OpenAM can act as both SP and IdP for SAML webSSO flows. OpenAM also provides ability to dynamically create user profiles.
When OpenAM is acting as SAML SP and Dynamic user profile is enabled, if user profile doesn’t exist on OpenAM then OpenAM dynamically creates this profile from attributes in SAML assertion.
The problem comes if user profile is updated at IdP side, all subsequent SAML webSSO flows doesn’t update these changes at OpenAM SP side. More details here: OPENAM-8340
Versions used for this implementation: OpenAM 13.5, OpenDJ 3.5
One of the solution can include extending OpenAM SP Attribute Mapper. This extension may include just checking if user profile exists in OpenAM SP and updating any modified or new attributes in OpenAM datastore. Some tips for this implementation:
- Extend DefaultSPAttributeMapper and override getAttributes()
- Get datastore provider from SAML2Utils.getDataStoreProvider()
- Check if user exists: dataStoreProvider.isUserExists(userID)
- Get existing user attributes: dataStoreProvider.getAttributes()
- Compare attributes in SAML assertion with existing user attributes.
- Finally persist any new and updated attributes: dataStoreProvider.setAttributes()
- Compile and deploy this extension in OpenAM under (OpenAM-Tomcat)/webapps/openam/WEB-INF/lib
- Change SAML attribute setting in OpenAM. Navigate to Federation > Entity Providers > (SP Hosted Entity) > Assertion Processing. Specify ‘org.forgerock.openam.saml2.plugins.examples.UpdateDynamicUserSPAttMapper’ under Attribute Mapper.
- Restart OpenAM
- And we are good to go! Any changes in user profile attributes in SAML assertion will now be persisted in OpenAM datastore.
Note that ideally attributes between different sources should be synced by using some tool like OpenIDM
Get code: https://github.com/CharanMann/OpenAM-SAMLSP-updateDynamicUser
OpenAM User Profile settings: https://backstage.forgerock.com/docs/openam/13.5/admin-guide#auth-core-realm-attributes
OpenAM SAML configuration: https://backstage.forgerock.com/docs/openam/13.5/admin-guide#chap-federation
This blog post was first published @ theinfinitelooper.blogspot.com, included here with permission.