Skip to content

Commit

Permalink
Merge pull request #26 from virtualidentityag/develop
Browse files Browse the repository at this point in the history
Remove diakonie specs
  • Loading branch information
mebo4b authored Aug 12, 2022
2 parents 2981d3a + f576881 commit 0ec6f8a
Show file tree
Hide file tree
Showing 40 changed files with 237 additions and 229 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>de.diakonie.onlineberatung</groupId>
<groupId>de.onlineberatung</groupId>
<artifactId>keycloak-otp-config-spi</artifactId>
<version>1.0-SNAPSHOT</version>

Expand Down
11 changes: 0 additions & 11 deletions src/main/java/de/diakonie/onlineberatung/otp/OtpMailSender.java

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
package de.diakonie.onlineberatung;
package de.onlineberatung;

import static java.util.Objects.isNull;
import static java.util.Objects.nonNull;

import de.diakonie.onlineberatung.authenticator.SessionAuthenticator;
import de.diakonie.onlineberatung.credential.AppOtpCredentialService;
import de.diakonie.onlineberatung.credential.CredentialContext;
import de.diakonie.onlineberatung.credential.MailOtpCredentialService;
import de.diakonie.onlineberatung.keycloak_otp_config_spi.keycloakextension.generated.web.model.Error;
import de.diakonie.onlineberatung.keycloak_otp_config_spi.keycloakextension.generated.web.model.OtpInfoDTO;
import de.diakonie.onlineberatung.keycloak_otp_config_spi.keycloakextension.generated.web.model.OtpSetupDTO;
import de.diakonie.onlineberatung.keycloak_otp_config_spi.keycloakextension.generated.web.model.OtpType;
import de.diakonie.onlineberatung.keycloak_otp_config_spi.keycloakextension.generated.web.model.Success;
import de.diakonie.onlineberatung.keycloak_otp_config_spi.keycloakextension.generated.web.model.SuccessWithEmail;
import de.diakonie.onlineberatung.mail.MailSendingException;
import de.diakonie.onlineberatung.otp.Otp;
import de.diakonie.onlineberatung.otp.OtpMailSender;
import de.diakonie.onlineberatung.otp.OtpService;
import de.onlineberatung.authenticator.SessionAuthenticator;
import de.onlineberatung.credential.AppOtpCredentialService;
import de.onlineberatung.credential.CredentialContext;
import de.onlineberatung.credential.MailOtpCredentialService;
import de.onlineberatung.keycloak_otp_config_spi.keycloakextension.generated.web.model.Error;
import de.onlineberatung.keycloak_otp_config_spi.keycloakextension.generated.web.model.OtpInfoDTO;
import de.onlineberatung.keycloak_otp_config_spi.keycloakextension.generated.web.model.OtpSetupDTO;
import de.onlineberatung.keycloak_otp_config_spi.keycloakextension.generated.web.model.OtpType;
import de.onlineberatung.keycloak_otp_config_spi.keycloakextension.generated.web.model.Success;
import de.onlineberatung.keycloak_otp_config_spi.keycloakextension.generated.web.model.SuccessWithEmail;
import de.onlineberatung.mail.MailSendingException;
import de.onlineberatung.otp.Otp;
import de.onlineberatung.otp.OtpMailSender;
import de.onlineberatung.otp.OtpService;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
Expand Down Expand Up @@ -44,7 +44,7 @@ public class RealmOtpResourceProvider implements RealmResourceProvider {
private static final String MISSING_CREDENTIAL_CONFIG = "no mail otp credentials configured";
private static final String MISSING_USERNAME_ERROR_DESCRIPTION = "username not found";
private static final String MISSING_EMAIL_ADDRESS_ERROR_DESCRIPTION = "email address of user not available";
private final static String FAILED_TO_SENT = "failed to send otp verification email";
private static final String FAILED_TO_SENT = "failed to send otp verification email";

private final KeycloakSession session;
private final SessionAuthenticator sessionAuthenticator;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package de.diakonie.onlineberatung;
package de.onlineberatung;

import static de.diakonie.onlineberatung.authenticator.OtpMailAuthenticatorFactory.OTP_CONFIG_ALIAS;
import static de.onlineberatung.authenticator.OtpMailAuthenticatorFactory.OTP_CONFIG_ALIAS;

import de.diakonie.onlineberatung.authenticator.BearerTokenSessionAuthenticator;
import de.diakonie.onlineberatung.credential.AppOtpCredentialService;
import de.diakonie.onlineberatung.credential.MailOtpCredentialProviderFactory;
import de.diakonie.onlineberatung.credential.MailOtpCredentialService;
import de.diakonie.onlineberatung.mail.DefaultMailSender;
import de.diakonie.onlineberatung.otp.MemoryOtpService;
import de.diakonie.onlineberatung.otp.RandomDigitsCodeGenerator;
import de.onlineberatung.authenticator.BearerTokenSessionAuthenticator;
import de.onlineberatung.credential.AppOtpCredentialService;
import de.onlineberatung.credential.MailOtpCredentialProviderFactory;
import de.onlineberatung.credential.MailOtpCredentialService;
import de.onlineberatung.mail.DefaultMailSender;
import de.onlineberatung.otp.MemoryOtpService;
import de.onlineberatung.otp.RandomDigitsCodeGenerator;
import java.time.Clock;
import org.keycloak.Config.Scope;
import org.keycloak.models.KeycloakSession;
Expand Down Expand Up @@ -55,4 +55,4 @@ public void close() {
public String getId() {
return ID;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.diakonie.onlineberatung.authenticator;
package de.onlineberatung.authenticator;

import static java.util.Objects.isNull;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.diakonie.onlineberatung.authenticator;
package de.onlineberatung.authenticator;

import static java.util.Arrays.asList;

Expand Down Expand Up @@ -73,14 +73,17 @@ public Authenticator create(KeycloakSession session) {

@Override
public void init(Config.Scope config) {
// unused
}

@Override
public void postInit(KeycloakSessionFactory factory) {
// unused
}

@Override
public void close() {
// unused
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package de.diakonie.onlineberatung.authenticator;
package de.onlineberatung.authenticator;

import static de.diakonie.onlineberatung.authenticator.OtpParameterAuthenticator.extractDecodedOtpParam;
import static de.diakonie.onlineberatung.keycloak_otp_config_spi.keycloakextension.generated.web.model.OtpType.EMAIL;
import static de.onlineberatung.authenticator.OtpParameterAuthenticator.extractDecodedOtpParam;
import static java.util.Objects.isNull;
import static java.util.Objects.nonNull;

import de.diakonie.onlineberatung.credential.CredentialContext;
import de.diakonie.onlineberatung.credential.MailOtpCredentialModel;
import de.diakonie.onlineberatung.credential.MailOtpCredentialService;
import de.diakonie.onlineberatung.keycloak_otp_config_spi.keycloakextension.generated.web.model.Challenge;
import de.diakonie.onlineberatung.mail.MailSendingException;
import de.diakonie.onlineberatung.otp.OtpMailSender;
import de.diakonie.onlineberatung.otp.OtpService;
import de.onlineberatung.credential.CredentialContext;
import de.onlineberatung.credential.MailOtpCredentialModel;
import de.onlineberatung.credential.MailOtpCredentialService;
import de.onlineberatung.keycloak_otp_config_spi.keycloakextension.generated.web.model.Challenge;
import de.onlineberatung.mail.MailSendingException;
import de.onlineberatung.otp.OtpMailSender;
import de.onlineberatung.otp.OtpService;
import de.onlineberatung.keycloak_otp_config_spi.keycloakextension.generated.web.model.OtpType;
import java.util.Collections;
import java.util.List;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
Expand Down Expand Up @@ -74,7 +75,7 @@ public boolean requiresUser() {

@Override
public void setRequiredActions(KeycloakSession session, RealmModel realm, UserModel user) {

// unused
}

private void sendOtpMail(MailOtpCredentialModel credentialModel, CredentialContext credContext,
Expand All @@ -93,7 +94,7 @@ private void sendOtpMail(MailOtpCredentialModel credentialModel, CredentialConte
try {
mailSender.sendOtpCode(otp, credContext);
var challengeResponse = new Challenge().error(INVALID_GRANT_ERROR)
.errorDescription("Missing totp").otpType(EMAIL);
.errorDescription("Missing totp").otpType(OtpType.EMAIL);
context.failure(AuthenticationFlowError.INVALID_CREDENTIALS,
Response.status(Status.BAD_REQUEST).entity(challengeResponse)
.type(MediaType.APPLICATION_JSON_TYPE).build());
Expand Down Expand Up @@ -177,7 +178,7 @@ public String getHelpText() {

@Override
public List<ProviderConfigProperty> getConfigProperties() {
return null;
return Collections.emptyList();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package de.diakonie.onlineberatung.authenticator;
package de.onlineberatung.authenticator;

import static java.util.Arrays.asList;

import de.diakonie.onlineberatung.credential.MailOtpCredentialProviderFactory;
import de.diakonie.onlineberatung.credential.MailOtpCredentialService;
import de.diakonie.onlineberatung.mail.DefaultMailSender;
import de.diakonie.onlineberatung.otp.MemoryOtpService;
import de.diakonie.onlineberatung.otp.RandomDigitsCodeGenerator;
import de.onlineberatung.credential.MailOtpCredentialProviderFactory;
import de.onlineberatung.credential.MailOtpCredentialService;
import de.onlineberatung.mail.DefaultMailSender;
import de.onlineberatung.otp.MemoryOtpService;
import de.onlineberatung.otp.RandomDigitsCodeGenerator;
import java.time.Clock;
import java.util.List;
import org.keycloak.Config;
Expand Down Expand Up @@ -89,14 +89,17 @@ public Authenticator create(KeycloakSession session) {

@Override
public void init(Config.Scope config) {
// unused
}

@Override
public void postInit(KeycloakSessionFactory factory) {
// unused
}

@Override
public void close() {
// unused
}

}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package de.diakonie.onlineberatung.authenticator;
package de.onlineberatung.authenticator;

import static de.diakonie.onlineberatung.keycloak_otp_config_spi.keycloakextension.generated.web.model.OtpType.APP;
import static java.util.Objects.isNull;

import de.diakonie.onlineberatung.keycloak_otp_config_spi.keycloakextension.generated.web.model.Challenge;
import de.onlineberatung.keycloak_otp_config_spi.keycloakextension.generated.web.model.Challenge;
import de.onlineberatung.keycloak_otp_config_spi.keycloakextension.generated.web.model.OtpType;
import java.util.Collections;
import java.util.List;
import javax.ws.rs.core.MediaType;
Expand All @@ -24,7 +24,7 @@ public class OtpParameterAuthenticator extends AbstractDirectGrantAuthenticator

public static final String ID = "otp-parameter-authenticator";

final AuthenticationExecutionModel.Requirement[] REQUIREMENT_CHOICES = {
static final AuthenticationExecutionModel.Requirement[] REQUIREMENT_CHOICES = {
AuthenticationExecutionModel.Requirement.REQUIRED};

@Override
Expand All @@ -38,7 +38,7 @@ public void authenticate(AuthenticationFlowContext context) {

if (otpOfRequest == null) {
Challenge challengeResponse = new Challenge().error("invalid_grant")
.errorDescription("Missing totp").otpType(APP);
.errorDescription("Missing totp").otpType(OtpType.APP);
context.failure(AuthenticationFlowError.INVALID_CREDENTIALS,
Response.status(Status.BAD_REQUEST).entity(challengeResponse)
.type(MediaType.APPLICATION_JSON_TYPE).build());
Expand Down Expand Up @@ -106,4 +106,4 @@ static String extractDecodedOtpParam(AuthenticationFlowContext context) {
otpParam = (isNull(otpParam)) ? inputData.getFirst("totp") : otpParam;
return otpParam;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.diakonie.onlineberatung.authenticator;
package de.onlineberatung.authenticator;

import org.keycloak.models.KeycloakSession;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.diakonie.onlineberatung.credential;
package de.onlineberatung.credential;

import org.keycloak.models.credential.OTPCredentialModel;
import org.keycloak.models.utils.CredentialValidation;
Expand Down Expand Up @@ -47,4 +47,4 @@ public void deleteCredentials(CredentialContext context) {
credentialModel -> CredentialHelper.deleteOTPCredential(context.getSession(),
context.getRealm(), context.getUser(), credentialModel.getId()));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.diakonie.onlineberatung.credential;
package de.onlineberatung.credential;

import java.util.Objects;
import org.keycloak.authentication.AuthenticationFlowContext;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.diakonie.onlineberatung.credential;
package de.onlineberatung.credential;

public class MailOtpCredentialData {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package de.diakonie.onlineberatung.credential;
package de.onlineberatung.credential;

import static org.keycloak.util.JsonSerialization.writeValueAsString;

import de.diakonie.onlineberatung.otp.Otp;
import de.onlineberatung.otp.Otp;
import java.io.IOException;
import java.time.Clock;
import org.jetbrains.annotations.NotNull;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package de.diakonie.onlineberatung.credential;
package de.onlineberatung.credential;

import de.diakonie.onlineberatung.RealmOtpResourceProvider;
import de.diakonie.onlineberatung.authenticator.OtpMailAuthenticator;
import de.onlineberatung.authenticator.OtpMailAuthenticator;
import java.time.Clock;
import org.jboss.logging.Logger;
import org.keycloak.credential.CredentialInput;
Expand All @@ -19,7 +18,7 @@
public class MailOtpCredentialProvider implements CredentialProvider<MailOtpCredentialModel>,
CredentialInputValidator {

private static final Logger logger = Logger.getLogger(RealmOtpResourceProvider.class);
private static final Logger logger = Logger.getLogger(MailOtpCredentialProvider.class);

private final KeycloakSession session;
private final Clock clock;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.diakonie.onlineberatung.credential;
package de.onlineberatung.credential;

import java.time.Clock;
import org.keycloak.credential.CredentialProviderFactory;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package de.diakonie.onlineberatung.credential;
package de.onlineberatung.credential;

import static java.util.Objects.isNull;
import static java.util.Objects.nonNull;

import de.diakonie.onlineberatung.otp.Otp;
import de.onlineberatung.otp.Otp;
import java.time.Clock;

public class MailOtpCredentialService {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.diakonie.onlineberatung.credential;
package de.onlineberatung.credential;

public class MailOtpSecretData {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.diakonie.onlineberatung.log;
package de.onlineberatung.log;

import java.util.Map;
import javax.ws.rs.core.Cookie;
Expand Down Expand Up @@ -145,6 +145,7 @@ private void logAdminEvent(AdminEvent adminEvent, boolean includeRepresentation)

@Override
public void close() {
// unused
}

private void setKeycloakContext(StringBuilder sb) {
Expand Down Expand Up @@ -173,4 +174,4 @@ private void setKeycloakContext(StringBuilder sb) {
sb.append("]");
}

}
}
Loading

0 comments on commit 0ec6f8a

Please sign in to comment.