Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combine inherited nonparam Security() objects #5667

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

kristjanvalur
Copy link
Contributor

@kristjanvalur kristjanvalur commented Nov 20, 2022

A simplified version of the rejected #5433 , this one combines the list of inherited "nonparam" dependencies. Multiple instances of a Security dependency are combined, their scopes joined into a single scope list.

This serves two purposes:

  1. In case there are many different scope checks set up, combine the invokation into one dependency call for efficiency.
  2. Allow a security dependency to interpret the combined list of scopes, for example, adding semantics where specially marked scopes can disable a previously added scope.

Example:

def my_security(scopes: SecurityScopes):
    active = set()
    for scope in scopes.scopes:
        if not scope.startswith("-"):
            active.add(scope)
        else:
            active.discard(scope[1:])
    apply_scopes(sorted(active))

see also #5622 which proposes to join nonparam dependencies with parameter dependencies in a similar manner.

@github-actions
Copy link
Contributor

📝 Docs preview for commit cf481b5 at: https://637a7de7e090c274f2beeb27--fastapi.netlify.app

Maintain order of dependencies when collapsing

keep ineritied security scopes in list order
@github-actions
Copy link
Contributor

📝 Docs preview for commit bec2dfc at: https://637a7f109d407f7b0734912b--fastapi.netlify.app

@github-actions
Copy link
Contributor

📝 Docs preview for commit a4deef4 at: https://637a80dc662f72679008991b--fastapi.netlify.app

@kristjanvalur kristjanvalur marked this pull request as ready for review November 21, 2022 10:24
@github-actions
Copy link
Contributor

github-actions bot commented Dec 1, 2022

📝 Docs preview for commit c22da74 at: https://6388bd4607d6820084382e83--fastapi.netlify.app

@github-actions
Copy link
Contributor

📝 Docs preview for commit 4b66d8f at: https://639ce5f789c20f057ba4cd45--fastapi.netlify.app

@github-actions
Copy link
Contributor

📝 Docs preview for commit dfe1220 at: https://639eef222b35ad633be481bd--fastapi.netlify.app

@alejsdev alejsdev added investigate feature New feature or request p3 and removed investigate labels Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request p3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants