2024-12-27 19:26:30 +00:00
== Features
The features of the project are the ones present in the course project description, but with an extra feature, the possibility to reset the database of the server. This was shown to be useful for testing purposes, but it should be disabled/deleted in a production environment.
The API has a list of endpoints that require different permission levels to access. Mainly, it's divided into 3 categories:
2024-12-28 17:13:16 +00:00
* <<_anonymous_endpoints,Anonymous>>: No authentication required.
* <<_authenticated_endpoints,Authenticated>>: Authentication required.
* <<_authorized_endpoints,Authorized>>: Authentication and permissions required.
2024-12-27 19:26:30 +00:00
2024-12-28 17:13:16 +00:00
[[_anonymous_endpoints]]
2024-12-27 19:26:30 +00:00
=== Anonymous Endpoints
[cols="1,1,1,1", options="header"]
|===
| Endpoint | Required headers | Required payload fields | Optional payload parameters
2024-12-28 17:13:16 +00:00
a| `GET /` → Returns a ping message.
2024-12-27 19:26:30 +00:00
| N/A
| N/A
| N/A
2024-12-28 17:13:16 +00:00
a| `POST /reset` → Resets the database and deletes all data.
a| * `Content-Type: application/json`
2024-12-27 19:26:30 +00:00
a| * `password`: The reset password. *Note: The reset password is `123` (very secure!).*
| N/A
2024-12-28 17:13:16 +00:00
a| `GET /org/list` → Returns a list of all organizations.
2024-12-27 19:26:30 +00:00
| N/A
| N/A
| N/A
2024-12-28 17:13:16 +00:00
a| `POST /org/create` → Creates a new organization.
a| * `Content-Type: application/octet-stream`
a|
* `name`: Organization name.
2024-12-27 19:26:30 +00:00
* `username`: Manager username.
* `full_name`: Manager full name.
* `email`: Manager email.
* `public_key`: Manager public key.
| N/A
2024-12-28 17:13:16 +00:00
a| `GET /file/get/<file_handle>/content` → Downloads the file content.
2024-12-27 19:26:30 +00:00
| N/A
| N/A
| N/A
2024-12-28 17:13:16 +00:00
.2+a| `POST /user/login` → Logs in a user.
a| * `Content-Type: application/json`
2024-12-27 19:26:30 +00:00
a| * `org`: Organization name.
* `username`: User username.
2024-12-28 17:13:16 +00:00
| N/A
a| * `Content-Type: application/octet-stream`
* `Authorization: token`
a| * `signature`: Signature of the challenge using the private key.
2024-12-27 19:26:30 +00:00
| N/A
|===
2024-12-28 17:13:16 +00:00
[[_authenticated_endpoints]]
2024-12-27 19:26:30 +00:00
=== Authenticated Endpoints
[cols="1,1,1,1", options="header", source]
|===
| Endpoint | Required headers | Required payload fields | Optional payload parameters
2024-12-28 17:13:16 +00:00
a| `GET /user/list` → Returns a list of all users
a| * `Content-Type: application/octet-stream`
* `Authorization: token`
2024-12-27 19:26:30 +00:00
| N/A
a| * `username`: Filter by username.
2024-12-28 17:13:16 +00:00
a| `GET /user/<username>/roles` → Returns a list of all roles of a user.
a| * `Authorization: token`
2024-12-27 19:26:30 +00:00
| N/A
| N/A
2024-12-28 17:13:16 +00:00
a| `GET /file/list` → Returns a list of all files.
a| * `Content-Type: application/octet-stream`
* `Authorization: token`
2024-12-27 19:26:30 +00:00
| N/A
2024-12-28 17:13:16 +00:00
a| * `username`: Filter by username.
2024-12-27 19:26:30 +00:00
* `datetime`: Filter by datetime. The datetime filter has the following fields:
2024-12-28 17:13:16 +00:00
** `value`: Epoch time in seconds.
** `relation`: `ot` \| `eq` \| `nt`. (One of the following: older than, equal to, newer than)
2024-12-27 19:26:30 +00:00
2024-12-28 17:13:16 +00:00
a| `POST /user/logout` → Logs out a user.
a| * `Authorization: token`
2024-12-27 19:26:30 +00:00
| N/A
| N/A
2024-12-28 17:13:16 +00:00
a| `POST /role/session/assume/<role>` → Assumes a role in the session.
a| * `Authorization: token`
| N/A
2024-12-27 19:26:30 +00:00
| N/A
2024-12-28 17:13:16 +00:00
a| `POST /role/session/drop/<role>` → Drops a role from the session.
a| * `Authorization: token`
| N/A
2024-12-27 19:26:30 +00:00
| N/A
2024-12-28 17:13:16 +00:00
a| `GET /role/session/list` → Lists the roles for the session.
a| * `Authorization: token`
2024-12-27 19:26:30 +00:00
| N/A
| N/A
2024-12-28 17:13:16 +00:00
a| `GET /role/<role>/list/users` → Lists the users for a role.
a| * `Authorization: token`
2024-12-27 19:26:30 +00:00
| N/A
| N/A
2024-12-28 17:13:16 +00:00
a| `GET /role/<role>/list/perms` → Lists the permissions for a role.
a| * `Authorization: token`
2024-12-27 19:26:30 +00:00
| N/A
| N/A
2024-12-28 17:13:16 +00:00
a| `GET /role/perm/<perm>/roles`: → Lists the roles with a permission.
a| * `Authorization: token`
2024-12-27 19:26:30 +00:00
| N/A
| N/A
|===
2024-12-28 17:13:16 +00:00
[[_authorized_endpoints]]
2024-12-27 19:26:30 +00:00
=== Authorized Endpoints
[cols="1,1,1,1", options="header", source]
|===
2024-12-28 17:13:16 +00:00
| Endpoint | Required headers | Required payload fields | Required permission
2024-12-27 19:26:30 +00:00
| `POST /user/create` → Creates a new user.
2024-12-28 17:13:16 +00:00
a| * `Content-Type: application/octet-stream`
* `Authorization: token`
2024-12-27 19:26:30 +00:00
a| * `username`: User's username.
* `name`: User's name.
* `email`: User's email.
* `public_key`: User's public key.
2024-12-28 17:13:16 +00:00
| SUBJECT_NEW
2024-12-27 19:26:30 +00:00
2024-12-28 17:13:16 +00:00
a| `POST /user/<username>/suspend` → Suspends a user.
a| * `Authorization: token`
2024-12-27 19:26:30 +00:00
| N/A
2024-12-28 17:13:16 +00:00
| SUBJECT_DOWN
2024-12-27 19:26:30 +00:00
2024-12-28 17:13:16 +00:00
a| `POST /user/<username>/activate` → Activates a user.
a| `Authorization: token`
2024-12-27 19:26:30 +00:00
| N/A
2024-12-28 17:13:16 +00:00
| SUBJECT_UP
2024-12-27 19:26:30 +00:00
2024-12-28 17:13:16 +00:00
a| `POST /file/upload/metadata` → Uploads a file's metadata.
a| * `Content-Type: application/octet-stream`
* `Authorization: token`
2024-12-27 19:26:30 +00:00
a| * `document_name`: Document name.
* `key`: Document key.
* `alg`: Document algorithm.
2024-12-28 17:13:16 +00:00
| DOC_NEW
2024-12-27 19:26:30 +00:00
2024-12-28 17:13:16 +00:00
a| `POST /file/upload/content` → Uploads a file's content.
2024-12-27 19:26:30 +00:00
a| * `Authorization: token`
* `Content-Type: multipart/form-data`
2024-12-28 17:13:16 +00:00
a| * file's content as request data
| DOC_NEW
2024-12-27 19:26:30 +00:00
2024-12-28 17:13:16 +00:00
a| `GET /file/get/<document_handle>/metadata` → Downloads a file's metadata.
a| * `Authorization: token`
2024-12-27 19:26:30 +00:00
| N/A
2024-12-28 17:13:16 +00:00
| DOC_READ
2024-12-27 19:26:30 +00:00
2024-12-28 17:13:16 +00:00
a| `POST /file/delete/<document_handle>` → Deletes a file.
a| * `Authorization: token`
2024-12-27 19:26:30 +00:00
| N/A
2024-12-28 17:13:16 +00:00
| DOC_DELETE
2024-12-27 19:26:30 +00:00
2024-12-28 17:13:16 +00:00
a| `POST /file/acl` → Updates the ACL of a file.
a| * `Content-Type: application/octet-stream`
* `Authorization: token`
2024-12-27 19:26:30 +00:00
a| * `document_handle`: Document handle.
* `role`: Role name.
* `perm`: Permission name.
* `operation`: `add` \| `remove`. (One of the following: add, remove)
2024-12-28 17:13:16 +00:00
| DOC_ACL
2024-12-27 19:26:30 +00:00
2024-12-28 17:13:16 +00:00
a| `POST /role/create` → Creates a new role.
a| * `Content-Type: application/octet-stream`
* `Authorization: token`
2024-12-27 19:26:30 +00:00
a| * `role`: Role name.
2024-12-28 17:13:16 +00:00
| ROLE_NEW
2024-12-27 19:26:30 +00:00
2024-12-28 17:13:16 +00:00
a| `POST /role/<role>/suspend` → Suspends a role.
a| * `Authorization: token`
2024-12-27 19:26:30 +00:00
| N/A
2024-12-28 17:13:16 +00:00
| ROLE_DOWN
2024-12-27 19:26:30 +00:00
2024-12-28 17:13:16 +00:00
a| `POST /role/<role>/activate` → Activates a role
a| * `Authorization: token`
2024-12-27 19:26:30 +00:00
| N/A
2024-12-28 17:13:16 +00:00
| ROLE_UP
2024-12-27 19:26:30 +00:00
2024-12-28 17:13:16 +00:00
a| `POST /role/<role>/user/add/<username>` → Adds a user to a role.
a| * `Authorization: token`
2024-12-27 19:26:30 +00:00
| N/A
2024-12-28 17:13:16 +00:00
| ROLE_MOD
2024-12-27 19:26:30 +00:00
2024-12-28 17:13:16 +00:00
a| `POST /role/<role>/user/remove/<username>` → Removes a user from a role.
a| * `Authorization: token`
2024-12-27 19:26:30 +00:00
| N/A
2024-12-28 17:13:16 +00:00
| ROLE_MOD
2024-12-27 19:26:30 +00:00
2024-12-28 17:13:16 +00:00
a| `POST /role/<role>/perm/add/<perm>` → Adds a permission to a role.
a| * `Authorization: token`
2024-12-27 19:26:30 +00:00
| N/A
2024-12-28 17:13:16 +00:00
| ROLE_MOD
2024-12-27 19:26:30 +00:00
2024-12-28 17:13:16 +00:00
a| `POST /role/<role>/perm/remove/<perm>` → Removes a permission from a role.
a| * `Authorization: token`
2024-12-27 19:26:30 +00:00
| N/A
2024-12-28 17:13:16 +00:00
| ROLE_MOD
2024-12-27 19:26:30 +00:00
|===