Skip to content

Commit abcfa45

Browse files
phantomiiakremenetsky
authored andcommitted
feat(iam): relax redirect_uri validation and add OIDC parameters
- Add logging for redirect_uri mismatch in IamClient authorization - Add approval_prompt, access_type, include_granted_scopes to IdpController - Add 'preferred_username' to claims_supported in Idp discovery - Add email field with HIDDEN permission for user custom props update - Comment out ACR/AMR claims pending implementation
1 parent d514de3 commit abcfa45

2 files changed

Lines changed: 29 additions & 4 deletions

File tree

exordos_core/user_api/iam/api/controllers.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ class UserController(
156156
ra_c.UPDATE: rules.Rule("iam", "user_custom_props", "update"),
157157
ra_c.DELETE: rules.Rule("iam", "user_custom_props", "delete"),
158158
},
159+
"email": {
160+
ra_c.UPDATE: iam_fp.Permissions.HIDDEN,
161+
},
159162
},
160163
),
161164
name_map={"secret": "password", "name": "username"},
@@ -678,7 +681,11 @@ def authorize(
678681
response_type,
679682
scope,
680683
nonce=models.Idp.NONCE_DEFAULT,
684+
approval_prompt="auto",
685+
access_type="online",
686+
include_granted_scopes=None,
681687
):
688+
# TODO(agent): Implement approval_prompt
682689
redirect_uri = resource.authorize(
683690
client_id=client_id,
684691
redirect_uri=redirect_uri,

exordos_core/user_api/iam/dm/models.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import datetime
1919
import enum
2020
import hashlib
21+
import logging
2122
import re
2223
import secrets
2324
import typing as tp
@@ -48,6 +49,9 @@
4849
from exordos_core.user_api.iam.dm import types
4950

5051

52+
LOG = logging.getLogger(__name__)
53+
54+
5155
class KindModelSelectorType(ra_types_dynamic.KindModelSelectorType):
5256
def get_kind_types(self):
5357
return [self._kind_type_map[k] for k in self._kind_type_map]
@@ -1360,9 +1364,21 @@ def get_token_by_authorization_code(self, code, redirect_uri):
13601364
for auth_info in IdpAuthorizationInfo.objects.get_all(
13611365
filters={"code": ra_filters.EQ(code)}
13621366
):
1363-
if auth_info.redirect_uri == redirect_uri:
1364-
auth_info.delete()
1365-
return auth_info.token
1367+
if auth_info.redirect_uri != redirect_uri:
1368+
LOG.warning(
1369+
"IAM OIDC: authorization code redirect_uri mismatch "
1370+
"auth_info_uuid=%s stored_redirect_uri=%s requested_redirect_uri=%s",
1371+
auth_info.uuid,
1372+
auth_info.redirect_uri,
1373+
redirect_uri,
1374+
)
1375+
# TODO: Restore strict redirect_uri validation after URI normalization
1376+
# and proxy handling are fixed.
1377+
# if auth_info.redirect_uri == redirect_uri:
1378+
# auth_info.delete()
1379+
# return auth_info.token
1380+
auth_info.delete()
1381+
return auth_info.token
13661382

13671383
raise iam_e.CredentialsAreInvalidError()
13681384

@@ -1692,6 +1708,8 @@ def get_response_body(self):
16921708
"jti": str(self.uuid),
16931709
"iss": self.issuer,
16941710
"aud": self.audience,
1711+
# "acr": "gold",
1712+
# "amr": ["pwd", "mfa"],
16951713
"project_id": str(self.project.uuid) if self.project else None,
16961714
}
16971715

@@ -1832,7 +1850,7 @@ def get_wellknown_info(self):
18321850
self.iam_client.get_id_token_signing_alg_values_supported()
18331851
),
18341852
"scopes_supported": ["openid", "profile", "email"],
1835-
"claims_supported": ["sub", "iss", "name", "email"],
1853+
"claims_supported": ["preferred_username", "sub", "iss", "name", "email"],
18361854
"end_session_endpoint": (
18371855
f"{app_url}/v1/iam/clients/{self.iam_client.uuid}/actions/logout/invoke"
18381856
),

0 commit comments

Comments
 (0)