You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am working on a more complex authorization mechanism and the only thing that is preventing me from using the starlette.authentication.require is that it hard codes starlette.authentication.require.has_required_scope to validate scopes against the request. I would like to propose adding a validate_scopes kwarg to require to allow passing in a user defined function. The default would be has_required_scopes. This would also provide a mechanism to better support #643. Will open a PR if this is acceptable.
This discussion was converted from issue #905 on February 14, 2022 10:19.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am working on a more complex authorization mechanism and the only thing that is preventing me from using the
starlette.authentication.require
is that it hard codesstarlette.authentication.require.has_required_scope
to validate scopes against the request. I would like to propose adding avalidate_scopes
kwarg torequire
to allow passing in a user defined function. The default would behas_required_scopes
. This would also provide a mechanism to better support #643. Will open a PR if this is acceptable.Code to be modified https://github.com/encode/starlette/blob/678f87da74232a76feb7db9b273a6b23fa56d92d/starlette/authentication.py#L19-23
The suggested signature would be as follows with references to
has_required_scopes
replaced in the function bodyFor #643 and my use case would enable something like
Beta Was this translation helpful? Give feedback.
All reactions