« »
7/24/2019

Rollback Keycloak admin theme change without downtime

Let start this post by saying that you just f*cked up changed Keycloak master realm admin theme to "base" and now you cry out loud deeply regret it 😅.

Here is how to bring everything's back without neither restarting Keycloak and restoring a backup.

First thing first connect to your database (hopefully PostgreSQL if you are decent) and run this SQL query:

UPDATE public.realm SET admin_theme = null WHERE id ='master'

Are we done yet? Nope, as you may know Keycloak has its own internal cache, you will have to flush it with the script below (note that jq is required and also don't forget to change username, password and endpoint):

username=admin
password=admin
endpoint=https://my-awesome-keycloak.com

# first retrieve a new token
export ACCESS_TOKEN=$(curl -X POST "$endpoint/auth/realms/master/protocol/openid-connect/token" \
 -H "Content-Type: application/x-www-form-urlencoded" \
 -d "username=$username" \
 -d "password=$password" \
 -d 'grant_type=password' \
 -d 'client_id=admin-cli' | jq -r '.access_token')

# then clear keycloak internal realm cache
curl -v -X POST "$endpoint/auth/admin/realms/master/clear-realm-cache" \
-H "Accept: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN"

Refresh your Keycloak console interface. Yep. You're welcome 👍

« »
 
 
Made with on a hot august night from an airplane the 19th of March 2017.