This is a sample project that uses Manfred Steyer's great library angular-oauth2-oidc to add OpenID Connect to an Angular project.
It uses the Angular APP_INITIALIZER to configure the authentication at runtime.
The authConfig is read at runtime from the file app/src/assets/config.json that is loaded at startup. To allow easier configuration the values
for redirectUri
and silentRefreshRedirectUri
use relative urls that are prefixed
with the url got from window.location.origin
.
Maybe you want to do some authorization based on claims received by the OIDC token issuer.
For this, a simple authorizer has been implemented. It is up to you to implement your own logic there to check the authorization.
To start the app just run:
(cd app && npm start)
The start configuration uses proxy-local-conf.json to map
any request starting with "/api"
to a backend running on http://localhost:3000
. This is just for testing. Adjust the settings to map your own backend app there.
You can find an example backend here: https://github.com/guidoffm/sample-backend-for-angular-oidc-with-app-initializer