diff --git a/fastapi/dependencies/utils.py b/fastapi/dependencies/utils.py index e765bbc74..a4dc5ca19 100644 --- a/fastapi/dependencies/utils.py +++ b/fastapi/dependencies/utils.py @@ -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, diff --git a/tests/test_security_scopes.py b/tests/test_security_scopes.py index 248fd2bcc..4bcf5248f 100644 --- a/tests/test_security_scopes.py +++ b/tests/test_security_scopes.py @@ -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} diff --git a/tests/test_security_scopes_dont_propagate.py b/tests/test_security_scopes_dont_propagate.py index 2bbcc749d..1da6544b8 100644 --- a/tests/test_security_scopes_dont_propagate.py +++ b/tests/test_security_scopes_dont_propagate.py @@ -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 diff --git a/tests/test_security_scopes_sub_dependency.py b/tests/test_security_scopes_sub_dependency.py index 9cc668d8e..e1ad3248f 100644 --- a/tests/test_security_scopes_sub_dependency.py +++ b/tests/test_security_scopes_sub_dependency.py @@ -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,