Use this application to configure your an OIDC application that illustrates purpose-aware OAuth scopes and native purpose-aware consent. The application is built with Node.js, the Verify OAuth SDK and the Verify Privacy SDK. All UI assets can be found under views and public. All views are written using vanilla HTML and JS and templated using Handlebars.
This application uses IBM Security Verify as the identity provider to illustrate the capabilities.
In this app, you can do the following -
- Authenticating the client using IBM Security Verify with one or more purpose-aware scopes
- Viewing the authenticated user's profile by unpacking the id_token
- Simulating a shopping cart consent experience, where the user's email and address is requested as part of the checkout process for the purpose of shipping purchases.
- Install Node and Git on your machine
- Create a tenant on IBM Security Verify
- Clone this repo to your machine
-
Login to IBM Security Verify admin console (https://yourtenant.verify.ibm.com/ui/admin) using admin
-
Go to
Configuration > Attributes
-
Add a new custom attribute with the ID
home_address
. When saved, it should look like this.
-
Login to IBM Security Verify admin console (https://yourtenant.verify.ibm.com/ui/admin) using admin or privacy officer credentials
-
Go to
Data privacy & consent > Purposes
-
Add purpose with ID
marketing
and 3 user attributes - email, mobile_number and work_number. Set access type asdefault
. When saved and published, it should look like this. -
Add purpose with ID
profilemgmt
and 5 user attributes - mobile_number, given_name, family_name, display_name, email. Create two new access types during the creation of the purpose with the IDread
andwrite
. When saved and published, it should look like this. -
Add purpose with ID
shipping
and 3 user attributes - Home Address, mobile_number, email. Set access type asdefault
. When saved and published, it should look like this.
-
Login to IBM Security Verify admin console (https://yourtenant.verify.ibm.com/ui/admin) using admin credentials
-
Go to
Applications
-
Click on
Add Application
and add aCustom Application
-
Fill in the name of the application etc. in the General tab.
-
Switch to the
Sign On
tab and chooseOpen ID Connect
as the Sign-on method. -
Enter an application URL. If you are running this app locally, use
http://localhost:3000
-
Verify that
Authorization code
is selected the grant type -
Uncheck
Require proof key for code exchange (PKCE) verification
. -
Add the redirect URI as
http://localhost:3000/auth/callback
if you are running this locally. If you hosting this somewhere, replace the hostname and protocol as appropriate. -
Uncheck "Restrict Custom Scopes"
-
Click Save.
-
In the Entitlements tab, choose
Automatic access for all users and groups
. Click Save. -
In the Privacy tab, add the Marketing, Profile Management and Shipping purposes.
-
Copy the dotenv file and name the new file
.env
. -
Change the
TENANT_URL
,ClIENT_ID
andCLIENT_SECRET
. The client ID and secret are obtained from the application that was created in the previous section.
-
Install node dependencies
npm install
-
Run the application. You should see
Server started and listening on port 3000
after executing the command below.npm start
-
Open the browser and go to http://localhost:3000 and you should be able to use the application
-
If everything is correctly setup, you should be redirected to authenticate with your tenant. On authentication, you should be presented with a consent page as below. This demonstrates the OAuth integration using the special format of the
scope
(see theSCOPE
in the .env file). -
Click on
Cart
once you login and you should see a consent prompt for shipping purpose. This demonstrates the native integration with APIs.