The ForgeRock SDK provides an option for using the Authorization Code Flow (with PKCE) with a centralized login application. For a non-authenticated user, use the login of "redirect" option (from the TokenManager) to request OAuth/OIDC tokens. This instructs the SDK to redirect the user to the login application that uses the ForgeRock platform. After successful authentication, the SDK redirects the user back to the original application to obtain OAuth/OIDC tokens and complete the centralized login flow.
You can run this sample app with the npm run start:central-login command. Please see the Getting Started instructions for more details.
-
Setup CORS support in an Access Management (AM) instance.
See Enabling CORS Support in the Documentation.
-
Create an authentication tree in AM.
See Creating a User Authentication Tree in the Documentation.
-
Clone this repo:
git clone https://github.com/ForgeRock/forgerock-javascript-sdk.git -
In the root folder of the repo, use NPM to install dependencies:
npm install -
Open
samples/central-login/.env.example. Copy the file in the same directory and name it.env. Fill in the values in this file with your values. -
Run the Central Login application
npm run start:central-login -
Edit your
/etc/hostsfile to point your localhost (e.g.127.0.0.1) tosdkapp.example.com -
In a supported web browser, navigate to https://sdkapp.example.com:8443.