Commit Graph

37 Commits

Author SHA1 Message Date
Andrew Bettison
8345d896a6 Add Route REST API (fixes #96)
Consists of a single, one-shot request, GET /restful/route/all.json, for
the time being.  A "newsince" request can be added later.

Add a Markdown tech doc that specifies the new Route REST API and update
the MDP tech doc a little.

Add the 'routerestful' test script, which uses some test utility
fuctions that have been factored out of the 'routing' test script into
the new testdefs_routing.sh.

Add the new 'allrestful' test script.
2018-03-29 15:31:03 +10:30
Andrew Bettison
c35af0617a Fix header files for Xcode iOS build
- make "debug.h" a private header so that the DEBUG() macro does not
  interfere with Xcode Debug builds, which set DEBUG=1
- move all #include "debug.h" from headers into .c files
- move 'struct idebug' into a new public header "idebug.h" so that
  "log.h" can be public
- move HTTPD port number defs from "httpd.h" to "constants.h", so that
  "httpd.h" can be private and "conf.h" can be public
- add missing nested includes so each header compiles stand-alone
  without error
- #include "sodium.h" instead of <sodium.h>
- #include "sqlite3.h" instead of <sqlite3.h>
- add header guard to "fifo.h"
- fix header guard in "sync_keys.h"
2018-03-06 15:29:29 +10:30
Andrew Bettison
e9d91d04ca Fix failing Rhizome Java API tests
Update the Java API to be consistent with recent changes to the Rhizome
REST API was that regularised the MIME types used in Content-Type
headers.

Add some missing CONTENT_TYPE_ constants to "httpd.h", and ensure they
are consistent with the Java getMimeType() methods in subclasses of
AbstractId.

Add the --stderr option to all executeJavaOk statements in the
'rhizomejava' test script, to reveal the exception message in the case
of failure.
2018-03-06 15:16:56 +10:30
Andrew Bettison
34e2e8d4bc Improve and document HTTP REST Rhizome import
The REST Rhizome import request now requires the 'id' and 'version'
query parameters to either both be supplied or neither, and fails if
they do not match the manifest that is supplied in the request body.
Added a test case for this.

Added a test case to ensure that if the 'id' and 'version' query
parameters cause a hit (already in store) then the response is sent
immediately without reading the request body.

Improve the documentation for the REST Rhizome import request.
2017-10-20 15:50:18 +10:30
Andrew Bettison
29ce8994f2 Improve HTTP Content-Type handling
Undo a change from late 2015 that allowed the format=text+binarysig
parameter of the rhizome/manifest MIME content-type to be optional -- it
is easy to provide that parameter via libcurl, and the lbard code has
just been updated to provide it.

Make Content-Type handling consistent throughout the Serval DNA code by
using 'struct mime_content_type' to represent both parsed (request) and
sent (response) Content-Type fields, replacing ad-hoc in-line string
literals.

Fix some TODOs by adding the "serval/sid", "rhizome/bid" and
"rhizome/bundlesecret" MIME types, which remain optional for the time
being to preserve REST API compatibility with clients that do not set
the Content-Type of their 'bundle-author', 'bundle-id' and
'bundle-secret' parameters.
2017-10-20 09:55:21 +10:30
Jeremy Lakeman
a473304c06 Add restful import API 2017-05-17 10:16:46 +09:30
Jeremy Lakeman
4b98def664 Add newsince request for incoming activity 2017-04-19 14:46:37 +09:30
Jeremy Lakeman
be9c138559 Add restful API for feed activity 2017-04-19 14:46:37 +09:30
Jeremy Lakeman
d2dfe71f26 Restful meshmb list subscribed feeds 2017-04-19 14:46:36 +09:30
Jeremy Lakeman
e7ca268dbc Add restful API's for follow and ignore 2017-04-19 14:46:36 +09:30
Jeremy Lakeman
eff46c9030 Add manifest name to meshmb restful output 2016-10-26 13:09:34 +10:30
Jeremy Lakeman
09d04d7c8f Add restful api for listing broadcast messages 2016-10-26 13:08:19 +10:30
Jeremy Lakeman
c2956568d6 Send a meshmb message via restful api 2016-10-26 13:08:13 +10:30
Jeremy Lakeman
e13b9c3c94 Reduce redundant reading of message ply's 2016-08-23 14:28:13 +09:30
Andrew Bettison
98ed0406c5 Refactor Rhizome result handling
- Introduce the new 'struct rhizome_bundle_result' that contains a
  rhizome_bundle_status enum value and an optional, nul-terminated
  string that provides an explanation of the cause of the status; add
  functions to construct, query, and free the struct

- Replace 'enum rhizome_add_result' with 'struct rhizome_bundle_result',
  removing an unnecessary level of enum interpretation

- Make rhizome_fill_manifest() return 'struct rhizome_bundle_result' and
  add logic to check that the supplied author SID is correct (previous
  behaviour was: if an incorrect author SID was supplied but the correct
  author could be found in the keyring, then the incorrect one was
  silently ignored)

- Simplify the response code in rhizome_restful.cc to take advantage of
  the new 'struct rhizome_bundle_result'; in particular, the mapping
  from 'enum rhizome_bundle_status' codes to HTTP status codes is now
  expressed in a single switch statement

- Fix some minor failures in test scripts revealed by the changes
2015-12-01 00:51:15 +10:30
Andrew Bettison
419364b5a9 Improve REST HTTP response status codes
List all the HTTP status codes in the REST API tech doc.

Only use 403 Forbidden for requests originating from a disallowed
origin (ie, not localhost).

- Return 400 for missing, unknown, duplicate and out-of-order form
  parts in POST requests.
- Return 415 Unsupported Media Type for unsupported form part
  Content-Disposition and Content-Type (including unsupported
  charset).
- Return 414 Request-URI Too Long for any buffer exhaustion while
  parsing request.
- Return 419 Authentication Timeout for missing crypto secret.
2015-11-02 12:26:40 +10:30
gardners
52bd428c09 make rhizome http port number configurable via serval.conf 2015-08-24 16:06:25 +09:30
Jeremy Lakeman
84caf21969 Use section linking to define httpd pages 2015-08-24 12:49:09 +09:30
Andrew Bettison
abb2a39330 Fix MeshMS REST newsince race condition
During GET /restful/meshms/SID1/SID2/newsince/messagelist.json, if a new
message was received before the request reached the end of its message
iterator and paused, then the new message did not make it into the
output.
2015-06-29 15:39:19 +09:30
Andrew Bettison
9f15c4770c Add [httpd/N] context to HTTP server logging 2015-06-29 15:39:19 +09:30
Andrew Bettison
0ac9d15b8f Rename variable to current_httpd_request_count 2015-06-29 15:39:19 +09:30
Andrew Bettison
6febcc350d Replace RESTful newsince polling with triggers
Remove the 'api.restful.newsince_poll_ms' config option, no longer
needed.
2015-06-02 02:23:06 +09:30
Andrew Bettison
ccf4824605 Add 'manifest-id' parameter to /restful/rhizome/insert 2015-03-28 05:09:38 +10:30
Andrew Bettison
015b4a0b07 Refactor and improve "journal append"
Distinguish between fatal and user-supplied-input errors, return
error descriptive text in a strbuf to allow dynamic content, apply
user-supplied field assgnments/deletions _after_ copying existing
manifest fields, use exit status 4 (invalid manifest) when applying
journal append to a non-journal or vice versa
2015-03-23 17:38:46 +10:30
Andrew Bettison
c9131f43a2 POST /restful/rhizome/append for journals 2015-03-02 18:52:12 +10:30
Jeremy Lakeman
ce21c64809 Allow serving of static http content from [etc]/static/ 2014-12-01 10:21:35 +10:30
Andrew Bettison
d8f26a76ee Accept '#passphrase' for bundle secret arguments
As well as a hex string.  Applies to CLI and also REST API.
Maximum pass phrase length is 80 ASCII chars.
2014-11-14 13:11:44 +10:30
Andrew Bettison
a4be1b0b0c Fix RESTful MeshMS newsince ACK logic
/restful/meshms/newsince/SID1/SID2/newsince/TOKEN/messagelist.json now
always lists an ACK as soon as it is received, instead of waiting for a
message to arrive as well.
2014-11-12 23:09:00 +10:30
Jeremy Lakeman
851144ea0a Refactor keyring identity iteration 2014-10-31 15:19:59 +10:30
Tobias Wooldridge
e79e74feb9 Exposes a list of configured identities through the REST API at /keyring/identities.json 2014-10-31 15:19:59 +10:30
Andrew Bettison
cf43635789 Improve Rhizome HTTP RESTful interface
Add RHIZOME_BUNDLE_STATUS_READONLY enum value

Tighten up switch statements on bundle and payload status enums (no
default labels)

Rename some recently added enum entries

Return bundle status and payload status in HTTP responses

Add test for failing to decrypt a foreign encrypted bundle payload,
fix bug that caused an assertion failure

Add tests for fetching a non-existent manifest and fetching bundles
whose payload blob is not in the store
2014-07-10 06:29:51 +09:30
Andrew Bettison
067340bbba Change HTTP Authorization realm to "Serval RESTful API"
Was "Serval Rhizome", which is not accurate
2014-06-30 11:11:01 +09:30
Jeremy Lakeman
186b6cbc2f Allow more servald's to be running during tests 2014-06-27 12:46:29 +09:30
Andrew Bettison
819b8dc9e7 MeshMS RESTful API stricter on incoming form data
/restful/meshms/SID/SID/sendmessage now enforces Content-Disposition:
form-data (was ignoring), and enforces Content-Type: text/plain;
charset=utf-8 (was ignoring)

New negative test cases to ensure that these are treated strictly
2014-06-23 12:27:09 +09:30
Andrew Bettison
fd86a3d17f Implement HTTP POST /restful/meshms/<SID>/<SID>/sendmessage
Rename struct meshms_ply fields from "buffer" to "record" for
consistency with comment terminology
2014-02-05 14:28:15 +10:30
Andrew Bettison
fb2709d10c Create rhizome_restful.c, meshms_restful.c
Move code from rhizome_http.c into rhizome_restful.c and
meshms_restful.c
2014-02-03 23:05:15 +10:30
Andrew Bettison
051066af86 Rename "rhizome_http.h" to "httpd.h" 2014-02-03 21:40:05 +10:30