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

Attribute consuming service index #241

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,11 @@ This is the ``settings.json`` file:
// attributeConsumingService. nameFormat, attributeValue and
// friendlyName can be ommited
"attributeConsumingService": {
// OPTIONAL: only specifiy if SP requires this.
// index is an integer which identifies the attributeConsumingService used
// to the SP. OneLogin toolkit supports configuring only one attributeConsumingService
// but in certain cases the SP requires a different value. Defaults to '1'.
// "index": '1',
"serviceName": "SP test",
"serviceDescription": "Test Service",
"requestedAttributes": [
Expand Down
2 changes: 1 addition & 1 deletion src/onelogin/saml2/authn_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def __init__(self, settings, force_authn=False, is_passive=False, set_nameid_pol

attr_consuming_service_str = ''
if 'attributeConsumingService' in sp_data and sp_data['attributeConsumingService']:
attr_consuming_service_str = "\n AttributeConsumingServiceIndex=\"1\""
attr_consuming_service_str = "\n AttributeConsumingServiceIndex=\"%s\"" % sp_data['attributeConsumingService'].get('index', '1')

request = OneLogin_Saml2_Templates.AUTHN_REQUEST % \
{
Expand Down
3 changes: 2 additions & 1 deletion src/onelogin/saml2/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,15 @@ def builder(cls, sp, authnsign=False, wsign=False, valid_until=None, cache_durat

requested_attribute_data.append(requested_attribute)

str_attribute_consuming_service = """ <md:AttributeConsumingService index="1">
str_attribute_consuming_service = """ <md:AttributeConsumingService index="%(attribute_consuming_service_index)s">
<md:ServiceName xml:lang="en">%(service_name)s</md:ServiceName>
%(attr_cs_desc)s%(requested_attribute_str)s
</md:AttributeConsumingService>
""" % \
{
'service_name': sp['attributeConsumingService']['serviceName'],
'attr_cs_desc': attr_cs_desc_str,
'attribute_consuming_service_index': sp['attributeConsumingService'].get('index', '1'),
'requested_attribute_str': '\n'.join(requested_attribute_data)
}

Expand Down