Set up user profile self service
The Ping SDKs support many of the callbacks used by authentication journeys, including ones that enable your users to manage their own profile information, such as name, address, phone numbers and marketing preferences.
To update a user’s profile information you must have already authenticated them and issued a session token. You can then use that session token to start a new journey which allows the user to update their profile data.
Compatibility
PingIDM is responsible for profile management. Therefore this tutorial is only compatible with the following server environments:
-
PingOne Advanced Identity Cloud
-
PingAM and PingIDM deployed together as the Ping Identity Platform (ForgeRock Identity Platform)
-
PingAM and PingIDM deployed together by using ForgeRock DevOps (ForgeOps)
Before you begin
You must create an authentication journey that checks for the presence of a user session and then displays the user profile fields for editing. The journey must also update the profile with any changed values.
Create a user profile management journey
Follow the steps below to create a user profile management journey:
-
Create a new journey or tree and give it a name:
PingOne Advanced Identity Cloud
-
In your PingOne Advanced Identity Cloud tenant, navigate to Journeys, and click New Journey.
-
Enter a name, such as
sdkProfileManagement
and click Save.The authentication journey designer appears.
PingAM
-
Under Realm Overview, click Authentication Trees, then click Create Tree.
-
Enter a tree name, for example
sdkProfileManagement
, and then click Create.The authentication tree designer appears, showing the Start entry point connected to the Failure exit point.
-
-
Drag the following nodes into the designer area:
-
Get Session Data
-
Attribute Collector
-
Patch Object
-
Data Store Decision
-
-
Connect the nodes as follows:
Figure 1. Example profile management authentication journey -
Select the Get Session Data node and configure it to obtain the user’s account name from the session and store it in shared state, as follows:
-
In Session Data Key, enter
UserToken
.This field is case-sensitive. The value must exactly match the name of a property in the user’s session.
For a list of properties, refer to Get Session Data node.
-
In Shared State Key, enter
userName
.
The result resembles the following:
Figure 2. Configure the Get Session Data node for profile management. -
-
Select the Attribute Collector node and configure it with the profile attributes you want the user to view and edit:
-
In Attributes to Collect, enter the profile attributes to display. For example:
-
givenName
-
sn
-
mail
-
telephoneNumber
-
postalAddress
-
city
-
country
-
preferences/marketing
-
-
In Identity Attribute, enter
userName
.
The result resembles the following:
Figure 3. Configure the Attribute Collector node for profile management. -
-
Select the Patch Object node and configure it to update the user’s profile:
-
In Identity Resource, enter
managed/alpha_user
. -
In Identity Attribute, enter
userName
.
The result resembles the following:
Figure 4. Configure the Patch Object node for profile management. -
-
Click Save.
Server configuration
This tutorial requires you to configure one of the following servers:
PingOne Advanced Identity Cloud
Task 1. Create a demo user
The samples and tutorials in this documentation often require that you have an identity set up so that you can test authentication.
To create a demo user in PingOne Advanced Identity Cloud, follow these steps:
-
Log in to your PingOne Advanced Identity Cloud tenant.
-
In the left panel, click Identities > Manage.
-
Click New Alpha realm - User.
-
Enter the following details:
-
Username =
demo
-
First Name =
Demo
-
Last Name =
User
-
Email Address =
demo.user@example.com
-
Password =
Ch4ng3it!
-
-
Click Save.
Task 2. Create an authentication journey
Authentication journeys provide fine-grained authentication by allowing multiple paths and decision points throughout the flow. Authentication journeys are made up of nodes that define actions taken during authentication.
Each node performs a single task, such as collecting a username or making a simple decision. Nodes can have multiple outcomes rather than just success or failure. For details, see the Authentication nodes configuration reference in the PingAM documentation.
To create a simple journey for use when testing the Ping SDKs, follow these steps:
-
In your PingOne Advanced Identity Cloud tenant, navigate to Journeys, and click New Journey.
-
Enter a name, such as
sdkUsernamePasswordJourney
and click Save.The authentication journey designer appears.
-
Drag the following nodes into the designer area:
-
Page Node
-
Platform Username
-
Platform Password
-
Data Store Decision
-
-
Drag and drop the Platform Username and Platform Password nodes onto the Page Node, so that they both appear on the same page when logging in.
-
Connect the nodes as follows:
Figure 5. Example username and password authentication journey -
Click Save.
Task 3. Register a public OAuth 2.0 client
Public clients do not use a client secret to obtain tokens because they are unable to keep them hidden. The Ping SDKs commonly use this type of client to obtain tokens, as they cannot guarantee safekeeping of the client credentials in a browser or on a mobile device.
To register a public OAuth 2.0 client application for use with the SDKs in PingOne Advanced Identity Cloud, follow these steps:
-
Log in to your PingOne Advanced Identity Cloud tenant.
-
In the left panel, click Applications.
-
Click Custom Application.
-
Select OIDC - OpenId Connect as the sign-in method, and then click Next.
-
Select Native / SPA as the application type, and then click Next.
-
In Name, enter a name for the application, such as
Public SDK Client
. -
In Owners, select a user that is responsible for maintaining the application, and then click Next.
When trying out the SDKs, you could select the demo
user you created previously. -
In Client ID, enter
sdkPublicClient
, and then click Create Application.PingOne Advanced Identity Cloud creates the application and displays the details screen.
-
On the Sign On tab:
-
In Sign-In URLs, enter the following values:
org.forgerock.demo://oauth2redirect
Also add any other domains where you host SDK applications. -
In Grant Types, enter the following values:
Authorization Code
Refresh Token
-
In Scopes, enter the following values:
openid profile email address
-
-
Click Show advanced settings, and on the Authentication tab:
-
In Token Endpoint Authentication Method, select
none
. -
In Client Type, select
Public
. -
Enable the Implied Consent property.
-
-
Click Save.
The application is now configured to accept client connections from and issue OAuth 2.0 tokens to the example applications and tutorials covered by this documentation.
Task 4. Configure the OAuth 2.0 provider service
The provider specifies the supported OAuth 2.0 configuration options for a realm.
To ensure the PingOne Advanced Identity Cloud OAuth 2.0 provider service is configured for use with the Ping SDKs, follow these steps:
-
In your PingOne Advanced Identity Cloud tenant, navigate to Native Consoles > Access Management.
-
In the left panel, click Services.
-
In the list of services, click OAuth2 Provider.
-
On the Core tab, ensure Issue Refresh Tokens is enabled.
-
On the Consent tab, ensure Allow Clients to Skip Consent is enabled.
-
Click Save Changes.
PingAM
Task 1. Create a demo user
The samples and tutorials in this documentation often require that you have an identity set up so that you can test authentication.
To create a demo user in PingAM, follow these steps:
-
Log in to the PingAM admin UI as an administrator.
-
Navigate to Identities, and then click Add Identity.
-
Enter the following details:
-
User ID =
demo
-
Password =
Ch4ng3it!
-
Email Address =
demo.user@example.com
-
-
Click Create.
Task 2. Create an authentication tree
Authentication trees provide fine-grained authentication by allowing multiple paths and decision points throughout the authentication flow. Authentication trees are made up of nodes that define actions taken during authentication.
Each node performs a single task, such as collecting a username or making a simple decision. Nodes can have multiple outcomes rather than just success or failure. For details, see the Authentication nodes configuration reference in the PingAM documentation.
To create a simple tree for use when testing the Ping SDKs, follow these steps:
-
Under Realm Overview, click Authentication Trees, then click Create Tree.
-
Enter a tree name, for example
sdkUsernamePasswordJourney
, and then click Create.The authentication tree designer appears, showing the Start entry point connected to the Failure exit point.
-
Drag the following nodes from the Components panel on the left side into the designer area:
-
Page Node
-
Username Collector
-
Password Collector
-
Data Store Decision
-
-
Drag and drop the Username Collector and Password Collector nodes onto the Page Node, so that they both appear on the same page when logging in.
-
Connect the nodes as follows:
Figure 6. Example username and password authentication tree -
Select the Page Node, and in the Properties pane, set the Stage property to
UsernamePassword
.You can configure the node properties by selecting a node and altering properties in the right-hand panel. One of the samples uses this specific value to determine the custom UI to display.
-
Click Save.
Task 3. Register a public OAuth 2.0 client
Public clients do not use a client secret to obtain tokens because they are unable to keep them hidden. The Ping SDKs commonly use this type of client to obtain tokens, as they cannot guarantee safekeeping of the client credentials in a browser or on a mobile device.
To register a public OAuth 2.0 client application for use with the SDKs in AM, follow these steps:
-
Log in to the PingAM admin UI as an administrator.
-
Navigate to Applications > OAuth 2.0 > Clients, and then click Add Client.
-
In Client ID, enter
sdkPublicClient
. -
Leave Client secret empty.
-
In Redirection URIs, enter the following values:
org.forgerock.demo://oauth2redirect
Also add any other domains where you will be hosting SDK applications. -
In Scopes, enter the following values:
openid profile email address
-
Click Create.
PingAM creates the new OAuth 2.0 client, and displays the properties for further configuration.
-
On the Core tab:
-
In Client type, select
Public
. -
Disable Allow wildcard ports in redirect URIs.
-
Click Save Changes.
-
-
On the Advanced tab:
-
In Grant Types, enter the following values:
Authorization Code Refresh Token
-
In Token Endpoint Authentication Method, select
None
. -
Enable the Implied consent property.
-
-
Click Save Changes.
Task 4. Configure the OAuth 2.0 provider service
The provider specifies the supported OAuth 2.0 configuration options for a realm.
To ensure the PingAM OAuth 2.0 provider service is configured for use with the Ping SDKs, follow these steps:
-
Log in to the PingAM admin UI as an administrator.
-
In the left panel, click Services.
-
In the list of services, click OAuth2 Provider.
-
On the Core tab, ensure Issue Refresh Tokens is enabled.
-
On the Consent tab, ensure Allow Clients to Skip Consent is enabled.
-
Click Save Changes.
Try it out
Follow the steps below to configure and run one of our sample applications to test profile self-management.
Step 1. Download the sample apps
To start this tutorial, you need to download the Ping SDK sample apps repo, which contains the projects you will use.
-
In a web browser, navigate to the Ping SDK sample apps repository.
-
Download the source code using one of the following methods:
- Download a ZIP file
-
-
Click Code, and then click Download ZIP.
-
Extract the contents of the downloaded ZIP file to a suitable location.
-
- Use a Git-compatible tool to clone the repo locally
-
-
Click Code, and then copy the HTTPS URL.
-
Use the URL to clone the repository to a suitable location.
For example, from the command-line you could run:
-
The result of these steps is a local folder named sdk-sample-apps
.
Step 2. Configure sample apps
Depending on the platform you are using, follow the steps below to configure a sample application to connect to your server.
-
Android
-
iOS
In this step, you configure the "kotlin-ui-prototype" sample to connect to your server.
-
In Android Studio, open the
sdk-sample-apps/android/kotlin-ui-prototype
folder you cloned in the previous step. -
In the Project pane, switch to the Android view.
-
In the Android view, navigate to app > kotlin+java > com.example.app > env, and open
EnvViewModel.kt
.This file has the server environments the sample app uses. Each specifies the properties using the
FROptionsBuilder.build
method. -
Update the
PingAM
orPingAdvancedIdentityCloud
example configuration values to match your server environment:- url
-
The URL of the server to connect to.
Identity Cloud example:
https://openam-forgerock-sdks.forgeblocks.com/am
Self-hosted example:
https://openam.example.com:8443/openam
- cookieName
-
The name of the cookie that contains the session token.
For example, with a self-hosted PingAM server this value might be
iPlanetDirectoryPro
.PingOne Advanced Identity Cloud tenants use a random alpha-numeric string.
To locate the cookie name in an PingOne Advanced Identity Cloud tenant, navigate to Tenant settings > Global Settings, and copy the value of the Cookie property.
- realm
-
The realm in which the OAuth 2.0 client profile and authentication journeys are configured.
Usually,
root
for AM andalpha
orbeta
for Advanced Identity Cloud. - oauthClientId
-
The client ID of your OAuth 2.0 application in PingOne Advanced Identity Cloud or PingAM.
For example,
sdkPublicClient
- oauthRedirectUri
-
The
redirect_uri
as configured in the OAuth 2.0 client profile.This value must exactly match a value configured in your OAuth 2.0 client. For example,
org.forgerock.demo://oauth2redirect
.
-
Update the
USER_PROFILE_JOURNEY
variable with the name of the profile management journey you created earlier.For example,
sdkProfileManagement
-
Save your changes.
In this step, you configure the "FRExample" sample app to connect to your server.
-
In Xcode, on the File menu, click Open.
-
Navigate to the
sdk-sample-apps
folder you cloned in the previous step, navigate toiOS
>uikit-frexamples
>FRExample
>FRExample.xcodeproj
, and then click Open. -
In the navigator pane in Xcode, right-click
FRExample/Configs/FRAuthConfig
and select Open As > Source Code. -
Update the following key values to match your server environment:
- forgerock_url
-
The URL of the server to connect to.
Identity Cloud example:
https://openam-forgerock-sdks.forgeblocks.com/am
Self-hosted example:
https://openam.example.com:8443/openam
- forgerock_cookie_name
-
The name of the cookie that contains the session token.
For example, with a self-hosted PingAM server this value might be
iPlanetDirectoryPro
.PingOne Advanced Identity Cloud tenants use a random alpha-numeric string.
To locate the cookie name in an PingOne Advanced Identity Cloud tenant, navigate to Tenant settings > Global Settings, and copy the value of the Cookie property.
- forgerock_realm
-
The realm in which the OAuth 2.0 client profile and authentication journeys are configured.
Usually,
root
for AM andalpha
orbeta
for Advanced Identity Cloud. - forgerock_oauth_client_id
-
The client ID of your OAuth 2.0 application in PingOne Advanced Identity Cloud or PingAM.
For example,
sdkPublicClient
- forgerock_oauth_redirect_uri
-
The
redirect_uri
as configured in the OAuth 2.0 client profile.This value must exactly match a value configured in your OAuth 2.0 client. For example,
org.forgerock.demo://oauth2redirect
.
-
Save your changes.
Step 3. Run the sample app
Depending on the platform you are using, follow the steps below to run the sample application, obtain a session token, and use it to complete the self-registration journey you created earlier.
-
Android
-
iOS
-
In Android Studio, select Run > Run 'app'.
-
Tap the menu icon (), and then tap Launch Journey.
-
In Journey Name enter the name of a journey that will authenticate the user and issue a session, and then click Submit.
For example, enter
sdkUsernamePasswordJourney
to use the authentication tree you created earlier. -
Sign on as a demo user:
-
Name:
demo
-
Password:
Ch4ng3it!
-
-
After successful authentication, tap the menu icon (), and then tap User Profile.
The app sends the session token to the journey which extracts the username and returns their profile information:
Figure 7. Viewing a user’s profile information in an Android sample app. -
Update any of the presented properties and then click Next.
-
To verify the profile was updated, tap the menu icon (), and then tap User Profile.
The app displays the updated profile values.
-
In Xcode, select Product > Run.
Xcode launches the
FRExample
app in the iPhone simulator. -
In the sample app on the iPhone simulator, in the Select an action menu, select Login with UI (FRUser), and then click Perform Action.
-
Sign on as a demo user:
-
Name:
demo
-
Password:
Ch4ng3it!
-
-
After successful authentication, in the Select an action menu, select FRSession.authenticate with UI (Token), and then click Perform Action.
-
In the popup window, enter the name of the profile management journey you created earlier, and then click Continue.
For example,
sdkProfileManagement
-
Update any of the presented properties and then click Next.
The app sends the session token to the journey which extracts the username and returns their profile information:
Figure 8. Viewing a user’s profile information in an iOS sample app. -
Update any of the presented properties and then click Next.
-
To verify the profile was updated, tap Perform Action again, enter the name of your profile management tree and then click Continue.
The app displays the updated profile values.