Keycloak#
Keycloak is an open-source Identity and Access Management (IAM) solution that provides user authentication, authorization, and single sign-on capabilities. It enables secure access to applications and services by managing user identities and permissions. In the Urban Model Platform, Keycloak serves as the central authentication server, handling access control across components.
Configure Keycloak#
Open Keycloak on
http://localhost:${KEYCLOAK_PORT_EXTERNAL}/authIn order to configure a dev setup Keycloak initially, log in with admin/admin. Then:
Create a new realm named
UrbanModelPlatformCreate a new client in that realm called
ump-client(activate OAuth 2.0 Device Authorization Grant and Direct access grants)Create a test user called
ump, set its password toumpMake sure to set the keycloak host in
.envto your local hostname or IP address
Securing Model Servers and Processes#
You can secure processes and model servers in keycloak by adding users to special client roles. In order to secure a specific process, create a role named modelserver_processid, in order to secure all processes of a model server just create a role named modelserver. The ids correspond to the keys used in the providers.yaml.
Accessing secured Processes in Development#
If you access the /processes list without any authentification, you can see all processes which are configured to be anonymous_access: True (Learn more about the configuration of providers here). If you want to see all processes a specific user is authorized to see, follow the following steps:
Log in with admin/admin
Go to the user (e.g.
ump) and make sure to fill out the general information and switch on “E-Mail verified”Log out and log in to the user
umpvia the following URL:http://localhost:${KEYCLOAK_PORT_EXTERNAL}/auth/realms/UrbanModelPlatform/accountObtain the client secret by going to the client, clicking
Credentialsand copying the secretIf the login is working, get token for user:
curl -X POST "http://localhost:${KEYCLOAK_PORT_EXTERNAL}/auth/realms/UrbanModelPlatform/protocol/openid-connect/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=password" \
-d "client_id=ump-client" \
-d "client_secret=<client-secret>" \
-d "username=ump" \
-d "password=ump"
With the token obtained, you can access the entire processes list by executing:
curl -L -v -X GET "http://localhost:<WEBAPP_PORT_EXTERNAL>/api/processes" \
-H -H "Authorization: Bearer <insert_token_here>"