This series delves into the integration of ASP.NET Core apps with Keycloak SSO (running in Docker), explaining how to authenticate and authorize an user.
We’ll start configuring the Keycloak instance on Docker running this command on powershell:
docker run -p 8080:8080 -e KEYCLOAK_ADMIN=admin -e KEYCLOAK_ADMIN_PASSWORD=admin quay.io/keycloak/keycloak:latest start-dev
This will start an instance on develop mode. Open the admin UI http://localhost:8080, option “Administration Console”, login with admin/admin credentials:
Lets create a new realm, name it aspnet (or any name do you want):
The realm needs just the name:
After create a realm, create a client:
Client type: OpenId;
ClientId: You can use a plain text or a uuid;
Give a name and description to the client;
Client Authentication: off;
Enable Implicit Flow (It’ll used by Swagger);
Root URL: API Url;
Valid Redirects URIs: are URIs that Keycloak can redirect after login;
Web Origins: are URIs that Keycloak can accept requests, set it ‘+’ to accept requests from Valid Redirect URIs;
Save. Now, create an user in the realm:
In the credentials tab, create a password (make it simple, like 123456):
For now, We have a Keycloak instance configured to use. In the next part, We’ll configure an API to use this client.