From 268471fed6df131975440ffe4eb93260da44c5c1 Mon Sep 17 00:00:00 2001 From: ewelinagr Date: Tue, 7 May 2024 14:44:36 +0200 Subject: [PATCH 1/4] Add custome fairspace login theme. --- charts/fairspace-keycloak/values.yaml | 20 ++++++ local-development/deploy.sh | 11 ++++ local-development/fairspace-realm.json | 5 +- local-development/local-values.yaml | 14 ++++ themes/Dockerfile | 2 + themes/README.md | 1 + .../login/resources/css/fairspace/login.css | 62 ++++++++++++++++++ .../resources/img/fairspace_logo_white.png | Bin 0 -> 5600 bytes themes/fairspace_theme/login/theme.properties | 6 ++ 9 files changed, 119 insertions(+), 2 deletions(-) create mode 100644 themes/Dockerfile create mode 100644 themes/README.md create mode 100644 themes/fairspace_theme/login/resources/css/fairspace/login.css create mode 100644 themes/fairspace_theme/login/resources/img/fairspace_logo_white.png create mode 100644 themes/fairspace_theme/login/theme.properties diff --git a/charts/fairspace-keycloak/values.yaml b/charts/fairspace-keycloak/values.yaml index a5dcadf..333c92e 100644 --- a/charts/fairspace-keycloak/values.yaml +++ b/charts/fairspace-keycloak/values.yaml @@ -31,6 +31,26 @@ keycloakx: database: keycloak existingSecret: keycloak-postgresql username: keycloak + extraInitContainers: | + - name: theme-provider + image: keycloak-fairspace-theme:latest + imagePullPolicy: IfNotPresent + command: + - sh + args: + - -c + - | + echo "Copying Fairspace theme..." + cp -R /fairspace_theme/* /theme + volumeMounts: + - name: theme + mountPath: /theme + extraVolumeMounts: | + - name: theme + mountPath: /opt/keycloak/themes/fairspace_theme + extraVolumes: | + - name: theme + emptyDir: { } postgresql: fullnameOverride: keycloak-db-postgresql diff --git a/local-development/deploy.sh b/local-development/deploy.sh index 58d3645..19e3101 100755 --- a/local-development/deploy.sh +++ b/local-development/deploy.sh @@ -7,6 +7,17 @@ helm_cmd=$(realpath ~/bin/helm3/helm) # $ minikube start # $ minikube addons enable ingress +eval $(minikube docker-env) + +pushd "${here}" + +pushd ../themes +(docker build . -t keycloak-fairspace-theme:latest) || { + echo "Building Fairspace theme image failed." + popd + exit 1 +} + pushd "${here}" (kubectl get ns keycloak-dev || kubectl create ns keycloak-dev) && \ diff --git a/local-development/fairspace-realm.json b/local-development/fairspace-realm.json index 52dd6d6..c9398c4 100644 --- a/local-development/fairspace-realm.json +++ b/local-development/fairspace-realm.json @@ -1,8 +1,9 @@ { "id": "fairspace", "realm": "fairspace", - "displayName": "Fairspace (local environment)", - "displayNameHtml": "Local environment
Fairspace
", + "displayName": "Fairspace (test environment)", + "displayNameHtml": "
Fairspace
", + "loginTheme": "fairspace_theme", "notBefore": 0, "revokeRefreshToken": false, "refreshTokenMaxReuse": 0, diff --git a/local-development/local-values.yaml b/local-development/local-values.yaml index 5aa5651..7bc83f0 100644 --- a/local-development/local-values.yaml +++ b/local-development/local-values.yaml @@ -4,6 +4,20 @@ fairspaceKeycloak: postgresPassword: "keycloak" # Set passwords to prevent having a new password at every upgrade keycloakx: + extraInitContainers: | + - name: theme-provider + image: keycloak-fairspace-theme:latest + imagePullPolicy: IfNotPresent + command: + - sh + args: + - -c + - | + echo "Copying Fairspace theme..." + cp -R /fairspace_theme/* /theme + volumeMounts: + - name: theme + mountPath: /theme extraEnv: | - name: KEYCLOAK_ADMIN value: keycloak diff --git a/themes/Dockerfile b/themes/Dockerfile new file mode 100644 index 0000000..4339bfa --- /dev/null +++ b/themes/Dockerfile @@ -0,0 +1,2 @@ +FROM busybox +COPY fairspace_theme /fairspace_theme \ No newline at end of file diff --git a/themes/README.md b/themes/README.md new file mode 100644 index 0000000..c361761 --- /dev/null +++ b/themes/README.md @@ -0,0 +1 @@ +TODO: document custom themes here... \ No newline at end of file diff --git a/themes/fairspace_theme/login/resources/css/fairspace/login.css b/themes/fairspace_theme/login/resources/css/fairspace/login.css new file mode 100644 index 0000000..3aebc30 --- /dev/null +++ b/themes/fairspace_theme/login/resources/css/fairspace/login.css @@ -0,0 +1,62 @@ +/*# Overwrites login page style of keycloak theme. +See: https://github.com/keycloak/keycloak/blob/main/themes/src/main/resources/theme/keycloak/login/resources/css/login.css */ + +:root { + --kc-blue-light: rgba(106,134,232,1); + --kc-blue-light-transp-25: rgba(106,134,232,0.25); + --kc-blue-medium: rgba(52,95,157,1); + --kc-blue-dark: rgba(8,65,92,1); +} + +.login-pf body { + background: radial-gradient(circle, var(--kc-blue-light) 5%, var(--kc-blue-medium) 25%, var(--kc-blue-dark) 75%); + background-size: cover; + height: 100%; +} + +#kc-header-wrapper { + padding: 30px 10px 0; +} + +div.kc-logo-text { + background-image: url(../../img/fairspace_logo_white.png); + background-size: contain; + background-position: center; + background-repeat: no-repeat; + height: 100px; + margin: 0 auto; +} + +.card-pf { + color: white; + margin: 0 auto; + box-shadow: none; + max-width: 500px; + border: 1px solid; + border-radius: 25px; + border-color: var(--kc-blue-light-transp-25); + background-color: var(--kc-blue-light-transp-25); +} + +.login-pf-page .card-pf { + padding: 60px 30px 70px; +} + +.login-pf-page .login-pf-header h1 { + text-align: left; + font-weight: bold; +} + +.pf-c-button.pf-m-primary { + background-color: var(--kc-blue-dark); + border-radius: 5px; +} + +#kc-form-buttons { + padding-top: 20px; + padding-bottom: 20px; +} + +.pf-c-form-control:not(textarea) { + border-radius: 5px; +} \ No newline at end of file diff --git a/themes/fairspace_theme/login/resources/img/fairspace_logo_white.png b/themes/fairspace_theme/login/resources/img/fairspace_logo_white.png new file mode 100644 index 0000000000000000000000000000000000000000..6291bdf6a932e13fec7b73a511ec5ba6b430d679 GIT binary patch literal 5600 zcmV<66(8z}P)EX>4Tx04R}tkv&MmKpe$iQ>7}E4t5Z6$WWc^q9Tr^6^me@v=v%)FuC*#nlvOS zE{=k0!NHHks)LKOt`4q(Aou~|>f)s6A|?JWDYS_3;J6>}?mh0_0Ya^gBSkzXsT&FpXB$kju8X{ygP(=+EqO@wHn8?t6+`~WS_|xQ)$yEg- z#{%k5Avu2VKlt6PS(=%4lY()e|HZaHCV;>$&~DoH_pxoaPXPZjaHVzq^%gMyNqV!Z zMUH^bHgIv>)#N?kat9cF(j`N3BtK1|R07`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}x zlR_8JdXlH8^wXpA%3|+feSbB_c-R9+A0oCDKyPErYK55pI;N6y@M(`6)1Z$!n)54? zr>fj5jsQDY!rPH+4uhP;d^pEbvy>{H0B_CZwcjMS$)2XS04z|6S3CjEu>d+Kr#e^2 zDkR5}Y^0K|nBc5#?X`YDcMDeX4WPX=%}gmBD(f(l?Xgc$b}RX&K^IxcA!?^7c?Hh; zR(jn#$`K{shWN*=_NObWmAnC{toa^bUD~ItR`LR%GR=3NbGe4HTFC=|(f}9-z+DVi zMOm$sb%2uiIe>04Zs`!Olx={r5`eI6y!R-pm9h#@5(5B)Wy-HtRx4$doFipiI!!sG zludA+7YCdNP)K!>l(GuYC*uHgg>pzKYc{CtuXIJ6BJV1jm9pt1bq7!<&i(nyW~FQb zv`d2fZ!4RXvT1+57sviwsvJ_vng%6V9YA56A`_LxO4-z&ZQ^LpgSobYol?cKL7T<7 zH`5riNm;CvO@OwDbMHZAuTr)F+BD?)9AnG^Wv^1U0a`EQ`e_&2>&KN2A3eegLP9-HJB_$;v>Hh&hm4L~g?Hf}70000 Date: Mon, 13 May 2024 12:30:53 +0200 Subject: [PATCH 2/4] Add github action to build and upload theme Docker images. --- ...build_and_upload_theme_on_push_to_dev.yaml | 55 +++++++++++++++++++ themes/VERSION | 1 + 2 files changed, 56 insertions(+) create mode 100644 .github/workflows/build_and_upload_theme_on_push_to_dev.yaml create mode 100644 themes/VERSION diff --git a/.github/workflows/build_and_upload_theme_on_push_to_dev.yaml b/.github/workflows/build_and_upload_theme_on_push_to_dev.yaml new file mode 100644 index 0000000..ace0fb8 --- /dev/null +++ b/.github/workflows/build_and_upload_theme_on_push_to_dev.yaml @@ -0,0 +1,55 @@ +# Jobs to build and deploy a Docker image for Fairspace Keycloak theme on push to the dev or release branches + +name: Build & Upload Fairspace Keycloak Theme Docker image + +env: + DOCKER_REGISTRY: ghcr.io + +on: + push: + branches: + - dev + - release + +jobs: + build-and-upload-docker-image-for-keycloak-fairspace-theme: + needs: [generate-version] + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Prepare version + run: | + # EXTRACT VERSION + BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} + echo "Building theme image from the branch: $BRANCH" + VER=$(cat ./themes/VERSION) + echo "Building theme image of version: $VER" + if [ $BRANCH != "release" ] + then + VER=$VER-SNAPSHOT + fi + echo "Docker tag to be attached to images: $VERSION" + echo "VERSION=$VERSION" >> $GITHUB_ENV + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.DOCKER_REGISTRY }} + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.DOCKER_REGISTRY }}/${{ github.repository }}/keycloak-fairspace-theme + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: ./themes/ + push: true + tags: ${{ env.DOCKER_REGISTRY }}/${{ github.repository }}/keycloak-fairspace-theme:${{ env.VERSION }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/themes/VERSION b/themes/VERSION new file mode 100644 index 0000000..8acdd82 --- /dev/null +++ b/themes/VERSION @@ -0,0 +1 @@ +0.0.1 From a6738e519868ba418efb9ba8129cbfb5a817e1ed Mon Sep 17 00:00:00 2001 From: ewelinagr Date: Tue, 14 May 2024 10:13:00 +0200 Subject: [PATCH 3/4] Add theme documentation. --- themes/README.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/themes/README.md b/themes/README.md index c361761..b3ddd94 100644 --- a/themes/README.md +++ b/themes/README.md @@ -1 +1,15 @@ -TODO: document custom themes here... \ No newline at end of file +# Custom Fairspace themes for Keycloak + +Keycloak allows customising the look and feel of the web pages, including login, account or admin console, by providing custom themes. +Keycloak provides default themes that can be extended or overridden by custom themes. A theme consists of a set of resources, such as HTML templates, CSS, JavaScript, images, message bundles and theme properties. + +More information about custom themes can be found in the [Keycloak documentation](https://www.keycloak.org/docs/latest/server_development/#_theme_stylesheet). + + +## Fairspace theme + +This directory contains the custom Fairspace theme for Keycloak. The theme is based on the default theme called "keycloak" and includes custom styles and a logo. + +The theme is packaged into a Docker image and made available in the Kubernetes setup using init container as theme provider. + +More information about the theme setup with Kubernetes and Helm can be found in [Keycloakx Helm chart documentation](https://github.com/codecentric/helm-charts/tree/master/charts/keycloakx#providing-a-custom-theme). From 1586ae58741b36a2a5894d9976604975860f9e77 Mon Sep 17 00:00:00 2001 From: ewelinagr Date: Tue, 14 May 2024 10:51:01 +0200 Subject: [PATCH 4/4] Adjust styling to include darker background. --- .../fairspace_theme/login/resources/css/fairspace/login.css | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/themes/fairspace_theme/login/resources/css/fairspace/login.css b/themes/fairspace_theme/login/resources/css/fairspace/login.css index 3aebc30..ff251d8 100644 --- a/themes/fairspace_theme/login/resources/css/fairspace/login.css +++ b/themes/fairspace_theme/login/resources/css/fairspace/login.css @@ -4,12 +4,12 @@ See: https://github.com/keycloak/keycloak/blob/main/themes/src/main/resources/th :root { --kc-blue-light: rgba(106,134,232,1); --kc-blue-light-transp-25: rgba(106,134,232,0.25); - --kc-blue-medium: rgba(52,95,157,1); - --kc-blue-dark: rgba(8,65,92,1); + --kc-blue-medium: rgba(63,102,177,1); + --kc-blue-dark: rgb(7, 59, 82); } .login-pf body { - background: radial-gradient(circle, var(--kc-blue-light) 5%, var(--kc-blue-medium) 25%, var(--kc-blue-dark) 75%); + background: radial-gradient(circle, var(--kc-blue-light) 10%, var(--kc-blue-medium) 25%, var(--kc-blue-dark) 75%); background-size: cover; height: 100%; }