Skip to content

Latest commit

 

History

History
139 lines (92 loc) · 3.73 KB

File metadata and controls

139 lines (92 loc) · 3.73 KB

How to run the SPA with the Standard OAuth Agent

Overview

The end-to-end solution provides the following behaviour:

  • The OAuth Agent performs OAuth work for the SPA in an API driven manner
  • Authorization Code Flow (PKCE) is used, along with a simple client secret
  • Only the strongest SameSite=strict cookies are used in the browser
  • The code example uses HTTP to reduce infrastructure

Configure Development Domains

Add these entries to your /etc/hosts file:

127.0.0.1 localhost www.example.com api.example.com login.example.com
:1        localhost

Install Prerequisites

Ensure that these tools are installed locally:

Also get a License File for the Curity Identity Server and copy it to the root folder:

Also, ensure that your computer's Curity Docker image is up to date:

docker pull curity.azurecr.io/curity/idsvr

Build the Code

This will compile projects and build Docker images:

./build.sh

For further control you can override the script with options:

OAUTH_AGENT=''
OAUTH_PROXY=''
./build.sh "$OAUTH_AGENT" "$OAUTH_PROXY" 

OAUTH_AGENT supported values:

  • NODE (default)
  • NET
  • KOTLIN

OAUTH_PROXY supported values:

  • KONG (default)
  • NGINX
  • OPENRESTY

Deploy the System

Then run this script to spin up all components in a small Docker Compose network:

./deploy.sh

If overriding default options, supply the same options to this script:

OAUTH_AGENT=''
OAUTH_PROXY=''
./deploy.sh "$OAUTH_AGENT" "$OAUTH_PROXY" 

Use the System

Then browse to http://www.example.com and sign in with the following test user name and password:

  • demouser / Password1

The SPA has an initial unauthenticated view to focus on triggering a login:

Unauthenticated View

The authenticated view demonstrates multi-tab browsing, which works reliably in all browsers:

Authenticated View

Deployed System

Once the system is deployed you can also browse to these URLs:

Deployment Details

To understand token handler deployment details you can study the build and deployment scripts.

Troubleshoot

If you need to troubleshoot, then access logs for the OAuth agent and OAuth proxy with these commands:

OAUTH_AGENT_CONTAINER_ID=$(docker container ls | grep oauth-agent | awk '{print $1}')
docker logs -f $OAUTH_AGENT_CONTAINER_ID
API_GATEWAY_CONTAINER_ID=$(docker container ls | grep api-gateway | awk '{print $1}')
docker logs -f $API_GATEWAY_CONTAINER_ID

Run UI Tests

If required, run the SPA's automated UI tests for login related operations:

cd spa
npm run uitests

Free Resources

When finished with your development session, run the following script to free resources:

./teardown.sh