MCPcopy
hub / github.com/fastapi/fastapi / process_auth

Function process_auth

tests/test_dependency_paramless.py:15–25  ·  view source on GitHub ↗
(
    credentials: Annotated[str | None, Security(oauth2_scheme)],
    security_scopes: SecurityScopes,
)

Source from the content-addressed store, hash-verified

13
14
15def process_auth(
16 credentials: Annotated[str | None, Security(oauth2_scheme)],
17 security_scopes: SecurityScopes,
18):
19 # This is an incorrect way of using it, this is not checking if the scopes are
20 # provided by the token, only if the endpoint is requesting them, but the test
21 # here is just to check if FastAPI is indeed registering and passing the scopes
22 # correctly when using Security with parameterless dependencies.
23 if "a" not in security_scopes.scopes or "b" not in security_scopes.scopes:
24 raise HTTPException(detail="a or b not in scopes", status_code=401)
25 return {"token": credentials, "scopes": security_scopes.scopes}
26
27
28@app.get("/get-credentials")

Callers

nothing calls this directly

Calls 2

SecurityClass · 0.90
HTTPExceptionClass · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…