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 for Keycloak 24 #29

Merged
merged 2 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ Configuration is done per realm in the keycloak administration console
Steps:

1. Select realm to be configured
2. Go to *Authentication* tab on the left and under *Flows* select *Registration*
3. On the right hand of the screen click "Duplicate" button and create a copy of the *Registration* flow
4. Name the new flow
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 execution flow to be just below *Profile validation*; this is important such that all the form validation is done sequentially
10. Enable the new execution
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
Expand All @@ -45,7 +45,7 @@ Sample config values
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 *Profile validation* and above "Registration email domain validation"; this is important such that all the form validation is done sequentially
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
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<keycloak.version>21.1.1</keycloak.version>
<keycloak.version>24.0.4</keycloak.version>
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
package org.highmed.mailwhitelisting;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import javax.ws.rs.core.MultivaluedMap;
import jakarta.ws.rs.core.MultivaluedMap;
import org.keycloak.authentication.FormAction;
import org.keycloak.authentication.ValidationContext;
import org.keycloak.authentication.forms.RegistrationPage;
import org.keycloak.authentication.forms.RegistrationProfile;
import org.keycloak.authentication.forms.RegistrationUserCreation;
import org.keycloak.events.Details;
import org.keycloak.events.Errors;
import org.keycloak.models.utils.FormMessage;
Expand All @@ -19,8 +14,14 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
import java.util.stream.Collectors;


public class RegistrationProfileWithMailDomainCheck extends RegistrationProfile implements
public class RegistrationProfileWithMailDomainCheck extends RegistrationUserCreation implements
FormAction {

private static final Logger LOGGER = LoggerFactory
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
package org.highmed.mailwhitelisting.validator;

import jakarta.ws.rs.core.MultivaluedMap;
import org.keycloak.authentication.FormAction;
import org.keycloak.authentication.ValidationContext;
import org.keycloak.authentication.forms.RegistrationPage;
import org.keycloak.authentication.forms.RegistrationProfile;
import org.keycloak.authentication.forms.RegistrationUserCreation;
import org.keycloak.events.Errors;
import org.keycloak.models.utils.FormMessage;
import org.keycloak.provider.ProviderConfigProperty;
import org.keycloak.utils.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.ws.rs.core.MultivaluedMap;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;

public class RegistrationPageFieldLengthValidator extends RegistrationProfile implements FormAction {
public class RegistrationPageFieldLengthValidator extends RegistrationUserCreation implements FormAction {

private static final Logger LOGGER = LoggerFactory
.getLogger(RegistrationPageFieldLengthValidator.class);
Expand Down