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