Add support to keycloak 18

This commit is contained in:
Nicolas Trangosi 2024-11-19 11:20:49 +01:00
parent dffb643b19
commit 61d2f2bcd1
7 changed files with 131 additions and 19 deletions
.gitignoreREADME.mdpom.xml
src
keycloak-v12-common/java/com/github/jpicht/keycloak/policy
keycloak-v15-common/java/com/github/jpicht/keycloak/policy
keycloak-v18-common/java/com/github/jpicht/keycloak/policy
keycloak-v18/java/com/github/jpicht/keycloak/policy

2
.gitignore vendored

@ -10,3 +10,5 @@ pom.xml.versionsBackup
# VS Code
.factorypath
.vscode
**/.idea/**

@ -1,5 +1,5 @@
# keycloak-group-password-policy
This keycloak extension (currenty developed and tested against version 6.0.1) aims to
This keycloak extension (currenty developed and tested against versions 6, 8-15, 18) aims to
create the possibility to assign additional password rules to user groups, extending the
rules attached to the realm, _not_ replacing them.
@ -8,7 +8,8 @@ It is available as a new type of password policy on the realm's password policy
## Installation
The extension can be installed just like any keycloak extension. Either copy it to the
`keycloak/standalone/deployments` folder, or load it via the jboss command line tool.
`keycloak/standalone/deployments` folder for JBoss deployments or in `keycloak/deployments`
for quarkus distributions, or load it via the jboss command line tool.
## Usage
There are multiple steps you will want to take to use this plugin. First, you need to determine

73
pom.xml

@ -12,7 +12,6 @@
<java.version>1.8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<keycloak.version>${keycloak.majorVersion}.0.0</keycloak.version>
<auto-service.version>1.0</auto-service.version>
</properties>
@ -57,12 +56,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.1</version>
<version>3.4.2</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.2.0</version>
<version>3.6.0</version>
</plugin>
</plugins>
</pluginManagement>
@ -71,15 +70,23 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<classifier>keycloak-v${keycloak.majorVersion}</classifier>
<archive>
<manifestEntries>
<!-- This is required in order for the classloader of this JAR to access the specified library at runtime -->
<Dependencies>org.keycloak.keycloak-services</Dependencies>
</manifestEntries>
</archive>
</configuration>
<executions>
<execution>
<id>>keycloak-v${keycloak.majorVersion}</id>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>keycloak-v${keycloak.majorVersion}</classifier>
<archive>
<manifestEntries>
<!-- This is required in order for the classloader of this JAR to access the specified library at runtime -->
<Dependencies>org.keycloak.keycloak-services</Dependencies>
</manifestEntries>
</archive>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
@ -114,9 +121,6 @@
</profile>
<profile>
<id>keycloak-v7</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<keycloak.majorVersion>7</keycloak.majorVersion>
</properties>
@ -390,5 +394,44 @@
</plugins>
</build>
</profile>
<profile>
<id>keycloak-v18</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<keycloak.majorVersion>18</keycloak.majorVersion>
<java.version>1.8</java.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-source-keycloak-v18</id>
<goals><goal>add-source</goal></goals>
<configuration>
<sources>
<source>${basedir}/src/keycloak-v6-common/java</source>
<source>${basedir}/src/keycloak-v8-common/java</source>
<source>${basedir}/src/keycloak-v9-common/java</source>
<source>${basedir}/src/keycloak-v10-common/java</source>
<source>${basedir}/src/keycloak-v11-common/java</source>
<source>${basedir}/src/keycloak-v12-common/java</source>
<source>${basedir}/src/keycloak-v13-common/java</source>
<source>${basedir}/src/keycloak-v14-common/java</source>
<source>${basedir}/src/keycloak-v15-common/java</source>
<source>${basedir}/src/keycloak-v18-common/java</source>
<source>${basedir}/src/keycloak-v18/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

@ -154,7 +154,7 @@ public abstract class FakeRealmV12 extends FakeRealmV11 {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void patchRealmLocalizationTexts(String locale, Map<String, String> localizationTexts) {
throw new UnsupportedOperationException("Not supported yet.");
}

@ -18,7 +18,7 @@ package com.github.jpicht.keycloak.policy;
import org.keycloak.models.ParConfig;
public class FakeRealmV15 extends FakeRealmV14 {
public abstract class FakeRealmV15 extends FakeRealmV14 {
@Override
public ParConfig getParPolicy() {

@ -0,0 +1,30 @@
/*
* Copyright 2021 Brian Long (brian@inteligr8.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jpicht.keycloak.policy;
import org.keycloak.models.ParConfig;
import java.util.Map;
public class FakeRealmV18 extends FakeRealmV15 {
@Override
public void createOrUpdateRealmLocalizationTexts(String locale, Map<String, String> localizationTexts) {
throw new UnsupportedOperationException("Not supported yet.");
}
}

@ -0,0 +1,36 @@
/*
* Copyright 2019 Julian Picht
* Copyright 2021 Brian Long (brian@inteligr8.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jpicht.keycloak.policy;
import org.keycloak.models.PasswordPolicy;
public class FakeRealm extends FakeRealmV18 {
private PasswordPolicy passwordPolicy;
@Override
public PasswordPolicy getPasswordPolicy() {
return passwordPolicy;
}
@Override
public void setPasswordPolicy(PasswordPolicy policy) {
passwordPolicy = policy;
}
}