Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Add] Limited support for <Scoping> in SAML2 #219

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ This is the settings.json file:
// represent the requested subject.
// Take a look on src/onelogin/saml2/constants.py to see the NameIdFormat that are supported.
"NameIDFormat": "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified",
// List of IdPs (entityIds) allowed to authenticate the request (SAML2 Scoping)
"scopingIdpList": ["https://<idp_domain>"],
// Usually x509cert and privateKey of the SP are provided by files placed at
// the certs folder. But we can also provide them with the following parameters
"x509cert": "",
Expand Down
18 changes: 16 additions & 2 deletions src/onelogin/saml2/authn_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,19 @@ def __init__(self, settings, force_authn=False, is_passive=False, set_nameid_pol
if 'attributeConsumingService' in sp_data and sp_data['attributeConsumingService']:
attr_consuming_service_str = 'AttributeConsumingServiceIndex="1"'

scoping_str = ''
if 'scopingIdpList' in sp_data:
scoping_idp_str = ''
for idp in sp_data['scopingIdpList']:
scoping_idp_str += ' <samlp:IDPEntry ProviderID="%s" />' % idp

scoping_str = '''\
<samlp:Scoping>
<samlp:IDPList>
%s
</samlp:IDPList>
</samlp:Scoping>''' % scoping_idp_str

request = """<samlp:AuthnRequest
xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
Expand All @@ -110,7 +123,7 @@ def __init__(self, settings, force_authn=False, is_passive=False, set_nameid_pol
ProtocolBinding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
AssertionConsumerServiceURL="%(assertion_url)s"
%(attr_consuming_service_str)s>
<saml:Issuer>%(entity_id)s</saml:Issuer>%(nameid_policy_str)s%(requested_authn_context_str)s
<saml:Issuer>%(entity_id)s</saml:Issuer>%(nameid_policy_str)s%(requested_authn_context_str)s%(scoping_str)s
</samlp:AuthnRequest>""" % \
{
'id': uid,
Expand All @@ -123,7 +136,8 @@ def __init__(self, settings, force_authn=False, is_passive=False, set_nameid_pol
'entity_id': sp_data['entityId'],
'nameid_policy_str': nameid_policy_str,
'requested_authn_context_str': requested_authn_context_str,
'attr_consuming_service_str': attr_consuming_service_str
'attr_consuming_service_str': attr_consuming_service_str,
'scoping_str': scoping_str
}

self.__authn_request = request
Expand Down