Skip to content

Commit d5687a2

Browse files
committed
Adds configuration directive for RequestedAuthnContext #806
Closes #806
1 parent 4d2dcce commit d5687a2

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/saml2/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
"sp_type",
105105
"sp_type_in_metadata",
106106
"requested_attributes",
107+
"requested_authn_context",
107108
]
108109

109110
AA_IDP_ARGS = [

tests/test_31_config.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88
from saml2 import BINDING_HTTP_REDIRECT, BINDING_SOAP, BINDING_HTTP_POST
99
from saml2.config import SPConfig, IdPConfig, Config
10-
10+
from saml2.saml import AUTHN_PASSWORD_PROTECTED, AuthnContextClassRef
11+
from saml2.samlp import RequestedAuthnContext
1112
from saml2 import logger
1213

1314
from pathutils import dotname, full_path
@@ -26,8 +27,14 @@
2627
"urn:mace:example.com:saml:roland:idp": {
2728
'single_sign_on_service':
2829
{'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect':
29-
'http://localhost:8088/sso/'}},
30-
}
30+
'http://localhost:8088/sso/'}},
31+
},
32+
"requested_authn_context": RequestedAuthnContext(
33+
authn_context_class_ref=[
34+
AuthnContextClassRef(AUTHN_PASSWORD_PROTECTED),
35+
],
36+
comparison="exact",
37+
),
3138
}
3239
},
3340
"key_file": full_path("test.key"),
@@ -217,6 +224,12 @@ def test_1():
217224
'http://localhost:8088/sso/'}}]
218225

219226
assert c.only_use_keys_in_metadata
227+
assert c._sp_requested_authn_context.to_string().decode() == (
228+
'<ns0:RequestedAuthnContext xmlns:ns0="urn:oasis:names:tc:SAML:2.0:protocol" '
229+
'xmlns:ns1="urn:oasis:names:tc:SAML:2.0:assertion" Comparison="exact">'
230+
'<ns1:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:'
231+
'PasswordProtectedTransport</ns1:AuthnContextClassRef></ns0:RequestedAuthnContext>'
232+
)
220233

221234

222235
def test_2():

0 commit comments

Comments
 (0)