Skip to content

Commit f90dbae

Browse files
Merge pull request #571 from RCOSDP/feature/R-2024-AUTH01-RCOS-RP
R-2024-AUTH01-49411,49412
2 parents 55fc0a2 + d9e76ef commit f90dbae

File tree

3 files changed

+213
-101
lines changed

3 files changed

+213
-101
lines changed

api/institutions/authentication.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@
3434
CAS_SERVER_URL,
3535
OSF_MFA_URL,
3636
OSF_IAL2_STR,
37+
OSF_AAL1_STR,
3738
OSF_AAL2_STR,
39+
OSF_IAL2_VAR,
40+
OSF_AAL1_VAR,
41+
OSF_AAL2_VAR,
3842
)
3943
from website.util.quota import update_default_storage
4044

@@ -179,10 +183,19 @@ def get_next(obj, *args):
179183
organization_name_ja = get_next(p_user, 'jao', 'jaOrganizationName')
180184
# affiliation: 'jaou' is friendlyName
181185
organizational_unit_ja = get_next(p_user, 'jaou', 'jaOrganizationalUnitName')
182-
# @R2022-48 ial
183-
ial = p_user.get('eduPersonAssurance')
184-
# @R2022-48 aal
185-
aal = p_user.get('Shib-AuthnContext-Class')
186+
# @R2022-48 ial,aal
187+
ial = None
188+
aal = None
189+
# @R-2024-AUTH01 eduPersonAssurance(multi value)
190+
eduPersonAssurance = p_user.get('eduPersonAssurance')
191+
if re.search(OSF_IAL2_STR, str(eduPersonAssurance)):
192+
ial = OSF_IAL2_VAR
193+
if re.search(OSF_AAL2_STR, str(eduPersonAssurance)):
194+
aal = OSF_AAL2_VAR
195+
elif re.search(OSF_AAL1_STR, str(eduPersonAssurance)):
196+
aal = OSF_AAL1_VAR
197+
else:
198+
aal = p_user.get('Shib-AuthnContext-Class')
186199

187200
# @R2022-48 loa + R-2023-55
188201
message = ''
@@ -207,7 +220,6 @@ def get_next(obj, *args):
207220
if not re.search(OSF_AAL2_STR, str(aal)):
208221
self.context['mfa_url'] = mfa_url
209222
elif loa.aal == 1:
210-
# if not re.search('https://www.gakunin.jp/profile/AAL1', aal):
211223
if not aal:
212224
message = (
213225
'Institution login failed: Does not meet the required AAL.<br />Please contact the IdP as the'
@@ -222,7 +234,6 @@ def get_next(obj, *args):
222234
)
223235
loa_flag = False
224236
elif loa.ial == 1:
225-
# if not re.search('https://www.gakunin.jp/profile/IAL1', ial):
226237
if not ial:
227238
message = (
228239
'Institution login failed: Does not meet the required IAL.<br />Please check the IAL of your'

website/profile/utils.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ def serialize_user(user, node=None, admin=False, full=False, is_profile=False, i
4141
_aal = 'AAL2'
4242
else:
4343
_aal = 'AAL1'
44-
if not user.ial:
45-
_ial = 'NULL'
46-
elif re.search(settings.OSF_IAL2_STR, str(user.ial)):
44+
# @R-2024-AUTH01 Values other than IAL2 are equivalent to IAL1.
45+
# if not user.ial:
46+
# _ial = 'NULL'
47+
if re.search(settings.OSF_IAL2_STR, str(user.ial)):
4748
_ial = 'IAL2'
4849
else:
4950
_ial = 'IAL1'
@@ -102,9 +103,11 @@ def serialize_user(user, node=None, admin=False, full=False, is_profile=False, i
102103
contrib = None
103104
is_contributor_obj = isinstance(contrib, Contributor)
104105
flags = {
105-
'visible': contrib.visible
106-
if is_contributor_obj
107-
else node.contributor_set.filter(user=user, visible=True).exists(),
106+
'visible': (
107+
contrib.visible
108+
if is_contributor_obj
109+
else node.contributor_set.filter(user=user, visible=True).exists()
110+
),
108111
'permission': contrib.permission if is_contributor_obj else None,
109112
}
110113
ret.update(flags)

0 commit comments

Comments
 (0)