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

2
.gitignore vendored
View File

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

View File

@@ -1,5 +1,5 @@
# keycloak-group-password-policy # 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 create the possibility to assign additional password rules to user groups, extending the
rules attached to the realm, _not_ replacing them. 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 ## Installation
The extension can be installed just like any keycloak extension. Either copy it to the 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 ## Usage
There are multiple steps you will want to take to use this plugin. First, you need to determine There are multiple steps you will want to take to use this plugin. First, you need to determine

55
pom.xml
View File

@@ -12,7 +12,6 @@
<java.version>1.8</java.version> <java.version>1.8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source> <maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target> <maven.compiler.target>${java.version}</maven.compiler.target>
<keycloak.version>${keycloak.majorVersion}.0.0</keycloak.version> <keycloak.version>${keycloak.majorVersion}.0.0</keycloak.version>
<auto-service.version>1.0</auto-service.version> <auto-service.version>1.0</auto-service.version>
</properties> </properties>
@@ -57,12 +56,12 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId> <artifactId>maven-jar-plugin</artifactId>
<version>3.1.1</version> <version>3.4.2</version>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.codehaus.mojo</groupId> <groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId> <artifactId>build-helper-maven-plugin</artifactId>
<version>3.2.0</version> <version>3.6.0</version>
</plugin> </plugin>
</plugins> </plugins>
</pluginManagement> </pluginManagement>
@@ -71,6 +70,12 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId> <artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>>keycloak-v${keycloak.majorVersion}</id>
<goals>
<goal>jar</goal>
</goals>
<configuration> <configuration>
<classifier>keycloak-v${keycloak.majorVersion}</classifier> <classifier>keycloak-v${keycloak.majorVersion}</classifier>
<archive> <archive>
@@ -80,6 +85,8 @@
</manifestEntries> </manifestEntries>
</archive> </archive>
</configuration> </configuration>
</execution>
</executions>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
@@ -114,9 +121,6 @@
</profile> </profile>
<profile> <profile>
<id>keycloak-v7</id> <id>keycloak-v7</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties> <properties>
<keycloak.majorVersion>7</keycloak.majorVersion> <keycloak.majorVersion>7</keycloak.majorVersion>
</properties> </properties>
@@ -390,5 +394,44 @@
</plugins> </plugins>
</build> </build>
</profile> </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> </profiles>
</project> </project>

View File

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

View File

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

View File

@@ -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.");
}
}

View File

@@ -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;
}
}