Skip to content

Commit

Permalink
Merge pull request #10 from RedFroggy/upgradeToV19
Browse files Browse the repository at this point in the history
feat: upgrade to keycloak 19.0.x version
  • Loading branch information
dajay authored Sep 29, 2022
2 parents 0f7b39f + b2e7b29 commit b0a12ee
Show file tree
Hide file tree
Showing 12 changed files with 1,425 additions and 2,499 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name: Keycloak Verify email by code RedFroggy CI
on:
push:
branches:
- "**"
- "master"
- "main"
tags-ignore:
- "**"
pull_request:
Expand Down
50 changes: 25 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,36 @@ This [Keycloak](https://www.keycloak.org) plugin adds a required action to verif

## Compatibility

The version 15.x of this plugin is compatible with Keycloak `15.1.1` and higher.
The version 19.0.x of this plugin is compatible with Keycloak `19.0.x` and higher.

## Installation
## How to install?

The plugin installation is simple and can be done without a Keycloak server restart.
Download a release (*.jar file) that works with your Keycloak version from
the [list of releases](https://github.com/RedFroggy/keycloak-verify-email-by-code/releases).

* Download the latest release from
the [releases page](https://github.com/RedFroggy/keycloak-verify-email-by-code/releases)
* Copy the JAR file into the `standalone/deployments` directory in your Keycloak server's root
* Restart Keycloak (optional, hot deployment should work)
### Server

You can also clone the Github Repository and install the plugin locally with the following command:
Copy the jar to the `providers` folder and execute the following command:

```shell
${kc.home.dir}/bin/kc.sh build
```
$ mvn clean install wildfly:deploy
```

### Maven

You can also clone the Github Repository and install the plugin locally.

### Container image (Docker)

For Docker-based setups mount or copy the jar to `/opt/keycloak/providers`.

You may want to check [docker-compose.yml](docker-compose.yml) as an example.

## How to use it

### Requirements

Verify required action is deploy in keycloak. Got to {keycloak url}/auth/admin/master/console/#/server-info/providers.
Verify required action is deploy in keycloak. Got to {keycloak url}/admin/master/console/#/master/providers.

![server-info_providers](/assets/server-info_providers.png)

Expand Down Expand Up @@ -62,22 +70,14 @@ themes/mytheme/login
#### Code length and symbols

Verify email code is generated using `org.keycloak.common.util.RandomString`. By default generated code will be 8 characters long and will use alphanumeric symbols. You may customize this behavior using SPI configuration in your `standalone.xml` file:
- property `codeLength` is a numeric value representing the number of symbols, defaults to `8`
- property `codeSymbols` is a string value listing all accepted symbols, defaults to `RandomString.alphanum`

- property `code-length` is a numeric value representing the number of symbols, defaults to `8`
- property `code-symbols` is a string value listing all accepted symbols, defaults to `RandomString.alphanum`

e.g. configure action to generate a code of 6 digits :
```xml
<subsystem xmlns="urn:jboss:domain:keycloak-server:1.1">
[...]
<spi name="required-action">
<provider name="VERIFY_EMAIL_CODE" enabled="true">
<properties>
<property name="codeLength" value="6"/>
<property name="codeSymbols" value="0123456789"/>
</properties>
</provider>
</spi>
</subsystem>

```shell
bin/kc.[sh|bat] start --spi-required-action-VERIFY_EMAIL_CODE-code-length=6 --spi-required-action-VERIFY_EMAIL_CODE-code-symbols=0123456789
```

## Q&A
Expand Down
65 changes: 22 additions & 43 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,24 @@
version: '3'
version: '3.8'
services:
keycloak:
network_mode: host
build: .
command: [ "-b", "0.0.0.0",
"-c", "standalone.xml",
"-Dkeycloak.migration.realmName=redfroggy",
"-Dkeycloak.migration.usersExportStrategy=DIFFERENT_FILES",
"-Dkeycloak.migration.action=import",
"-Dkeycloak.migration.provider=dir",
"-Dkeycloak.migration.dir=/opt/jboss/keycloak/realm-config/dev",
"-Dkeycloak.migration.strategy=OVERWRITE_EXISTING",
'-Dkeycloak.profile.feature.upload_scripts=enabled',
"-Djboss.socket.binding.port-offset=1000" ]
volumes:
- ./realm-config:/opt/jboss/keycloak/realm-config
- ./standalone/configuration/standalone.xml:/opt/jboss/keycloak/standalone/configuration/standalone.xml
- ./src/main/resources/theme-resources/templates/login-verify-email-code.ftl:/opt/jboss/keycloak/themes/base/login/login-verify-email-code.ftl
environment:
- DB_VENDOR=h2
- DB_ADDR=localhost
- DB_DATABASE=keycloak
- DB_USER=keycloak
- DB_PASSWORD=keycloak
- DB_PORT=9132
- KEYCLOAK_USER=admin
- KEYCLOAK_PASSWORD=admin
- JDBC_PARAMS=connectTimeout=30
- PROXY_ADDRESS_FORWARDING=true
# - KEYCLOAK_LOGLEVEL=DEBUG
# ports:
# - 9080:9080
# - 9443:9443
# - 10990:10990
# dns:
# - 8.8.8.8
# - 8.8.4.4
keycloak:
image: quay.io/keycloak/keycloak:19.0.2
command: [ 'start-dev --import-realm',
'--debug',
'--spi-required-action-VERIFY_EMAIL_CODE-code-length=5' ]
volumes:
- ./realm-config/local:/opt/keycloak/data/import
- ./target/keycloak-verify-email-by-code-19.0.0-SNAPSHOT.jar:/opt/keycloak/providers/keycloak-verify-email-by-code.jar

#networks:
# default:
# ipam:
# driver: default
# config:
# - subnet: 172.28.0.0/16
environment:
- KC_DB=dev-file
- KEYCLOAK_ADMIN=admin
- KEYCLOAK_ADMIN_PASSWORD=admin
- DEBUG=true
- KC_FEATURES=scripts
- KC_HTTP_PORT=9080
- KC_HTTPS_PORT=9443
# If you want to expose these ports outside your dev PC,
# remove the "127.0.0.1:" prefix
ports:
- 127.0.0.1:9080:9080
- 127.0.0.1:9443:9443
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>fr.redfroggy.keycloak</groupId>
<artifactId>keycloak-verify-email-by-code</artifactId>
<version>15.2-SNAPSHOT</version>
<version>19.0.0-SNAPSHOT</version>

<name>${project.groupId}:${project.artifactId}</name>
<description>Action to verify email by code for Keycloak</description>
Expand Down Expand Up @@ -55,9 +55,9 @@
<wildfly.maven.plugin.version>2.0.2.Final</wildfly.maven.plugin.version>

<keycloak.version>19.0.2</keycloak.version>
<junit-jupiter.version>5.7.2</junit-jupiter.version>
<mockito.version>3.11.0</mockito.version>
<assertj.version>3.19.0</assertj.version>
<junit-jupiter.version>5.9.1</junit-jupiter.version>
<mockito.version>4.8.0</mockito.version>
<assertj.version>3.23.1</assertj.version>
</properties>

<build>
Expand Down
Loading

0 comments on commit b0a12ee

Please sign in to comment.