Commit Graph

193 Commits

Author SHA1 Message Date
D. Berge
3c4a558e02 Serve OpenAPI document on API root.
When a client makes a request for `/` (the root of
the API), the OpenAPI description is served in an
appropriate format according to the `Accept` request
header, as follows:

Accept: text/html => HTML version
Accept: application/json => JSON version
Accept: * => YAML version
2020-12-29 16:20:57 +01:00
D. Berge
5ffd3712cf Merge branch '61-user-authentication' into devel 2020-10-23 15:14:09 +02:00
D. Berge
141d5805ae Reissue user login tokens when close to expiring 2020-10-23 14:50:35 +02:00
D. Berge
8a0bcc5cb4 Change HTTP response status from 201 to 204 2020-10-23 11:00:56 +02:00
D. Berge
59aaacbeee Apply access restrictions to writable routes 2020-10-12 19:43:07 +02:00
D. Berge
3c86981dc6 Add authorisation middleware.
Defines three levels of access:
* read: anyone who is logged in
* write: `user` and `admin` roles
* admin: `admin` roles
2020-10-12 19:42:02 +02:00
D. Berge
5594b6863c Do not run authentication if headers already sent 2020-10-12 19:41:00 +02:00
D. Berge
7201c29df5 Inject auth middleware after login routes.
Routes not requiring authentication must,
self-evidently, go before the authentication
middleware.
2020-10-11 22:11:36 +02:00
D. Berge
947736e8c1 Check code rather than errno.
Different versions of that library work
differently.
2020-10-11 22:10:21 +02:00
D. Berge
cdd007ce88 Fix authentification middleware 2020-10-11 19:08:36 +02:00
D. Berge
2aca34e488 Read user login info from discrete file.
`$DOUGAL_ROOT/etc/users.yaml` to be exact.
2020-10-11 18:21:19 +02:00
D. Berge
dd32982cbe Add login/logout middleware 2020-10-11 17:52:13 +02:00
D. Berge
a3bfb73937 Add authentication middleware.
The user is authenticated by one of the following
methods, in order of priority:

* The presence of a valid JWT.
* Its IP.
* Its hostname.

In the case of the latter two methods, if authentication
is successful a JWT valid for 15 minutes will be generated
and passed back to the user in a cookie.
2020-10-11 13:11:43 +02:00
D. Berge
72922560d2 Add GeoJSON output of planned lines 2020-10-09 13:58:11 +02:00
D. Berge
63254a6bf7 Add planner endpoints 2020-10-08 16:40:52 +02:00
D. Berge
963f75fd51 Add exporting of missing shots.
It is enabled by default but the user should pass
`missing=t` (or some other truty value) in the query
part of the request.
2020-10-04 03:49:04 +02:00
D. Berge
cf1678ed25 Increase body-parser limits.
Fixes #51.
2020-10-02 15:28:43 +02:00
D. Berge
f9ef971802 Add preplot line patching endpoint.
Allows us to change remarks, meta and ntba
fields in preplot lines.
2020-10-01 18:28:02 +02:00
D. Berge
bdf573d4a6 Add Dougal-specific data to structured sequence exports 2020-09-30 15:54:16 +02:00
D. Berge
32d97a4856 Fix errors in Multiseis export 2020-09-29 20:28:56 +02:00
D. Berge
e7099643f5 Try harder to produce Multiseis export files.
We try to ensure that for each sequence we have
at least FSP and LSP entries. We do this by:

* If there exists a FGSP / LGSP, we clone those as
FSP / LSP respectively.

* Otherwise, we take the first and last shots
found in the final P1 which have a preplot.

We also include log comments whenever possible and
format the azimuth a bit better.
2020-09-29 18:05:46 +02:00
D. Berge
fd1f1a2c1a Implement sequence patching endpoint.
Allows us to change remarks and meta fields in sequences.
2020-09-27 19:21:59 +02:00
D. Berge
acf58df59f Return events in structured sequence export format.
The events endpoint will return data in the format
agreed with Multiseis if the request has an
Accept: application/vnd.seis+json
header.

Related to #12.
2020-09-26 22:55:11 +02:00
D. Berge
b76f1f166b Refactor events middleware.
The reason for refactoring was to accommodate
Multiseis / client sequence exports, which will be
served by this endpoint via a specific Content-Type.

In the process, the cache has been fixed and redesigned.

Related to #12.
2020-09-26 17:41:47 +02:00
D. Berge
42d453f714 Cache event responses at the middleware level.
This is not really a substitute for proper database
design but if deemed useful it might be refactored
into a more generic caching middleware and applied
to other requests as a low-cost alternative to
database refactoring while we gain usage and
performance information.
2020-09-25 18:29:40 +02:00
D. Berge
80e8ccef9c Add endpoints for setting and retrieving metadata 2020-09-20 18:11:33 +02:00
D. Berge
db25878fdd Add info API endpoint.
It queries a project's `info` table.
2020-09-09 15:55:04 +02:00
D. Berge
eded667d79 Add endpoint for retrieving real-time data as GeoJSON 2020-09-01 10:58:37 +02:00
D. Berge
557d87de72 Add endpoint to retrieve real-time input data 2020-09-01 10:56:25 +02:00
D. Berge
e5bc5a0757 Refactor project summaries to use database views 2020-08-26 20:20:53 +02:00
D. Berge
f486b4835e Instrument alerts for HTTP backend.
An alert is sent whenever an endpoint returns
an error other than an explicit failure (e.g.,
it won't send an alert if a middleware intentionally
returns a {status: XXX} object).
2020-08-25 11:32:13 +02:00
D. Berge
721dae4084 Catch all middleware errors 2020-08-24 13:25:14 +02:00
D. Berge
949defd2f6 Add event API endpoints 2020-08-22 20:46:15 +02:00
D. Berge
a55046ed93 Add a meta property to requests.
Using the meta(key, value) middleware factory, the user
can add a property req.meta[key] = value to the request.
2020-08-22 20:46:15 +02:00
D. Berge
0c4d91c603 Implement event DELETE middleware 2020-08-22 20:46:15 +02:00
D. Berge
5349708fb8 Implement event PUT middleware 2020-08-22 20:46:15 +02:00
D. Berge
58694ac1c1 Refactor event POST middleware.
It can now take some parameters from the request URL.
If present, request URL parameters take precedence over
request body values.
2020-08-22 20:45:59 +02:00
D. Berge
c93188a5a7 Add event POST middleware to API 2020-08-16 10:50:58 +02:00
D. Berge
2bfa340b52 Add API endpoint to retrieve survey configuration.
The endpoint /project/:project/configuration/:path(*)?
returns the contents of the survey configuration YAML
file for a given project.

To retrieve the full configuration:
 * /project/:project/configuration

To retrieve a specific subset (e.g., binning parameters):

 * /project/:project/configuration/binning

To retrieve a specific value (e.g., inline bin width):

 * /project/:project/configuration/binning/I_width
2020-08-16 10:06:43 +02:00
D. Berge
a73376572b API: Add label querying endpoint.
Labels can be associated with events and can have
display properties such as a description and colour,
this is why we need an endpoint for the client to
retrieve them.
2020-08-12 11:41:28 +02:00
D. Berge
d52f8f8bc2 API: Add event querying endpoint.
Events may be filtered by sequence(s):
   …/event?sequence=1
   …/event?sequence=1;3;7

Events may be filtered by date:
   …/event?date0=1970-01-01

Events may be filtered by a date interval:
   …/event?date0=1970-01-01&date1=1980-01-01

Events may also be paginated.
2020-08-12 11:35:57 +02:00
D. Berge
91f6fc3763 Remove debugging statement 2020-08-11 20:21:19 +02:00
D. Berge
4c5d29494c Initial commit 2020-08-08 23:59:13 +02:00