-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Extract email verification check
- Loading branch information
1 parent
c704ee5
commit a6206df
Showing
6 changed files
with
51 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
.../keycloak/authentication/hidpd/discovery/orgs/email/OrgsEmailHomeIdpDiscovererConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package de.sventorben.keycloak.authentication.hidpd.discovery.orgs.email; | ||
|
||
import org.keycloak.models.AuthenticatorConfigModel; | ||
import org.keycloak.provider.ProviderConfigProperty; | ||
import org.keycloak.provider.ProviderConfigurationBuilder; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import static org.keycloak.provider.ProviderConfigProperty.BOOLEAN_TYPE; | ||
import static org.keycloak.provider.ProviderConfigProperty.STRING_TYPE; | ||
|
||
final class OrgsEmailHomeIdpDiscovererConfig { | ||
|
||
private static final String FORWARD_UNVERIFIED_ATTRIBUTE = "forwardUnverifiedEmail"; | ||
|
||
private static final ProviderConfigProperty FORWARD_UNVERIFIED_PROPERTY = new ProviderConfigProperty( | ||
FORWARD_UNVERIFIED_ATTRIBUTE, | ||
"Forward users with unverified email", | ||
"If 'User attribute' is set to 'email', whether to forward existing user if user's email is not verified.", | ||
BOOLEAN_TYPE, | ||
false, | ||
false); | ||
|
||
static final List<ProviderConfigProperty> CONFIG_PROPERTIES = ProviderConfigurationBuilder.create() | ||
.property(FORWARD_UNVERIFIED_PROPERTY) | ||
.build(); | ||
private final AuthenticatorConfigModel authenticatorConfigModel; | ||
|
||
public OrgsEmailHomeIdpDiscovererConfig(AuthenticatorConfigModel authenticatorConfigModel) { | ||
this.authenticatorConfigModel = authenticatorConfigModel; | ||
} | ||
|
||
boolean forwardUserWithUnverifiedEmail() { | ||
return Optional.ofNullable(authenticatorConfigModel) | ||
.map(it -> Boolean.parseBoolean(it.getConfig().getOrDefault(FORWARD_UNVERIFIED_ATTRIBUTE, "false"))) | ||
.orElse(false); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters