@@ -247,6 +247,9 @@ onelogin.saml2.sp.x509certNew =
247247# If you have PKCS#1 BEGIN RSA PRIVATE KEY convert it by openssl pkcs8 -topk8 -inform pem -nocrypt -in sp.rsa_key -outform pem -out sp.pem
248248onelogin.saml2.sp.privatekey =
249249
250+ # Attribute Consuming Services
251+ # SEE BELOW
252+
250253# # Identity Provider Data that we want connect with our SP ##
251254
252255# Identifier of the IdP entity (must be a URI)
@@ -492,9 +495,88 @@ The getSPMetadata will return the metadata signed or not based on the security p
492495
493496Before the XML metadata is exposed, a check takes place to ensure that the info to be provided is valid.
494497
495- ##### Attribute Consumer Service(ACS)
496- This code handles the SAML response that the IdP forwards to the SP through the user's client.
498+ ##### Attribute Consuming Service (ACS)
499+ The SP may optionally specify one or more Attribute Consuming Services in its metadata. These can be configured in the settings.
500+
501+ If just one ACS is required:
502+
503+ ``` properties
504+ # Attribute Consuming Service name when just one ACS should be declared by the SP.
505+ # Comment out or set to empty if no ACS should be declared, or if multiple ones should (see below).
506+ # The service name is mandatory.
507+ onelogin.saml2.sp.attribute_consuming_service.name = My service
508+
509+ # Attribute Consuming Service description when just one ACS should be declared by the SP.
510+ # Ignored if the previous property is commented or empty.
511+ # The service description is optional.
512+ onelogin.saml2.sp.attribute_consuming_service.description = My service description
513+
514+ # Language used for Attribute Consuming Service name and description when just one ACS should be declared by the SP.
515+ # Ignored if the name property is commented or empty.
516+ # The language is optional and default to "en" (English).
517+ onelogin.saml2.sp.attribute_consuming_service.lang = en
518+
519+ # Requested attributes to be included in the Attribute Consuming Service when just one ACS should be declared by the SP.
520+ # At least one requested attribute must be specified, otherwise schema validation will fail.
521+ # Attribute properties are indexed properties, starting from 0. The index is used only to enumerate and sort attributes, but it's required.
522+ # The following properties allow to define each requested attribute:
523+ # - name: mandatory
524+ # - name_format: optional; if omitted, defaults to urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified
525+ # - friendly_name: optional; if omitted, it won't appear in SP metadata
526+ # - required: optional; if omitted or empty, defaults to false
527+ # - value[x]: an attribute value; the [x] is only used only to enumerate and sort values, but it's required
528+ # Please note that only simple values are currently supported and treated internally as strings. Hence no structured values
529+ # and no ability to specify an xsi:type attribute.
530+ # Attribute values are optional and most often they are simply omitted.
531+ onelogin.saml2.sp.attribute_consuming_service.attribute[0].name = Email
532+ onelogin.saml2.sp.attribute_consuming_service.attribute[0].name_format = urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress
533+ onelogin.saml2.sp.attribute_consuming_service.attribute[0].friendly_name = E-mail address
534+ onelogin.saml2.sp.attribute_consuming_service.attribute[0].required = true
535+ onelogin.saml2.sp.attribute_consuming_service.attribute[0].value[0] = foo@example.org
536+ onelogin.saml2.sp.attribute_consuming_service.attribute[0].value[1] = bar@example.org
537+ ```
538+
539+ If multiple ACSs are required, they can be specified in a similar way, but using indexes: these indexes are used to enumerate and
540+ identify attribute consuming services within the SP metadata and can be subsequently used in the auth process to specify which
541+ attribute set should be requested to the IdP. The "default" property can also be set to designate the default ACS. Here is an example:
542+
543+ ``` properties
544+ onelogin.saml2.sp.attribute_consuming_service[0].name = Just e-mail
545+ onelogin.saml2.sp.attribute_consuming_service[0].attribute[0].name = Email
546+ onelogin.saml2.sp.attribute_consuming_service[0].attribute[0].name_format = urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress
547+ onelogin.saml2.sp.attribute_consuming_service[0].attribute[0].friendly_name = E-mail address
548+ onelogin.saml2.sp.attribute_consuming_service[0].attribute[0].required = true
549+ onelogin.saml2.sp.attribute_consuming_service[0].attribute[0].value[0] = foo@example.org
550+ onelogin.saml2.sp.attribute_consuming_service[0].attribute[0].value[1] = bar@example.org
551+ onelogin.saml2.sp.attribute_consuming_service[1].name = Anagrafica
552+ onelogin.saml2.sp.attribute_consuming_service[1].description = Set completo
553+ onelogin.saml2.sp.attribute_consuming_service[1].lang = it
554+ onelogin.saml2.sp.attribute_consuming_service[1].default = true
555+ onelogin.saml2.sp.attribute_consuming_service[1].attribute[0].name = FirstName
556+ onelogin.saml2.sp.attribute_consuming_service[1].attribute[1].name = LastName
557+ onelogin.saml2.sp.attribute_consuming_service[1].attribute[1].required = true
558+ ```
559+
560+ Please note that if you specify (multiple) indexed Attribute Consuming Services, the non-indexed properties will be ignored.
561+
562+ As said, to request a specific attribute set when initiating SSO, a selection mechanism is available:
563+
564+ ``` java
565+ import static com.onelogin.saml2.authn.AttributeConsumingServiceSelector.* ;
566+ Auth auth = new Auth (request, response);
567+ // select by index 1
568+ auth. login(new AuthnRequestParams (false , false , true , byIndex(1 ));
569+ // or select by ACS name
570+ auth. login(new AuthnRequestParams (false , false , true , byServiceName(auth. getSettings(), " Anagrafica" ));
571+ // or see AttributeConsumingServiceSelector interface implementations for more options
497572```
573+
574+ If no selector is specified, `AttributeConsumingServiceSelector . useDefault()` will be used, which will simply omit any
575+ `AttributeConsumingServiceIndex ` from the request, hence leaving the IdP choose the default attribute set agreed upon.
576+
577+ Then , the following code handles the SAML response that the IdP forwards to the SP through the user' s client:
578+
579+ ```java
498580Auth auth = new Auth(request, response);
499581auth.processResponse();
500582if (!auth.isAuthenticated()) {
0 commit comments