Merge pull request #10 from mmadoo/keycloak18

Add support to keycloak 18
This commit is contained in:
Julian Picht
2024-11-20 16:59:05 +01:00
committed by GitHub
7 changed files with 132 additions and 20 deletions

2
.gitignore vendored
View File

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

View File

@@ -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
@@ -44,7 +45,7 @@ For example:
[`length(8) and digits(2) and lowerCase(2) and upperCase(2) and specialChars(2) and notUsername()`](https://github.com/keycloak/keycloak/blob/6.0.1/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/policy/PasswordPolicyTest.java#L243)
The [policies provided with KeyCloak](https://www.keycloak.org/docs/6.0/server_admin/#password-policy-types) are:
The [policies provided with KeyCloak](https://www.keycloak.org/docs/latest/server_admin/#authentication-operations) are:
| Identifier | Parameter description | Tested |
| ------------- |:------------------------------------ | ------ |

55
pom.xml
View File

@@ -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,6 +70,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>>keycloak-v${keycloak.majorVersion}</id>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>keycloak-v${keycloak.majorVersion}</classifier>
<archive>
@@ -80,6 +85,8 @@
</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>

View File

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

View File

@@ -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() {

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