Oidc sample app for Angular | Read-only mirror of https://github.com/swisscom/sample-uaa-angular-client — Swisscom. Issues & pull requests at the source.
  • TypeScript 86.5%
  • HTML 10.5%
  • Shell 2.3%
  • CSS 0.7%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2024-10-16 17:18:56 +02:00
src Remove renew and logout buttons for now 2019-02-28 09:57:17 +01:00
.cfignore Make minor formatting changes 2019-02-26 16:07:11 +01:00
.gitignore Change build output folder and ignore it in git 2019-02-25 15:41:56 +01:00
angular.json Change build output folder and ignore it in git 2019-02-25 15:41:56 +01:00
CODE_OF_CONDUCT.md Compliance bulk update. Add CODE_OF_CONDUCT.md 2024-10-16 17:18:56 +02:00
CONTRIBUTING.md Compliance bulk update. Add CONTRIBUTING.md 2024-10-16 17:18:55 +02:00
LICENSE add license 2023-04-24 17:56:32 +02:00
manifest.yml Add stuff for CF deployment 2019-02-25 15:52:25 +01:00
package-lock.json Merge pull request #17 from JamesClonk/elliptic 2020-10-06 19:09:42 +02:00
package.json Remove test code (does add value to the example) 2019-02-28 08:17:42 +01:00
README.md Update README.md 2023-08-02 11:39:40 +02:00
start.sh Add stuff for CF deployment 2019-02-25 15:52:25 +01:00
Staticfile Add stuff for CF deployment 2019-02-25 15:52:25 +01:00
tsconfig.json Import sample code from https://github.com/IdentityModel/oidc-client-js 2019-02-25 15:36:33 +01:00
tslint.json Import sample code from https://github.com/IdentityModel/oidc-client-js 2019-02-25 15:36:33 +01:00

sample-uaa-angular-client

This is a small Angular sample app to demonstrate how to integrate with a UAA service using the implicit flow of OIDC. The code is based on the Angular sample app in oidc-client-js.

Running this sample

Here's how you can run the example app in your own space.

Set up a resource server

To run this sample, you need to first set up a resource server, i.e. an API to which your Angular app will connect once it has the auth token. To achieve this you can either deploy the Spring Boot sample or the Ruby sample. We will refer to the URL under which this resource server is running as <resource server URL>.

Clone the repo

Next you need to clone this repo.

git clone https://github.com/swisscom/sample-uaa-angular-client.git

Adapt the config

Adapt the manifest.yml to include the route which you want to assign to your app as well as the URL of the resource server. Note that you will also need to reference this route in the service instance creation step below.

---
applications:
  - name: sample-uaa-angular-client
    env:
      SERVER_URL: <resource server URL>
    memory: 64MB
    command: $HOME/public/start.sh
    path: dist
    routes:
      - route: <provide a route for your app>
    services:
      - oauth2

Create an instance of the UAA service

Use the Cloud Foundry CLI to create a user provided service instance for the UAA you are targeting. The parameter redirectUris will reference your app's route, as specified in the manifest.yml. Be sure to tag your service instance with oauth2 as shown below, so that the the OIDC enpoints of the instace can be picked up by the service binding an served to the browser app.

CREDENTIALS='{"logoutEndpoint": "<uaa-url>/logout.do", "userInfoEndpoint": "<uaa-url>/userinfo", "checkTokenEndpoint": "<uaa-url>/check_token", "scope": "openid,roles,user_attributes", "grantTypes": "implicit", "redirectUris": "<your app's route>/callback", "authorizationEndpoint": "<uaa-url>/oauth/authorize", "clientId": "HwykJoWyMNmJMLe93OgFiTxeOzYVMk7ff80v7ss87FwUJKIwsyzlM6vm2YVN4u9g", "clientSecret": "null", "accessTokenValidity": "14400", "tokenEndpoint": "<uaa-url>/oauth/token"}
cf create-user-provided-service oauth2 -p $CREDENTIALS -t oauth2

Build the Angular app

Run the productive build for the Angular app.

npm run build

Push the app

Push the app to Cloud Foundry

cf push

Sample overview

Authorization code

Implicit flow & Client Credentials

WARNING: PKCE's secure implementation renders the implicit flow obsolete, as it is vulnerable and must not be used anymore.