Skip to content

Commit

Permalink
docs: authz implementation methods tables
Browse files Browse the repository at this point in the history
  • Loading branch information
v-rocheleau committed Oct 31, 2024
1 parent f9f9533 commit 33d5fd7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ You can then attach VS Code to the `tds` container, and use the preconfigured `P

The Transcriptomics-Data-Service is meant to be a reusable microservice that can be integrated in existing
stacks. Since authorization schemes vary across projects, TDS allows adopters to code their own authorization plugin,
enabling adopters to leverage their existing access control tools and policies.
enabling adopters to leverage their existing access control code, tools and policies.

See the [authorization docs](./docs/authz.md) for more information on how to create and use the authz plugin with TDS.

Expand Down
23 changes: 22 additions & 1 deletion docs/authz.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ Furthermore, the content of the file must follow some implementation guidelines:
- In that class, you MUST implement the functions from BaseAuthzMiddleware with the expected signatures:
- `attach`: used to attach the middleware to the FastAPI app.
- `dipatch`: called for every request made to the API.
- `dep_authorize_<endpoint>`: endpoint-specific, authz evaluation functions that should return an injectable function.
- Finally, the script should expose an instance of your concrete authz middleware, named `authz_middleware`.

Looking at [bento.authz.module.py](./etc/bento.authz.module.py), we can see an implementation that is specific to
Expand All @@ -40,6 +39,28 @@ Rather than directly implementing the `attach`, `dispatch` and other authorizati

The only thing left to do is to implement the endpoint-specific authorization functions.

Here is a full view of the methods you can implement and their purpose.
| Lifecycle methods | Mandatory | Description |
| ----------------- | --------- | ------------------------------------------------------------------------------------------- |
| `attach` | YES | Attaches the middleware to the FastAPI app |
| `dispatch` | YES | Middleware dispatch executed for all requests. Handle authorization errors/exceptions here |
| `mark_authz_done` | NO | Bento lib authz middleware specific, marks that the authz check on a request was performed |

| App/router authorization methods | Description |
| -------------------------------- | -------------------------------------------------------------------- |
| `dep_app` | Returns a list of injectables that will be added as app dependencies |
| `dep_ingest_router` | Returns a list of injectables for the ingest router |
| `dep_expression_router` | Returns a list of injectables for the expression router |
| `dep_experiment_result_router` | Returns a list of injectables for the expression router |

| Endpoint authorization methods | Description |
| ------------------------------------ | --------------------------------------------------------- |
| `dep_public_endpoint` | Returns an injectable authz function for public endpoints |
| `dep_authz_ingest` | TODO |
| `dep_authz_normalize` | TODO |
| `dep_authz_expressions_list` | TODO |
| `dep_authz_delete_experiment_result` | TODO |
| `dep_authz_get_experiment_result` | TODO |
## Using an authorization plugin

When using the production image, the authz plugin must be mounted correclty on the container.
Expand Down

0 comments on commit 33d5fd7

Please sign in to comment.