Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New auth (Authentication + Authorization) system. Major points:
Decorator
New decorator is opt-in. Create an object that wraps an existing
APIRouter
instance:Then substitute
@router.X
with@auth.X
:The second positional argument is the list of "scopes" (permissions) required for the endpoint.
Optional
auth_identity
argument to endpoint function can be used to extract the identity for further use (similar to use cases ofget_project_user
from old code).Authentication
Bearer tokens (users)
For now, user authentication uses the same system and login procedure as before (jwt bearer token through either a cookie or the
WWW-Authenticate
header).API keys
API-keys can be provided to endpoints with the
X-Api-Key
header, e.g.X-Api-Key: fai-abcdef...
.API keys can be created/list/revoked through the new API key CRUD api at
/api/auth/apikey
. Managing API keys requires thecan_manage_api_keys
scope.After the results of the initial create call (
POST /api/auth/apikey
) the actual API key is never exposed again. Instead a key can only be revoked by using itsrevoke_id
which is also provided in the result of the create call.TODO/future
Limit scopes an API key can be created with to a subset of the scopes available of the calling identityDONEIAuthorizationProvider