mirror of https://github.com/tiangolo/fastapi.git
🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
This commit is contained in:
parent
27db96808f
commit
cf4739d81f
|
|
@ -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…
Reference in New Issue