Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade to Keycloakify 11 #3272

Merged
merged 52 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
4b2d680
Add starter; add nvmrc; add yarn to package.json; copy over Dockerfile
fhennig Nov 21, 2024
b1167a5
yarn install
fhennig Nov 21, 2024
c6993bd
Apply theos fix
fhennig Nov 21, 2024
dabec3d
Fix casing warning
fhennig Nov 21, 2024
e3d4c29
don't copy .yarn/releases, as it shouldn't be needed if packageManage…
fhennig Nov 21, 2024
bdf6de3
Restrict license to apply only to this repo as before!
fhennig Nov 21, 2024
5f4e5cf
Set theme name
fhennig Nov 21, 2024
957ef6f
Fix package name
fhennig Nov 21, 2024
e0eea87
Update README
fhennig Nov 21, 2024
b751fbb
yarn install
fhennig Nov 21, 2024
ba04eca
Update Dockerfile for new output filenames
fhennig Nov 21, 2024
e505074
Update auto-gen file
fhennig Nov 21, 2024
3e36cd4
fix docker
fhennig Nov 21, 2024
09394c9
remove outdated comment
fhennig Nov 21, 2024
1b75cab
Add comment about the version switch
fhennig Nov 21, 2024
5f7ddc8
Update README a bit more
fhennig Nov 21, 2024
d6f991e
Copy over dockerignore
fhennig Nov 21, 2024
1d6124a
add 'nvm use' to README
fhennig Nov 21, 2024
8ef9e01
add email theme as we did so previously
fhennig Nov 21, 2024
47989e7
delete upstream ci file
fhennig Nov 21, 2024
755a507
Update favicon
fhennig Nov 21, 2024
cfafdbc
apparently formatting the README?
fhennig Nov 21, 2024
df1d67d
Add ORCID button to register?
fhennig Nov 21, 2024
a8bab1f
Make ORCID logo prettier -- use the same code as on the login page
fhennig Nov 21, 2024
1b0acea
fix
fhennig Nov 21, 2024
f2543ab
Add old email text back
fhennig Nov 21, 2024
e4a9233
Upercase KcContext
fhennig Nov 21, 2024
97cf2c0
Fix export back to how it is in starter
corneliusroemer Nov 21, 2024
a35e31e
Update Readme, it's one of the few things that are good to change fro…
corneliusroemer Nov 21, 2024
d8f904f
Add ToS Storybook with ORCID
fhennig Nov 25, 2024
828c759
add basic styling
fhennig Nov 25, 2024
b9e60f9
Add link to ToS and Privacy Policy
fhennig Nov 25, 2024
2fcd1ad
Fix org invite text
fhennig Nov 25, 2024
d735279
Improve Orcid icon handling
fhennig Nov 25, 2024
d04d5e4
formatting
fhennig Nov 25, 2024
09af143
Hide realm name in layout
fhennig Nov 25, 2024
e9ea5f8
Hardcode termsAcceptanceRequired=true
fhennig Nov 25, 2024
554579b
Add link to GH issue
fhennig Nov 25, 2024
6d9d189
Eject IdpReviewUserProfile
fhennig Nov 25, 2024
85db45b
Add back email theme; use PROJECT_NAME env var instead of realmName
fhennig Nov 25, 2024
cf0a503
Display header again, but don't use realm name, use env.PROJECT_NAME …
fhennig Nov 25, 2024
6c1a866
Fix env var usage
fhennig Nov 25, 2024
1bfb616
Add checkbox to the post-orcid-profile thingie
fhennig Nov 25, 2024
3ab7bc8
add REGISTRATION_TERMS_MESSAGE env var
fhennig Nov 25, 2024
923370f
Use ToS from env
fhennig Nov 25, 2024
7a65f9a
helmchart: Set PROJECT_NAME from Values.name
fhennig Nov 25, 2024
fd4c9f4
silly me ... fix
fhennig Nov 25, 2024
b0b0bd7
Fix HTML injection
fhennig Nov 25, 2024
c679fcc
Update readme
fhennig Nov 26, 2024
6b073c5
remove old theme
fhennig Nov 26, 2024
a7467af
Add theme.properties back
fhennig Nov 26, 2024
3bf4195
email fix now?
fhennig Nov 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/keycloakify-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,5 @@ jobs:
run: yarn install --immutable
- name: Build
run: yarn build
- name: Build storybook
run: yarn build-storybook
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we use storybook we should test it in CI so we can upgrade without surprises. I.e. don't revert this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

build-storybook doesn't exist anymore, and there isn't a replacement AFAIK

- name: Build keycloak theme
run: yarn build-keycloak-theme
26 changes: 0 additions & 26 deletions keycloak/keycloakify/.devcontainer/.devcontainer.json

This file was deleted.

46 changes: 24 additions & 22 deletions keycloak/keycloakify/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:react-hooks/recommended', 'plugin:storybook/recommended'],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
root: true,
env: { browser: true, es2020: true },
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended",
"plugin:storybook/recommended"
],
'react-hooks/exhaustive-deps': 'off',
'@typescript-eslint/no-redeclare': 'off',
'no-labels': 'off',
},
overrides: [
{
files: ['**/*.stories.*'],
rules: {
'import/no-anonymous-default-export': 'off',
},
ignorePatterns: ["dist", ".eslintrc.cjs"],
parser: "@typescript-eslint/parser",
plugins: ["react-refresh"],
rules: {
"react-refresh/only-export-components": ["warn", { allowConstantExport: true }],
"react-hooks/exhaustive-deps": "off",
"@typescript-eslint/no-redeclare": "off",
"no-labels": "off"
},
],
}
overrides: [
{
files: ["**/*.stories.*"],
rules: {
"import/no-anonymous-default-export": "off"
}
}
]
};
2 changes: 1 addition & 1 deletion keycloak/keycloakify/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ jspm_packages

/dist_keycloak
/build
/storybook-static
/storybook-static
6 changes: 6 additions & 0 deletions keycloak/keycloakify/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules/
/dist/
/dist_keycloak/
/public/keycloakify-dev-resources/
/.vscode/
/.yarn_home/
25 changes: 25 additions & 0 deletions keycloak/keycloakify/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"printWidth": 90,
"tabWidth": 4,
"useTabs": false,
"semi": true,
"singleQuote": false,
"trailingComma": "none",
"bracketSpacing": true,
"arrowParens": "avoid",
"overrides": [
{
"files": [
"**/login/pages/*.tsx",
"**/account/pages/*.tsx",
"**/login/Template.tsx",
"**/account/Template.tsx",
"**/login/UserProfileFormFields.tsx",
"KcApp.tsx"
],
"options": {
"printWidth": 150
}
}
]
}
23 changes: 7 additions & 16 deletions keycloak/keycloakify/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
import type { StorybookConfig } from "@storybook/react-vite";

const config: StorybookConfig = {
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-onboarding",
"@storybook/addon-interactions",
"@chromatic-com/storybook"
],
framework: {
name: "@storybook/react-vite",
options: {},
},
docs: {
autodocs: "tag",
},
staticDirs: ["../public"],
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
addons: [],
framework: {
name: "@storybook/react-vite",
options: {}
},
staticDirs: ["../public"]
};
export default config;
25 changes: 25 additions & 0 deletions keycloak/keycloakify/.storybook/preview-head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<style>
body.sb-show-main.sb-main-padded {
padding: 0;
}

/* Following styles are just meant to avoid white flash when switching from one story to another */
@keyframes fadeToTransparent {
from {
background-color: #393939;
}

to {
background-color: transparent;
}
}
html {
animation: fadeToTransparent 500ms forwards ease-in;
}
body > .sb-preparing-docs {
visibility: hidden;
}
body > .sb-preparing-story {
visibility: hidden;
}
</style>
16 changes: 8 additions & 8 deletions keycloak/keycloakify/.storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import type { Preview } from "@storybook/react";

const preview: Preview = {
parameters: {
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
},
parameters: {
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i
}
}
}
};

export default preview;
894 changes: 0 additions & 894 deletions keycloak/keycloakify/.yarn/releases/yarn-4.2.2.cjs

This file was deleted.

1 change: 0 additions & 1 deletion keycloak/keycloakify/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
nodeLinker: node-modules
yarnPath: .yarn/releases/yarn-4.2.2.cjs
16 changes: 12 additions & 4 deletions keycloak/keycloakify/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
ARG NODE_VERSION=22
FROM node:${NODE_VERSION}-bookworm as builder
FROM node:${NODE_VERSION}-bookworm AS builder

ARG KEYCLOAK_ORCID_VERSION=1.3.0
ARG KEYCLOAK_MAJOR_VERSION=24

USER root

Expand All @@ -12,18 +13,25 @@ RUN mvn --version
WORKDIR /app
RUN wget https://github.com/eosc-kc/keycloak-orcid/releases/download/${KEYCLOAK_ORCID_VERSION}/keycloak-orcid-${KEYCLOAK_ORCID_VERSION}.jar
COPY package.json yarn.lock .yarnrc.yml ./
COPY .yarn/releases .yarn/releases
RUN corepack enable
RUN corepack install
RUN yarn install --immutable && \
yarn cache clean
COPY . .
RUN yarn build-keycloak-theme

RUN if [ "$KEYCLOAK_MAJOR_VERSION" -le 25 ]; then \
mv dist_keycloak/keycloak-theme-for-kc-22-to-25.jar loculus-theme.jar; \
else \
mv dist_keycloak/keycloak-theme-for-kc-all-other-versions.jar loculus-theme.jar; \
fi
# You can set an explicit version in vite.config.ts, see docs here:
# https://docs.keycloakify.dev/targeting-specific-keycloak-versions
# But for now this was the easiest way; In the future once we migrated away from KC<25 we can just get rid if this entirely

FROM alpine:3.19
RUN mkdir /output
COPY --from=builder /app/keycloak-orcid*.jar /output/
# /loculus.jar is the theme name set in vite.config.ts
COPY --from=builder /app/dist_keycloak/target/loculus*.jar /output/
COPY --from=builder /app/loculus-theme.jar /output/
RUN ls -alht /output
CMD sh -c 'cp /output/*.jar /destination/'
72 changes: 55 additions & 17 deletions keycloak/keycloakify/README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,74 @@
# Keycloakify theme
# Loculus Keycloakify theme

This is a keycloak theme, built with keycloakify, and branched from <https://github.com/keycloakify/keycloakify-starter>.
This theme is primarily used for:

We last synced with upstream on 2024-05-11.
- Adding ORCID support
- Adding a little tickbox to the registration process, as well as the IDP review page (after registering with ORCID).
- Minimal styling changes.
- Overriding the realm name in various places.

To preview in the storybook:
Changes are deliberately kept minimal to make it easier to maintain the theme.

Based on upstream commit: https://github.com/keycloakify/keycloakify-starter/commit/a543bc0f73e5874648cf6d907c88aba9b4b48536

## Quick start

```bash
nvm use
corepack install
yarn install --immutable
```

If you get:

```log
error This project's package.json defines "packageManager": "[email protected]". However the current global version of Yarn is 1.22.22.
```

then uninstall the global yarn version (e.g. `homebrew install yarn`) and try `yarn install` again.

## Testing the theme locally

### Storybook

For a quick preview of the theme, you can use Storybook:

```bash
nvm use # use the correct node version
yarn install --immutable # install dependencies (it's like npm install)
yarn storybook
```

To build a JAR and package it into an image that copies it to an output directory, build the Dockerfile. (This is done by CI).
Then visit http://localhost:6006/

### Use with actual dev Keycloak

Currently, only the login theme is implemented.
Not so useful right now as it doesn't show the right pages yet:

## Dependency documentation
```sh
npx keycloakify start-keycloak
```

(needs port 8080 to be available, so shut down your cluster if you have one running)

### Keycloakify
Then visit https://my-theme.keycloakify.dev (ensure ad blocker is disabled if you get an error).

https://docs.keycloakify.dev/
[Documentation](https://docs.keycloakify.dev/testing-your-theme)

### Keycloak ORCID
## How to customize the theme

https://github.com/eosc-kc/keycloak-orcid
[Documentation](https://docs.keycloakify.dev/customization-strategies)

## Installing yarn 4
## Building the theme

Prerequisite: node
You need to have [Maven](https://maven.apache.org/) installed to build the theme (Maven >= 3.1.1, Java >= 7).
The `mvn` command must be in the $PATH.

- macOS: `brew install maven`
- On Debian/Ubuntu: `sudo apt-get install maven`
- On Windows: `choco install openjdk` and `choco install maven` (Or download from [here](https://maven.apache.org/download.cgi))

```bash
corepack enable
corepack install yarn
npm run build-keycloak-theme
```

Note that by default Keycloakify generates multiple .jar files for different versions of Keycloak.
You can customize this behavior, see documentation [here](https://docs.keycloakify.dev/targeting-specific-keycloak-versions).
43 changes: 13 additions & 30 deletions keycloak/keycloakify/index.html
Original file line number Diff line number Diff line change
@@ -1,31 +1,14 @@
<!doctype html>
<html lang="en">

<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />

<!--
Notice the use of %BASE_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.

Unlike "/favicon.ico" or "favicon.ico", "%BASE_URL%favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
-->
<link rel="icon" type="image/svg+xml" sizes="32x32" href="%BASE_URL%favicon.svg">

<title>Loculus Authentication</title>

<meta name="keycloakify-ignore-start">
<script>console.log("This is logged Only in the main app, stripped out in the theme")</script>
<meta name="keycloakify-ignore-end">

</head>

<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>

</html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />

<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
</head>

<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
Loading
Loading