Archived
2

removed maintain user, constrained spctra access

This commit is contained in:
VLE2FE
2020-08-05 18:28:27 +02:00
parent 821b2664bd
commit a910371882
22 changed files with 357 additions and 221 deletions

View File

@ -5,28 +5,35 @@ info:
title: Digital fingerprint of plastics - API
version: 1.0.0
description: |
This API gives access to the project database.<br>
This **API** gives access to the project database.
Access is restricted. Authentication can be obtained with HTTP Basic Auth using username and password.
Data access methods can also be accessed using an API key at the URL ending like ?key=xxx<br>
Data access methods can also be accessed using an API key at the URL ending like ?key=xxx
The description lists available authentication methods, also the locks of each method close correspondingly
if the entered authentication is allowed.<br><br>
There are a number of different user levels: <br>
<ul>
<li>read: read access to the samples database</li>
<li>write: write access to the samples database, users can change only the values they created</li>
<li>maintain: functions like changing templates, validating data, changing values of others</li>
<li>dev: handling machine learning models</li>
<li>admin: user administration</li>
</ul>
if the entered authentication is allowed.
There are a number of different user levels:
| | read sample data | add samples/edit own | read spectral data | edit other's data | maintain templates | edit users |
|:-----:|:----------------:|:--------------------:|:------------------:|:-----------------:|:------------------:|:----------:|
| read | yes | no | no | no | no | no |
| write | yes | yes | no | no | no | no |
| dev | yes | yes | yes | yes | yes | no |
| admin | yes | yes | yes | yes | yes | yes |
Password policy:
<ul>
<li>at least one digit</li>
<li>at least one lower case letter</li>
<li>at least one upper case letter</li>
<li>at least one of the following special characters: !"#%&'()*+,-./:;<=>?@[\]^_`{|}~</li>
<li>no whitespace</li>
<li>at least 8 characters</li>
</ul>
- at least one digit
- at least one lower case letter
- at least one upper case letter
- at least one of the following special characters: !"#%&'()*+,-./:;<=>?@[\]^_`{|}~
- no whitespace
- at least 8 characters
<br>
x-doc: |
status:
<ul>

View File

@ -1,7 +1,7 @@
/materials:
get:
summary: lists all materials
description: 'Auth: all, levels: read, write, maintain, dev, admin'
description: 'Auth: all, levels: read, write, dev, admin'
x-doc: returns only materials with status 10
tags:
- /material
@ -31,7 +31,7 @@
- $ref: 'api.yaml#/components/parameters/State'
get:
summary: lists all new/deleted materials
description: 'Auth: basic, levels: maintain, admin'
description: 'Auth: basic, levels: dev, admin'
x-doc: returns materials with status 0/-1
tags:
- /material
@ -54,8 +54,8 @@
- $ref: 'api.yaml#/components/parameters/Id'
get:
summary: get material details
description: 'Auth: all, levels: read, write, maintain, dev, admin'
x-doc: deleted samples are available only for maintain/admin
description: 'Auth: all, levels: read, write, dev, admin'
x-doc: deleted samples are available only for dev/admin
tags:
- /material
responses:
@ -73,7 +73,7 @@
$ref: 'api.yaml#/components/responses/500'
put:
summary: change material
description: 'Auth: basic, levels: write, maintain, dev, admin'
description: 'Auth: basic, levels: write, dev, admin'
x-doc: status is reset to 0 on any changes, deleted samples cannot be changed
tags:
- /material
@ -104,7 +104,7 @@
$ref: 'api.yaml#/components/responses/500'
delete:
summary: delete material
description: 'Auth: basic, levels: write, maintain, dev, admin'
description: 'Auth: basic, levels: write, dev, admin'
x-doc: sets status to -1
tags:
- /material
@ -129,7 +129,7 @@
- $ref: 'api.yaml#/components/parameters/Id'
put:
summary: restore material
description: 'Auth: basic, levels: maintain, admin'
description: 'Auth: basic, levels: dev, admin'
x-doc: status is set to 0
tags:
- /material
@ -152,7 +152,7 @@
- $ref: 'api.yaml#/components/parameters/Id'
put:
summary: restore material
description: 'Auth: basic, levels: maintain, admin'
description: 'Auth: basic, levels: dev, admin'
x-doc: status is set to 10
tags:
- /material
@ -173,7 +173,7 @@
/material/new:
post:
summary: add material
description: 'Auth: basic, levels: write, maintain, dev, admin'
description: 'Auth: basic, levels: write, dev, admin'
x-doc: 'Adds status: 0 automatically'
tags:
- /material
@ -204,7 +204,7 @@
/material/groups:
get:
summary: list all existing material groups
description: 'Auth: all, levels: read, write, maintain, dev, admin'
description: 'Auth: all, levels: read, write, dev, admin'
tags:
- /material
responses:
@ -227,7 +227,7 @@
/material/suppliers:
get:
summary: list all existing material suppliers
description: 'Auth: all, levels: read, write, maintain, dev, admin'
description: 'Auth: all, levels: read, write, dev, admin'
tags:
- /material
responses:

View File

@ -3,8 +3,8 @@
- $ref: 'api.yaml#/components/parameters/Id'
get:
summary: measurement values by id
description: 'Auth: all, levels: read, write, maintain, dev, admin'
x-doc: deleted samples are available only for maintain/admin
description: 'Auth: all, levels: read, write, dev, admin, spectral data can only be accessed by dev and admin'
x-doc: deleted samples are available only for dev/admin
tags:
- /measurement
responses:
@ -24,7 +24,7 @@
$ref: 'api.yaml#/components/responses/500'
put:
summary: change measurement
description: 'Auth: basic, levels: write, maintain, dev, admin'
description: 'Auth: basic, levels: write, dev, admin'
x-doc: status is reset to 0 on any changes, deleted measurements cannot be edited
tags:
- /measurement
@ -57,7 +57,7 @@
$ref: 'api.yaml#/components/responses/500'
delete:
summary: delete measurement
description: 'Auth: basic, levels: write, maintain, dev, admin'
description: 'Auth: basic, levels: write, dev, admin'
x-doc: sets status to -1
tags:
- /measurement
@ -82,7 +82,7 @@
- $ref: 'api.yaml#/components/parameters/Id'
put:
summary: restore measurement
description: 'Auth: basic, levels: maintain, admin'
description: 'Auth: basic, levels: dev, admin'
x-doc: status is set to 0
tags:
- /measurement
@ -105,7 +105,7 @@
- $ref: 'api.yaml#/components/parameters/Id'
put:
summary: set measurement status to validated
description: 'Auth: basic, levels: maintain, admin'
description: 'Auth: basic, levels: dev, admin'
x-doc: status is set to 10
tags:
- /measurement
@ -126,7 +126,7 @@
/measurement/new:
post:
summary: add measurement
description: 'Auth: basic, levels: write, maintain, dev, admin'
description: 'Auth: basic, levels: write, dev, admin'
x-doc: 'Adds status: 0 automatically'
tags:
- /measurement

View File

@ -21,7 +21,7 @@
/authorized:
get:
summary: Checks authorization
description: 'Auth: all, levels: read, write, maintain, dev, admin'
description: 'Auth: all, levels: read, write, dev, admin'
tags:
- /
responses:
@ -69,7 +69,9 @@
example: 30
get:
summary: get changelog
description: 'Auth: basic, levels: maintain, admin<br>Displays all logs older than timestamp, sorted by date descending, page defaults to 0, pagesize defaults to 25<br>Avoid using high page numbers for older logs, better use an older timestamp'
description: 'Auth: basic, levels: dev, admin<br>Displays all logs older than timestamp, sorted by date descending,
page defaults to 0, pagesize defaults to 25<br>Avoid using high page numbers for older logs, better use an older
timestamp'
tags:
- /
responses:

View File

@ -1,8 +1,9 @@
/samples:
get:
summary: all samples in overview
description: 'Auth: all, levels: read, write, maintain, dev, admin'
x-doc: 'Limitations: paging and csv output does not work when including the spectrum measurement fields as well as the returned number of total samples'
description: 'Auth: all, levels: read, write, dev, admin, spectral data can only be accessed by dev and admin'
x-doc: 'Limitations: paging and csv output does not work when including the spectrum measurement fields as well as
the returned number of total samples'
tags:
- /sample
parameters:
@ -19,7 +20,8 @@
type: string
example: 5ea0450ed851c30a90e70894
- name: to-page
description: relative change of pages, use negative values to get back, defaults to 0, works only together with page-size
description: 'relative change of pages, use negative values to get back, defaults to 0, works only together with
page-size'
in: query
schema:
type: string
@ -43,7 +45,8 @@
type: boolean
example: false
- name: fields[]
description: the fields to include in the output as array, defaults to ['_id','number','type','batch','material_id','color','condition','note_id','user_id','added']
description: "the fields to include in the output as array, defaults to ['_id', 'number', 'type',
'batch', 'material_id', 'color', 'condition', 'note_id', 'user_id', 'added']"
in: query
schema:
type: array
@ -51,19 +54,23 @@
type: string
example: ['number', 'batch']
- name: filters[]
description: "the filters to apply as an array of URIComponent encoded objects in the form {mode: 'eq/ne/lt/lte/gt/gte/in/nin', field: 'material.m', values: ['15']} using encodeURIComponent(JSON.stringify({}))"
description: "the filters to apply as an array of URIComponent encoded objects in the form {mode:
'eq/ne/lt/lte/gt/gte/in/nin', field: 'material.m', values: ['15']} using encodeURIComponent(JSON.stringify({}))"
in: query
schema:
type: array
items:
type: string
example: ["%7B%22mode%22%3A%22eq%22%2C%22field%22%3A%22material.m%22%2C%22values%22%3A%5B%2215%22%5D%7D", "%7B%22mode%22%3A%22isin%22%2C%22field%22%3A%22material.supplier%22%2C%22values%22%3A%5B%22BASF%22%2C%22DSM%22%5D%7D"]
example: '["%7B%22mode%22%3A%22eq%22%2C%22field%22%3A%22material.m%22%2C%22values%22%3A%5B%2215%22%5D%7D",
"%7B%22mode%22%3A%22isin%22%2C%22field%22%3A%22material.supplier%22%2C%22values%22%3A%5B%22BASF%22%2C%22DSM%22
%5D%7D"]'
responses:
200:
description: samples overview (if the csv parameter is set, this is in CSV instead of JSON format)
headers:
x-total-items:
description: Total number of available items when from-id is not specified and spectrum field is not included
description: Total number of available items when from-id is not specified and spectrum field is not
included
schema:
type: integer
example: 243
@ -87,7 +94,7 @@
- $ref: 'api.yaml#/components/parameters/State'
get:
summary: all new/deleted samples in overview
description: 'Auth: basic, levels: maintain, admin'
description: 'Auth: basic, levels: admin'
x-doc: returns only samples with status 0/-1
tags:
- /sample
@ -108,7 +115,7 @@
/samples/count:
get:
summary: total number of samples
description: 'Auth: all, levels: read, write, maintain, dev, admin'
description: 'Auth: all, levels: read, write, dev, admin'
tags:
- /sample
responses:
@ -129,8 +136,9 @@
- $ref: 'api.yaml#/components/parameters/Id'
get:
summary: sample details
description: 'Auth: all, levels: read, write, maintain, dev, admin<br>Returns validated as well as new measurements'
x-doc: deleted samples are available only for maintain/admin
description: 'Auth: all, levels: read, write, dev, admin, spectral data can only be accessed by dev and admin<br>
Returns validated as well as new measurements'
x-doc: deleted samples are available only for dev/admin
tags:
- /sample
responses:
@ -150,7 +158,8 @@
$ref: 'api.yaml#/components/responses/500'
put:
summary: change sample
description: 'Auth: basic, levels: write, maintain, dev, admin <br>Only maintain and admin are allowed to edit samples created by another user'
description: 'Auth: basic, levels: write, dev, admin <br>
Only dev and admin are allowed to edit samples created by another user'
x-doc: status is reset to 0 on any changes, deleted samples cannot be changed
tags:
- /sample
@ -181,8 +190,10 @@
$ref: 'api.yaml#/components/responses/500'
delete:
summary: delete sample
description: 'Auth: basic, levels: write, maintain, dev, admin <br>Only maintain and admin are allowed to edit samples created by another user'
x-doc: sets status to -1, notes and references to this sample are also kept, only note_fields are updated accordingly
description: 'Auth: basic, levels: write, dev, admin <br>
Only dev and admin are allowed to edit samples created by another user'
x-doc: sets status to -1, notes and references to this sample are also kept, only note_fields are updated
accordingly
tags:
- /sample
security:
@ -206,8 +217,9 @@
- $ref: 'api.yaml#/components/parameters/Number'
get:
summary: sample details
description: 'Auth: all, levels: read, write, maintain, dev, admin<br>Returns validated as well as new measurements'
x-doc: deleted samples are available only for maintain/admin
description: 'Auth: all, levels: read, write, dev, admin, spectral data can only be accessed by dev and admin<br>
Returns validated as well as new measurements'
x-doc: deleted samples are available only for dev/admin
tags:
- /sample
responses:
@ -231,7 +243,7 @@
- $ref: 'api.yaml#/components/parameters/Id'
put:
summary: restore sample
description: 'Auth: basic, levels: maintain, admin'
description: 'Auth: basic, levels: dev, admin'
x-doc: status is set to 0
tags:
- /sample
@ -254,7 +266,7 @@
- $ref: 'api.yaml#/components/parameters/Id'
put:
summary: set sample status to validated
description: 'Auth: basic, levels: maintain, admin'
description: 'Auth: basic, levels: dev, admin'
x-doc: status is set to 10
tags:
- /sample
@ -277,7 +289,8 @@
/sample/new:
post:
summary: add sample
description: 'Auth: basic, levels: write, maintain, dev, admin. Number property is only for admin when adding existing samples'
description: 'Auth: basic, levels: write, dev, admin. Number property is only for admin when adding existing
samples'
x-doc: 'Adds status: 0 automatically'
tags:
- /sample
@ -313,7 +326,7 @@
/sample/notes/fields:
get:
summary: list all existing field names for custom notes fields
description: 'Auth: all, levels: read, write, maintain, dev, admin'
description: 'Auth: all, levels: read, write, dev, admin'
x-doc: integrity has to be ensured
tags:
- /sample

View File

@ -3,7 +3,7 @@
- $ref: 'api.yaml#/components/parameters/Collection'
get:
summary: all available templates
description: 'Auth: basic, levels: read, write, maintain, dev, admin'
description: 'Auth: basic, levels: read, write, dev, admin'
tags:
- /template
security:
@ -28,7 +28,7 @@
- $ref: 'api.yaml#/components/parameters/Id'
get:
summary: template details
description: 'Auth: basic, levels: read, write, maintain, admin'
description: 'Auth: basic, levels: read, write, dev, admin'
tags:
- /template
security:
@ -48,7 +48,7 @@
$ref: 'api.yaml#/components/responses/500'
put:
summary: change template
description: 'Auth: basic, levels: maintain, admin'
description: 'Auth: basic, levels: dev, admin'
x-doc: With a change a new version is set, resulting in a new template with a new id
tags:
- /template
@ -83,7 +83,7 @@
- $ref: 'api.yaml#/components/parameters/Collection'
post:
summary: add template
description: 'Auth: basic, levels: maintain, admin'
description: 'Auth: basic, levels: dev, admin'
tags:
- /template
security:

View File

@ -24,7 +24,7 @@
/user:
get:
summary: list own user details
description: 'Auth: basic, levels: read, write, maintain, admin'
description: 'Auth: basic, levels: read, write, dev, admin'
tags:
- /user
security:
@ -44,7 +44,7 @@
$ref: 'api.yaml#/components/responses/500'
put:
summary: change user details
description: 'Auth: basic, levels: read, write, maintain, admin'
description: 'Auth: basic, levels: read, write, dev, admin'
tags:
- /user
security:
@ -86,7 +86,7 @@
$ref: 'api.yaml#/components/responses/500'
delete:
summary: delete user
description: 'Auth: basic, levels: read, write, maintain, admin'
description: 'Auth: basic, levels: read, write, dev, admin'
tags:
- /user
security:
@ -174,7 +174,7 @@
/user/key:
get:
summary: get API key for the user
description: 'Auth: basic, levels: read, write, maintain, dev, admin'
description: 'Auth: basic, levels: read, write, dev, admin'
tags:
- /user
security: