Demo for Keycloak Integration in ASP.NET Core and Angular.

February 23, 2021 ยท View on GitHub

Start

Use

docker-compose up

to start Keycloak, the API and Angular Frontend.

Urls

SystemUrl
Keycloakhttp://localhost:8080
APIhttp://localhost:5000
Frontendhttp://localhost:4200

Logins

UsernamePasswordDescription
editoreditorCan create posts and delete not published posts
publisherpublisherCan publish and unpublish posts
legallegaCan unpublish posts

Point of interest

API

FileDescription
startup.csConfigures Jwt Bearer authentication to use Keycloak
KeycloakRolesClaimsTransformation.csTransforms keycloak role claims to be compatible with ASP.NET
startup.csConfigures authorization with Keycloak
KeycloakAuthorization\KeycloakAuthorizationHandler.csAuthorization handler that makes decision call to Keycloak

Frontend

FileDescription
keycloakAuthorization.service.tsAuthorization Service that makes decision call to Keycloak.
security.service.tsSecurity service that checks the roles of the user.
auth.guard.tsAuth guard to protect routes.