Skip to content

Commit 3590423

Browse files
committed
fix
1 parent 6865cb9 commit 3590423

File tree

8 files changed

+32
-36
lines changed

8 files changed

+32
-36
lines changed

diracx-logic/src/diracx/logic/auth/authorize_code_flow.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
)
1919

2020

21-
async def authorization_flow(
21+
async def initiate_authorization_flow(
2222
request_url: str,
2323
code_challenge: str,
2424
code_challenge_method: Literal["S256"],
@@ -67,7 +67,7 @@ async def authorization_flow(
6767
return authorization_flow_url
6868

6969

70-
async def authorization_flow_complete(
70+
async def complete_authorization_flow(
7171
code: str,
7272
state: str,
7373
request_url: str,

diracx-logic/src/diracx/logic/auth/management.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
"""This module contains the auth management endpoints.
2-
3-
These endpoints are used to manage the user's authentication tokens and
4-
to get information about the user's identity.
5-
"""
1+
"""This module contains the auth management functions."""
62

73
from __future__ import annotations
84

@@ -15,8 +11,8 @@ async def get_refresh_tokens(
1511
auth_db: AuthDB,
1612
subject: str | None,
1713
) -> list:
18-
"""Get all refresh tokens for the user. If the user has the `proxy_management` property, then
19-
the subject is not used to filter the refresh tokens.
14+
"""Get all refresh tokens bound to a given subject. If there is no subject, then
15+
all the refresh tokens are retrieved.
2016
"""
2117
return await auth_db.get_user_refresh_tokens(subject)
2218

@@ -26,9 +22,7 @@ async def revoke_refresh_token(
2622
subject: str | None,
2723
jti: UUID,
2824
) -> str:
29-
"""Revoke a refresh token. If the user has the `proxy_management` property, then
30-
the subject is not used to filter the refresh tokens.
31-
"""
25+
"""Revoke a refresh token. If a subject is provided, then the refresh token must be owned by that subject."""
3226
res = await auth_db.get_refresh_token(jti)
3327

3428
if subject and subject != res["Sub"]:

diracx-logic/src/diracx/logic/auth/token.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
)
3131

3232

33-
async def token(
33+
async def get_oidc_token(
3434
grant_type: GrantType,
3535
client_id: str,
3636
auth_db: AuthDB,
@@ -200,7 +200,7 @@ async def get_oidc_token_info_from_refresh_flow(
200200
LEGACY_EXCHANGE_PATTERN = rf"Bearer diracx:legacy:({BASE_64_URL_SAFE_PATTERN})"
201201

202202

203-
async def legacy_exchange(
203+
async def perform_legacy_exchange(
204204
expected_api_key: str,
205205
preferred_username: str,
206206
scope: str,

diracx-logic/src/diracx/logic/auth/well_known.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from diracx.core.settings import AuthSettings, DevelopmentSettings
66

77

8-
async def openid_configuration(
8+
async def get_openid_configuration(
99
token_endpoint: str,
1010
userinfo_endpoint: str,
1111
authorization_endpoint: str,
@@ -38,7 +38,7 @@ async def openid_configuration(
3838
}
3939

4040

41-
async def installation_metadata(
41+
async def get_installation_metadata(
4242
config: Config,
4343
dev_settings: DevelopmentSettings,
4444
) -> Metadata:

diracx-routers/src/diracx/routers/auth/authorize_code_flow.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@
4545

4646
from diracx.core.exceptions import AuthorizationError, IAMClientError, IAMServerError
4747
from diracx.logic.auth.authorize_code_flow import (
48-
authorization_flow as authorization_flow_bl,
48+
complete_authorization_flow as complete_authorization_flow_bl,
4949
)
5050
from diracx.logic.auth.authorize_code_flow import (
51-
authorization_flow_complete as authorization_flow_complete_bl,
51+
initiate_authorization_flow as initiate_authorization_flow_bl,
5252
)
5353

5454
from ..dependencies import (
@@ -63,7 +63,7 @@
6363

6464

6565
@router.get("/authorize")
66-
async def authorization_flow(
66+
async def initiate_authorization_flow(
6767
request: Request,
6868
response_type: Literal["code"],
6969
code_challenge: str,
@@ -97,7 +97,7 @@ async def authorization_flow(
9797
user authorize flow.
9898
"""
9999
try:
100-
redirect_uri = await authorization_flow_bl(
100+
redirect_uri = await initiate_authorization_flow_bl(
101101
request_url=f"{request.url.replace(query='')}",
102102
code_challenge=code_challenge,
103103
code_challenge_method=code_challenge_method,
@@ -120,7 +120,7 @@ async def authorization_flow(
120120

121121

122122
@router.get("/authorize/complete")
123-
async def authorization_flow_complete(
123+
async def complete_authorization_flow(
124124
code: str,
125125
state: str,
126126
request: Request,
@@ -135,7 +135,7 @@ async def authorization_flow_complete(
135135
The user is then redirected to the client's redirect URI.
136136
"""
137137
try:
138-
redirect_uri = await authorization_flow_complete_bl(
138+
redirect_uri = await complete_authorization_flow_bl(
139139
code=code,
140140
state=state,
141141
request_url=str(request.url.replace(query="")),

diracx-routers/src/diracx/routers/auth/token.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Token endpoint implementation."""
1+
"""Token endpoint."""
22

33
from __future__ import annotations
44

@@ -21,8 +21,10 @@
2121
TokenResponse,
2222
)
2323
from diracx.logic.auth.token import create_token
24-
from diracx.logic.auth.token import legacy_exchange as legacy_exchange_bl
25-
from diracx.logic.auth.token import token as token_bl
24+
from diracx.logic.auth.token import get_oidc_token as get_oidc_token_bl
25+
from diracx.logic.auth.token import (
26+
perform_legacy_exchange as perform_legacy_exchange_bl,
27+
)
2628
from diracx.routers.access_policies import BaseAccessPolicy
2729

2830
from ..dependencies import AuthDB, AuthSettings, AvailableSecurityProperties, Config
@@ -66,7 +68,7 @@ async def mint_token(
6668

6769

6870
@router.post("/token")
69-
async def token(
71+
async def get_oidc_token(
7072
# Autorest does not support the GrantType annotation
7173
# We need to specify each option with Literal[]
7274
grant_type: Annotated[
@@ -108,7 +110,7 @@ async def token(
108110
This is the endpoint being pulled by dirac-login when doing the device flow.
109111
"""
110112
try:
111-
access_payload, refresh_payload = await token_bl(
113+
access_payload, refresh_payload = await get_oidc_token_bl(
112114
grant_type,
113115
client_id,
114116
auth_db,
@@ -164,7 +166,7 @@ async def token(
164166

165167

166168
@router.get("/legacy-exchange", include_in_schema=False)
167-
async def legacy_exchange(
169+
async def perform_legacy_exchange(
168170
preferred_username: str,
169171
scope: str,
170172
authorization: Annotated[str, Header()],
@@ -207,7 +209,7 @@ async def legacy_exchange(
207209
)
208210

209211
try:
210-
access_payload, refresh_payload = await legacy_exchange_bl(
212+
access_payload, refresh_payload = await perform_legacy_exchange_bl(
211213
expected_api_key=expected_api_key,
212214
preferred_username=preferred_username,
213215
scope=scope,

diracx-routers/src/diracx/routers/auth/well_known.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
from diracx.core.models import Metadata, OpenIDConfiguration
66
from diracx.core.settings import AuthSettings
77
from diracx.logic.auth.well_known import (
8-
installation_metadata as installation_metadata_bl,
8+
get_installation_metadata as get_installation_metadata_bl,
99
)
1010
from diracx.logic.auth.well_known import (
11-
openid_configuration as openid_configuration_bl,
11+
get_openid_configuration as get_openid_configuration_bl,
1212
)
1313

1414
from ..dependencies import Config, DevelopmentSettings
@@ -18,13 +18,13 @@
1818

1919

2020
@router.get("/openid-configuration")
21-
async def openid_configuration(
21+
async def get_openid_configuration(
2222
request: Request,
2323
config: Config,
2424
settings: AuthSettings,
2525
) -> OpenIDConfiguration:
2626
"""OpenID Connect discovery endpoint."""
27-
return await openid_configuration_bl(
27+
return await get_openid_configuration_bl(
2828
request.url_for("token"),
2929
request.url_for("userinfo"),
3030
request.url_for("authorize"),
@@ -35,9 +35,9 @@ async def openid_configuration(
3535

3636

3737
@router.get("/dirac-metadata")
38-
async def installation_metadata(
38+
async def get_installation_metadata(
3939
config: Config,
4040
dev_settings: DevelopmentSettings,
4141
) -> Metadata:
4242
"""Get metadata about the dirac installation."""
43-
return await installation_metadata_bl(config, dev_settings)
43+
return await get_installation_metadata_bl(config, dev_settings)

docs/SERVICES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Usage example:
6161

6262
```python
6363
@router.get("/openid-configuration")
64-
async def openid_configuration(settings: AuthSettings):
64+
async def get_openid_configuration(settings: AuthSettings):
6565
...
6666
```
6767

0 commit comments

Comments
 (0)