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

Update Keycloak #32

Merged
merged 30 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
254e389
feat(NUM-1909): Extends email domain validation at register
Dec 6, 2021
d9d1b0a
Merge pull request #11 from NUM-Forschungsdatenplattform/feature/NUM-…
alexkarle Dec 7, 2021
56ec70b
use keycloack 21.0.1
crisdelta Mar 7, 2023
0daa508
Merge pull request #12 from NUM-Forschungsdatenplattform/feature/NUM-…
crisdelta Mar 15, 2023
b266f55
NUM-2182 custom validator for field length
crisdelta May 23, 2023
a788aa8
code format
crisdelta May 24, 2023
d2a3350
update README
crisdelta May 24, 2023
ed573db
Merge pull request #13 from NUM-Forschungsdatenplattform/bugfix/NUM-2…
crisdelta May 24, 2023
a44ffe7
update keycloak version for custom plugin
crisdelta Jun 14, 2023
ded94e8
Merge pull request #14 from NUM-Forschungsdatenplattform/bugfix/NUM-2…
crisdelta Jun 14, 2023
253f926
add github pipeline (#15)
mafasva Mar 12, 2024
b83c9a2
add release pipeline
ramueSVA Mar 18, 2024
53067c3
11 -> 17
ramueSVA Mar 21, 2024
dd1729d
build(deps): Bump org.apache.maven.plugins:maven-assembly-plugin
dependabot[bot] Mar 25, 2024
40d2088
Update release.yml
ramueSVA Mar 25, 2024
0fff790
Merge pull request #18 from NUM-Forschungsdatenplattform/feature/add-…
romanschneidersva Mar 25, 2024
da85315
changed package structure and groupid in pom.xml
ramueSVA Apr 2, 2024
fbfe3b9
Feature/remove vitagroup signature (#23)
ramueSVA Apr 2, 2024
8bbce54
new tagging pipeline (#22)
ramueSVA Apr 2, 2024
ba5f481
remove docker from CI
mafasva Apr 2, 2024
fbe615f
Merge pull request #24 from NUM-Forschungsdatenplattform/feature/with…
ramueSVA Apr 2, 2024
b67bd9a
fix mailwhitelisting in package structure and change license (#25)
ramueSVA Apr 11, 2024
6b6e010
changed release trigger (#26)
ramueSVA Apr 17, 2024
7596dbb
Update to Keycloak 24
askask Jun 3, 2024
5c69358
Update README for Keycloak 24
askask Jun 3, 2024
0041896
Merge pull request #29 from askask/develop
ramueSVA Sep 17, 2024
7e99e67
Bump keycloak.version from 24.0.4 to 25.0.5
dependabot[bot] Sep 17, 2024
21aa194
Merge pull request #20 from NUM-Forschungsdatenplattform/dependabot/m…
ramueSVA Sep 17, 2024
d4ac6c5
Merge pull request #31 from NUM-Forschungsdatenplattform/dependabot/m…
ramueSVA Sep 17, 2024
8696760
Update pom.xml
ramueSVA Sep 17, 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
19 changes: 19 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: maven
directory: "/"
schedule:
interval: weekly
day: monday
time: "04:00"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: weekly
day: monday
time: "03:00"
36 changes: 36 additions & 0 deletions .github/workflows/build-for-development.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Build for development

on:
push:
branches: [ 'feature/**', 'dependabot/**' ]
pull_request_target:
branches: [ develop, main ]
types: [ ready_for_review, closed ]

jobs:
scan:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'
- name: Run verify
run: mvn verify
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
ignore-unfixed: true
format: 'sarif'
output: 'trivy-results.sarif'
severity: 'CRITICAL,HIGH'
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: 'trivy-results.sarif'
85 changes: 85 additions & 0 deletions .github/workflows/create-release-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Create release branch

on:
workflow_dispatch:
branches: [ develop ]
inputs:
release:
description: 'Type of the release.'
type: choice
options:
- major
- minor
- patch
default: minor

jobs:
create_branch:
if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/develop'

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: main
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'
- name: Create version
id: createVersion
run: |
CURRENT_VERSION=$(mvn -q -Dexec.executable='echo' -Dexec.args='${project.version}' --non-recursive exec:exec)
echo "Current version: $CURRENT_VERSION"
MAJOR=`echo $CURRENT_VERSION | cut -d. -f1`
MINOR=`echo $CURRENT_VERSION | cut -d. -f2`
PATCH=`echo $CURRENT_VERSION | cut -d. -f3 | cut -d- -f1`

if [ ${{ inputs.release }} == 'major' ]; then
MAJOR=$((MAJOR+1))
MINOR=0
PATCH=0
elif [ ${{ inputs.release }} == 'minor' ]; then
MINOR=$((MINOR+1))
PATCH=0
else
PATCH=$((PATCH+1))
fi

VERSION=${MAJOR}.${MINOR}.${PATCH}

echo
echo "Release version: $VERSION"

echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"

- name: Checkout
uses: actions/checkout@v4
- name: Create release branch
env:
VERSION: ${{ steps.createVersion.outputs.VERSION }}
run: |
git config --global user.email "github-actions@example.com"
git config --global user.name "Github Actions"

git branch release/$VERSION
git checkout release/$VERSION

mvn versions:set -DnewVersion=${VERSION}-SNAPSHOT versions:commit
git add pom.xml
git commit -m "updated project version to ${VERSION}"

git push --set-upstream origin release/$VERSION

wrong_branch:
if: github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/develop'

runs-on: ubuntu-latest

steps:
- name: ERROR
run: echo 'This workflow only runs on develop branch!'
115 changes: 115 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: release

on:
workflow_dispatch:
branches: [ 'release/**' ]

env:
RELEASE_VERSION: ''
DEV_VERSION: ''

jobs:

read_version:
runs-on: ubuntu-latest

outputs:
DEV_VERSION: ${{ steps.createVersion.outputs.DEV_VERSION}}
RELEASE_VERSION: ${{ steps.createVersion.outputs.RELEASE_VERSION}}

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'
- name: Create new development version
id: createVersion
run: |
CURRENT_VERSION=$(mvn -q -Dexec.executable='echo' -Dexec.args='${project.version}' --non-recursive exec:exec)
RELEASE_VERSION=`echo $CURRENT_VERSION | cut -d- -f1`
echo "Current version: $CURRENT_VERSION"
MAJOR=`echo $CURRENT_VERSION | cut -d. -f1`
MINOR=`echo $CURRENT_VERSION | cut -d. -f2`

DEV_VERSION=${MAJOR}.$((MINOR+1)).0-SNAPSHOT

echo
echo "Release version: $RELEASE_VERSION"
echo "Develop version: $DEV_VERSION"

echo "RELEASE_VERSION=${RELEASE_VERSION}" >> "$GITHUB_OUTPUT"
echo "DEV_VERSION=${DEV_VERSION}" >> "$GITHUB_OUTPUT"

echo "### :rocket: ${RELEASE_VERSION}" >> $GITHUB_STEP_SUMMARY

update_dev:
needs: read_version
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'
- name: Create branch to update develop version
env:
DEV_VERSION: ${{ needs.read_version.outputs.DEV_VERSION }}
run: |
git config --global user.email "noreply@github.com"
git config --global user.name "Github Actions"

git branch feature/update_develop_${DEV_VERSION}
git checkout feature/update_develop_${DEV_VERSION}

mvn versions:set -DnewVersion=${DEV_VERSION} versions:commit
git commit -am "updated development version to ${DEV_VERSION}"

git push --set-upstream origin feature/update_develop_${DEV_VERSION}

- name: Create PR to merge changes to Develop and update Version
env:
RELEASE_VERSION: ${{ needs.read_version.outputs.RELEASE_VERSION }}
GH_TOKEN: ${{ github.token }}
run: |
PR_URL=`gh pr create --draft -B develop --title "Merge release branch '${RELEASE_VERSION}' back to develop" --body "Merge release branch '${RELEASE_VERSION}' back to develop"`
echo $PR_URL

release:
needs: read_version
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'
- name: Set the release version
env:
RELEASE_VERSION: ${{ needs.read_version.outputs.RELEASE_VERSION }}
run: |
git config --global user.email "noreply@github.com"
git config --global user.name "Github Actions"

mvn versions:set -DremoveSnapshot versions:commit
git commit -am "updated release version to ${RELEASE_VERSION}"
git push

- name: Create PR to merge release branch to main
env:
RELEASE_VERSION: ${{ needs.read_version.outputs.RELEASE_VERSION }}
GH_TOKEN: ${{ github.token }}
run: |
PR_URL=`gh pr create --draft -B main --title "Merge release branch '${RELEASE_VERSION}'" --body "Merge release branch '${RELEASE_VERSION}'"`
echo $PR_URL
33 changes: 33 additions & 0 deletions .github/workflows/weekly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Weekly

on:
schedule:
- cron: '0 23 * * 1'

jobs:
scan:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'
- name: Run verify
run: mvn verify
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
ignore-unfixed: true
format: 'sarif'
output: 'trivy-results.sarif'
severity: 'CRITICAL,HIGH'
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: 'trivy-results.sarif'
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright [2024] [HiGHmed e.V.]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
49 changes: 31 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@


# mail-whitelisting
# mail-whitelisting and field length validation for registration page

### Deployment

Copy jar to ```/opt/jboss/keycloak/standalone/deployments```
1. Copy jar to ```/keycloak-<version>/providers```
2. Run the following command to complete the installation:
```
${kc.home.dir}/bin/kc.sh build
```

### Configuration

Expand All @@ -13,32 +17,41 @@ Configuration is done per realm in the keycloak administration console
Steps:

1. Select realm to be configured
1. Go to *Authentication* tab on the left and under *Flows* select *Registration*
1. On the right hand of the screen click copy button and create a copy of the *Registration* flow
1. Name the new flow
1. In the *Flows* tab, select the newly created registration flow in order to configure it
1. Under *Actions*, under the root execution, add a new execution
1. In the providers list, select the plugin name *Registration email domain validation*
1. Save
1. Move the newly added execution flow to be just below *Profile validation*; this is important such that all the form validation is done sequentially
1. Enable the new execution
1. On the right there is a config button where the plugin is to be configured
1. Under *Bindings* tab next to the *Flows* tab, the newly created registration flow needs to be selected instead of the default *Registration*
2. Go to *Authentication* tab on the left and under *Flows* select *registration*
3. On the right hand of the screen select "Duplicate" from the "Action" menu and create a copy of the *registration* flow
4. Name the new flow "registration-with-whitelisting"
5. In the *Flows* tab, select the newly created registration flow in order to configure it
6. Under *Add* (+ icon), add a new step
7. In the providers list, select the plugin name *Registration email domain validation*
8. Save
9. Move the newly added step to be just below *Registration User Profile Creation*; this is important such that all the form validation is done sequentially
10. Set the new step to "Required"
11. On the right there is a config button (gear settings) where the plugin is to be configured
12. Under *Flows* tab, the newly created registration flow needs to be selected instead of the default *Registration*
13. Click on settings (right corner with 3 verical dots) and choose bind flow
14. Select registration flow
15. Default *Registration* flow should appear as 'Not in use' now

Sample config values

* Num portal uri: http://host.docker.internal:8090/organization/domains
* Token uri: https://keycloak.dev.num-codex.de/auth/realms/crr/protocol/openid-connect/token
* Client id: 89dddc8f-0f25-4faf-a58d-6cda681f6ed3
* Secret: num-portal
* Client id: num-portal
* Client secret: <num-portal-client-secret>
* Error message:

```<div>Invalid email address. Please contact us at: <a href="mailto:john.doe@example.com">John Doe</a></div>```

```<span class="message-text" style = "display:block">Your email-address is not allowed. Please contact our support at:<a href="mailto:num-support@gwdg.de" style="color: white;font-weight: bold;padding-left: 10px;">num-support@gwdg.de</a> and inform about this message.</span>```

Steps to configure field length validator plugin
1. Repeat step 1-6 but for previously created flow (so you have to duplicate "registration-with-whitelisting" flow)
2. In the providers list, select the plugin name *NUM Custom registration page field length validator*
3. Move the newly added execution flow to be just below *Registration User Profile Creation* and above "Registration email domain validation"; this is important such that all the form validation is done sequentially
4. save
5. On the right there is a config button (gear settings) where the plugin is to be configured (first and last name maximum length should be set to 50, department to 100 and notes to 255)
6. repeat 12-13 from above
### License

Copyright 2021 vitagroup AG
Copyright 2024 HiGHmed e.V.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Loading