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

doc: add documentation for Security dependencies #5

Open
adriangb opened this issue Jan 18, 2022 · 0 comments
Open

doc: add documentation for Security dependencies #5

adriangb opened this issue Jan 18, 2022 · 0 comments

Comments

@adriangb
Copy link
Owner

adriangb commented Jan 18, 2022

Make sure to include the ability to dynamically configure security dependencies in lifespan events:

def get_name() -> str:
return "key"
class LazyAPIKeyHeader(APIKeyHeader):
def __init__(self, name: Annotated[str, Dependant(get_name, scope="app")]) -> None:
super().__init__(name=name)
class User(BaseModel):
username: str
def get_current_user(oauth_header: Annotated[str, Security(LazyAPIKeyHeader)]):
user = User(username=oauth_header)
return user
def read_current_user(current_user: Annotated[User, Dependant(get_current_user)]):
return current_user
app = App([Path("/users/me", get=read_current_user)])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant