mirror of https://github.com/tiangolo/fastapi.git
Update code and tests to use `oauth_scopes` instead of `scopes`
This commit is contained in:
parent
4c6fd06027
commit
be6db923bf
|
|
@ -127,7 +127,7 @@ def get_parameterless_sub_dependant(*, depends: params.Depends, path: str) -> De
|
|||
)
|
||||
own_oauth_scopes: List[str] = []
|
||||
if isinstance(depends, params.Security) and depends.oauth_scopes:
|
||||
own_oauth_scopes.extend(depends.scopes)
|
||||
own_oauth_scopes.extend(depends.oauth_scopes)
|
||||
return get_dependant(
|
||||
path=path,
|
||||
call=depends.dependency,
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ def app_fixture(call_counter: Dict[str, int]):
|
|||
@app.get("/")
|
||||
def endpoint(
|
||||
db: Annotated[str, Depends(get_db)],
|
||||
user: Annotated[str, Security(get_user, scopes=["read"])],
|
||||
user: Annotated[str, Security(get_user, oauth_scopes=["read"])],
|
||||
):
|
||||
return {"db": db}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ async def security2(scopes: SecurityScopes):
|
|||
|
||||
|
||||
async def dep3(
|
||||
dep1: Annotated[List[str], Security(security1, scopes=["scope1"])],
|
||||
dep2: Annotated[List[str], Security(security2, scopes=["scope2"])],
|
||||
dep1: Annotated[List[str], Security(security1, oauth_scopes=["scope1"])],
|
||||
dep2: Annotated[List[str], Security(security2, oauth_scopes=["scope2"])],
|
||||
):
|
||||
return {"dep1": dep1, "dep2": dep2}
|
||||
|
||||
|
|
@ -28,7 +28,7 @@ app = FastAPI()
|
|||
|
||||
@app.get("/scopes")
|
||||
def get_scopes(
|
||||
dep3: Annotated[Dict[str, Any], Security(dep3, scopes=["scope3"])],
|
||||
dep3: Annotated[Dict[str, Any], Security(dep3, oauth_scopes=["scope3"])],
|
||||
):
|
||||
return dep3
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ def app_fixture(call_counts: Dict[str, int]):
|
|||
}
|
||||
|
||||
def get_user_me(
|
||||
current_user: Annotated[dict, Security(get_current_user, scopes=["me"])],
|
||||
current_user: Annotated[dict, Security(get_current_user, oauth_scopes=["me"])],
|
||||
):
|
||||
call_counts["get_user_me"] += 1
|
||||
return {
|
||||
|
|
@ -59,7 +59,7 @@ def app_fixture(call_counts: Dict[str, int]):
|
|||
@app.get("/")
|
||||
def path_operation(
|
||||
user_me: Annotated[dict, Depends(get_user_me)],
|
||||
user_items: Annotated[dict, Security(get_user_items, scopes=["items"])],
|
||||
user_items: Annotated[dict, Security(get_user_items, oauth_scopes=["items"])],
|
||||
):
|
||||
return {
|
||||
"user_me": user_me,
|
||||
|
|
|
|||
Loading…
Reference in New Issue