diff --git a/docker/services/keycloak/Dockerfile b/docker/services/keycloak/Dockerfile --- a/docker/services/keycloak/Dockerfile +++ b/docker/services/keycloak/Dockerfile @@ -1,6 +1,8 @@ FROM jboss/keycloak USER root +# install git to get custom keycloak theme in service entrypoint +RUN microdnf install -y git # install python3 and python-keycloak, this is needed to execute a # custom config script after keycloak server is up RUN microdnf install -y python3 && microdnf clean all diff --git a/docker/services/keycloak/entrypoint.sh b/docker/services/keycloak/entrypoint.sh --- a/docker/services/keycloak/entrypoint.sh +++ b/docker/services/keycloak/entrypoint.sh @@ -3,6 +3,13 @@ # turn on bash's job control set -m +cd +if [ ! -d swh-keycloak-theme ] +then + git clone https://forge.softwareheritage.org/source/swh-keycloak-theme.git + ln -s /opt/jboss/swh-keycloak-theme/swh/ /opt/jboss/keycloak/themes/swh +fi + echo "Starting Keycloak" /opt/jboss/tools/docker-entrypoint.sh -b 0.0.0.0& echo "Waiting for Keycloak server to be up" diff --git a/docker/services/keycloak/keycloak_swh_setup.py b/docker/services/keycloak/keycloak_swh_setup.py --- a/docker/services/keycloak/keycloak_swh_setup.py +++ b/docker/services/keycloak/keycloak_swh_setup.py @@ -67,6 +67,12 @@ '/keycloak/auth/admin/master/console/index.html' ) +keycloak_admin.update_realm('master', payload={ + 'loginTheme': 'swh', + 'accountTheme': 'swh', + 'adminTheme': 'swh', +}) + # create swh realm keycloak_admin.create_realm(payload={ 'realm': realm_name, @@ -75,6 +81,9 @@ 'frontendUrl': 'http://localhost:5080/keycloak/auth/' }, 'enabled': True, + 'loginTheme': 'swh', + 'accountTheme': 'swh', + 'adminTheme': 'swh', }, skip_exists=True) # set swh realm name in order to create users in it