Browse Source

🎨 [pre-commit.ci] Auto format from pre-commit.com hooks

pull/10278/head
pre-commit-ci[bot] 1 week ago
parent
commit
cf4739d81f
  1. 6
      docs_src/security/tutorial008_an_py39.py

6
docs_src/security/tutorial008_an_py39.py

@ -50,7 +50,9 @@ class AccessTokenValidator(HTTPBearer):
result = self.keyset_cache[self.uri] = response.text result = self.keyset_cache[self.uri] = response.text
return result return result
async def __call__(self, request: Request, security_scopes: SecurityScopes) -> AccessTokenCredentials: # type: ignore async def __call__(
self, request: Request, security_scopes: SecurityScopes
) -> AccessTokenCredentials: # type: ignore
"""Validates the JWT Access Token. If security_scopes are given, they are validated against the roles_claim in the Access Token.""" """Validates the JWT Access Token. If security_scopes are given, they are validated against the roles_claim in the Access Token."""
# 1. Unpack bearer token # 1. Unpack bearer token
unverified_token = await super().__call__(request) unverified_token = await super().__call__(request)
@ -131,6 +133,6 @@ oauth2 = AccessTokenValidator(
@app.get("/hello") @app.get("/hello")
async def hello( async def hello(
token: Annotated[AccessTokenCredentials, Security(oauth2, scopes=["Foo"])] token: Annotated[AccessTokenCredentials, Security(oauth2, scopes=["Foo"])],
) -> str: ) -> str:
return "Hi!" return "Hi!"

Loading…
Cancel
Save