@@ -275,6 +275,9 @@ onelogin.saml2.contacts.technical.email_address = technical@example.com
275275onelogin.saml2.contacts.support.given_name = Support Guy
276276onelogin.saml2.contacts.support.email_address = support@example.com
277277
278+ # Attribute Consuming Services
279+ # SEE BELOW
280+
278281# # Identity Provider Data that we want connect with our SP ##
279282
280283# Identifier of the IdP entity (must be a URI)
@@ -510,8 +513,87 @@ The getSPMetadata will return the metadata signed or not based on the security p
510513
511514Before the XML metadata is exposed, a check takes place to ensure that the info to be provided is valid.
512515
513- ##### Attribute Consumer Service(ACS)
514- This code handles the SAML response that the IdP forwards to the SP through the user's client.
516+ ##### Attribute Consuming Service (ACS)
517+ The SP may optionally specify one or more Attribute Consuming Services in its metadata. These can be configured in the settings.
518+
519+ If just one ACS is required:
520+
521+ ``` properties
522+ # Attribute Consuming Service name when just one ACS should be declared by the SP.
523+ # Comment out or set to empty if no ACS should be declared, or if multiple ones should (see below).
524+ # The service name is mandatory.
525+ onelogin.saml2.sp.attribute_consuming_service.name = My service
526+
527+ # Attribute Consuming Service description when just one ACS should be declared by the SP.
528+ # Ignored if the previous property is commented or empty.
529+ # The service description is optional.
530+ onelogin.saml2.sp.attribute_consuming_service.description = My service description
531+
532+ # Language used for Attribute Consuming Service name and description when just one ACS should be declared by the SP.
533+ # Ignored if the name property is commented or empty.
534+ # The language is optional and default to "en" (English).
535+ onelogin.saml2.sp.attribute_consuming_service.lang = en
536+
537+ # Requested attributes to be included in the Attribute Consuming Service when just one ACS should be declared by the SP.
538+ # At least one requested attribute must be specified, otherwise schema validation will fail.
539+ # Attribute properties are indexed properties, starting from 0. The index is used only to enumerate and sort attributes, but it's required.
540+ # The following properties allow to define each requested attribute:
541+ # - name: mandatory
542+ # - name_format: optional; if omitted, defaults to urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified
543+ # - friendly_name: optional; if omitted, it won't appear in SP metadata
544+ # - required: optional; if omitted or empty, defaults to false
545+ # - value[x]: an attribute value; the [x] is only used only to enumerate and sort values, but it's required
546+ # Please note that only simple values are currently supported and treated internally as strings. Hence no structured values
547+ # and no ability to specify an xsi:type attribute.
548+ # Attribute values are optional and most often they are simply omitted.
549+ onelogin.saml2.sp.attribute_consuming_service.attribute[0].name = Email
550+ onelogin.saml2.sp.attribute_consuming_service.attribute[0].name_format = urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress
551+ onelogin.saml2.sp.attribute_consuming_service.attribute[0].friendly_name = E-mail address
552+ onelogin.saml2.sp.attribute_consuming_service.attribute[0].required = true
553+ onelogin.saml2.sp.attribute_consuming_service.attribute[0].value[0] = foo@example.org
554+ onelogin.saml2.sp.attribute_consuming_service.attribute[0].value[1] = bar@example.org
555+ ```
556+
557+ If multiple ACSs are required, they can be specified in a similar way, but using indexes: these indexes are used to enumerate and
558+ identify attribute consuming services within the SP metadata and can be subsequently used in the auth process to specify which
559+ attribute set should be requested to the IdP. The "default" property can also be set to designate the default ACS. Here is an example:
560+
561+ ``` properties
562+ onelogin.saml2.sp.attribute_consuming_service[0].name = Just e-mail
563+ onelogin.saml2.sp.attribute_consuming_service[0].attribute[0].name = Email
564+ onelogin.saml2.sp.attribute_consuming_service[0].attribute[0].name_format = urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress
565+ onelogin.saml2.sp.attribute_consuming_service[0].attribute[0].friendly_name = E-mail address
566+ onelogin.saml2.sp.attribute_consuming_service[0].attribute[0].required = true
567+ onelogin.saml2.sp.attribute_consuming_service[0].attribute[0].value[0] = foo@example.org
568+ onelogin.saml2.sp.attribute_consuming_service[0].attribute[0].value[1] = bar@example.org
569+ onelogin.saml2.sp.attribute_consuming_service[1].name = Anagrafica
570+ onelogin.saml2.sp.attribute_consuming_service[1].description = Set completo
571+ onelogin.saml2.sp.attribute_consuming_service[1].lang = it
572+ onelogin.saml2.sp.attribute_consuming_service[1].default = true
573+ onelogin.saml2.sp.attribute_consuming_service[1].attribute[0].name = FirstName
574+ onelogin.saml2.sp.attribute_consuming_service[1].attribute[1].name = LastName
575+ onelogin.saml2.sp.attribute_consuming_service[1].attribute[1].required = true
576+ ```
577+
578+ Please note that if you specify (multiple) indexed Attribute Consuming Services, the non-indexed properties will be ignored.
579+
580+ As said, to request a specific attribute set when initiating SSO, a selection mechanism is available:
581+
582+ ``` java
583+ import static com.onelogin.saml2.authn.AttributeConsumingServiceSelector.* ;
584+ Auth auth = new Auth (request, response);
585+ // select by index 1
586+ auth. login(new AuthnRequestParams (false , false , true , byIndex(1 ));
587+ // or select by ACS name
588+ auth. login(new AuthnRequestParams (false , false , true , byServiceName(auth. getSettings(), " Anagrafica" ));
589+ // or see AttributeConsumingServiceSelector interface implementations for more options
590+ ```
591+
592+ If no selector is specified, `AttributeConsumingServiceSelector . useDefault()` will be used, which will simply omit any
593+ `AttributeConsumingServiceIndex ` from the request, hence leaving the IdP choose the default attribute set agreed upon.
594+
595+ Then , the following code handles the SAML response that the IdP forwards to the SP through the user' s client:
596+
515597```java
516598Auth auth = new Auth(request, response);
517599auth.processResponse();
0 commit comments