Repository: keycloak
Keycloak
Section titled “Keycloak”CONFIGURE KEYCLOAK 26.0
Section titled “CONFIGURE KEYCLOAK 26.0”CACHE ON AZURE
Section titled “CACHE ON AZURE”- In the env variabels in the server Rancher/Azure Container APP add the following:
JAVA_OPTS_APPEND = -Djboss.jgroups.azure_ping.storage_account_name=BLOB_STORAGE_NAME -Djboss.jgroups.azure_ping.storage_access_key=BLOB_STORAGE_ACCESS_KEY -Djboss.jgroups.azure_ping.container=THE_CONTAINER_NAMEPOSTGRES DATABASE CONECTION
Section titled “POSTGRES DATABASE CONECTION”- In the env variabels in the server Rancher/Azure Container APP add the following:
KC_DB=postgres KC_DB_USERNAME=KEYCLOAK_DB_USERNAME KC_DB_PASSWORD=KEYCLOAK_DB_PASSWORD KC_DB_URL=jdbc:postgresql://{HOST}:{PORT}/{DB_NAME}?&sslmode=verify-ca&sslfactory=org.postgresql.ssl.DefaultJavaSSLFactory KC_HTTP_ENABLED=true KC_PROXY_HEADERS=xforwarded KC_HOSTNAME_DEBUG=trueREALM PROVIDER EXTENSION
Section titled “REALM PROVIDER EXTENSION”TO ENABLE IT
- in the start the variable must be added
REALM_PROVIDER='the-name-of-the-realm' ... ... ... KC_DB=postgres KC_DB_USERNAME=KEYCLOAK_DB_USERNAME KC_DB_PASSWORD=KEYCLOAK_DB_PASSWORD ...- later after starting key claok only create a realm that has the same name as the
REALM_PROVIDERvariable. and it is ready to use.
======================
-
Build the project in mvn
-
Copy the JAR file to the provider folder in the keycloak server
-
This extension provids an API fuctionality to get the realm for a user.
-
For example if the realm that we activated this functionality on is called
realm-providerthen the API is available on the following endpoint:http://{KEYCLOAK-HOST}/realms/realm-provider/user-extention/realms- The call is a
GETrequest it must take aquery parametercalleduserstating the username or the email. - The complete call is
http://{KEYCLOAK-HOST}/realms/realm-provider/user-extention/realms?user={username} - As we stated in the environment variable
REALM_PROVIDERthe value is the realm name that this functionality is available on, so the call is only available on the realm that is stated in the environment variable. If the same call is done using another realm name, the call will return a404error.
- The call is a
-
The response is a
jsonobject as follows:- If no query parameter is provided, the response is a
400error.
{"error": "User parameter is required"}- If the user is not found, the response is a
404error.
{"error": "User not found in any realm"}- If the user is found in only ONE realm, the response is a
200status code with the following response:
{"hint": "realm-name","status": "ok"}Hint: the hint param is the realm name that the user is found in.
- If the user is found in MORE than one realm, the response is a
200status code with the following response:
{"message": "User found in multiple realms","status": "ok"}Hint: in this case the user have to state the realm so we can use the login directly to correct realm.
- If no query parameter is provided, the response is a
-