diff --git a/streampipes-commons/src/main/java/org/apache/streampipes/commons/constants/Envs.java b/streampipes-commons/src/main/java/org/apache/streampipes/commons/constants/Envs.java
index 672014852e..00765b76b5 100644
--- a/streampipes-commons/src/main/java/org/apache/streampipes/commons/constants/Envs.java
+++ b/streampipes-commons/src/main/java/org/apache/streampipes/commons/constants/Envs.java
@@ -42,6 +42,8 @@ public enum Envs {
SP_CLIENT_USER("SP_CLIENT_USER", DefaultEnvValues.INITIAL_CLIENT_USER_DEFAULT),
SP_CLIENT_SECRET("SP_CLIENT_SECRET", DefaultEnvValues.INITIAL_CLIENT_SECRET_DEFAULT),
SP_ENCRYPTION_PASSCODE("SP_ENCRYPTION_PASSCODE", DefaultEnvValues.DEFAULT_ENCRYPTION_PASSCODE),
+ SP_OAUTH_ENABLED("SP_OAUTH_ENABLED", "false"),
+ SP_OAUTH_REDIRECT_URI("SP_OAUTH_REDIRECT_URI"),
SP_DEBUG("SP_DEBUG", "false"),
SP_MAX_WAIT_TIME_AT_SHUTDOWN("SP_MAX_WAIT_TIME_AT_SHUTDOWN"),
diff --git a/streampipes-commons/src/main/java/org/apache/streampipes/commons/environment/DefaultEnvironment.java b/streampipes-commons/src/main/java/org/apache/streampipes/commons/environment/DefaultEnvironment.java
index 463a3a1d3e..5b6d5428d6 100644
--- a/streampipes-commons/src/main/java/org/apache/streampipes/commons/environment/DefaultEnvironment.java
+++ b/streampipes-commons/src/main/java/org/apache/streampipes/commons/environment/DefaultEnvironment.java
@@ -19,10 +19,14 @@
package org.apache.streampipes.commons.environment;
import org.apache.streampipes.commons.constants.Envs;
+import org.apache.streampipes.commons.environment.model.OAuthConfiguration;
+import org.apache.streampipes.commons.environment.parser.OAuthConfigurationParser;
import org.apache.streampipes.commons.environment.variable.BooleanEnvironmentVariable;
import org.apache.streampipes.commons.environment.variable.IntEnvironmentVariable;
import org.apache.streampipes.commons.environment.variable.StringEnvironmentVariable;
+import java.util.List;
+
public class DefaultEnvironment implements Environment {
@Override
@@ -174,6 +178,21 @@ public StringEnvironmentVariable getEncryptionPasscode() {
return new StringEnvironmentVariable(Envs.SP_ENCRYPTION_PASSCODE);
}
+ @Override
+ public BooleanEnvironmentVariable getOAuthEnabled() {
+ return new BooleanEnvironmentVariable(Envs.SP_OAUTH_ENABLED);
+ }
+
+ @Override
+ public StringEnvironmentVariable getOAuthRedirectUri() {
+ return new StringEnvironmentVariable(Envs.SP_OAUTH_REDIRECT_URI);
+ }
+
+ @Override
+ public List getOAuthConfigurations() {
+ return new OAuthConfigurationParser().parse(System.getenv());
+ }
+
@Override
public StringEnvironmentVariable getKafkaRetentionTimeMs() {
return new StringEnvironmentVariable(Envs.SP_KAFKA_RETENTION_MS);
diff --git a/streampipes-commons/src/main/java/org/apache/streampipes/commons/environment/Environment.java b/streampipes-commons/src/main/java/org/apache/streampipes/commons/environment/Environment.java
index aabae364b4..1a72910522 100644
--- a/streampipes-commons/src/main/java/org/apache/streampipes/commons/environment/Environment.java
+++ b/streampipes-commons/src/main/java/org/apache/streampipes/commons/environment/Environment.java
@@ -18,10 +18,13 @@
package org.apache.streampipes.commons.environment;
+import org.apache.streampipes.commons.environment.model.OAuthConfiguration;
import org.apache.streampipes.commons.environment.variable.BooleanEnvironmentVariable;
import org.apache.streampipes.commons.environment.variable.IntEnvironmentVariable;
import org.apache.streampipes.commons.environment.variable.StringEnvironmentVariable;
+import java.util.List;
+
public interface Environment {
BooleanEnvironmentVariable getSpDebug();
@@ -91,6 +94,12 @@ public interface Environment {
StringEnvironmentVariable getEncryptionPasscode();
+ BooleanEnvironmentVariable getOAuthEnabled();
+
+ StringEnvironmentVariable getOAuthRedirectUri();
+
+ List getOAuthConfigurations();
+
// Messaging
StringEnvironmentVariable getKafkaRetentionTimeMs();
diff --git a/streampipes-commons/src/main/java/org/apache/streampipes/commons/environment/model/OAuthConfiguration.java b/streampipes-commons/src/main/java/org/apache/streampipes/commons/environment/model/OAuthConfiguration.java
new file mode 100644
index 0000000000..7ab566f460
--- /dev/null
+++ b/streampipes-commons/src/main/java/org/apache/streampipes/commons/environment/model/OAuthConfiguration.java
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.streampipes.commons.environment.model;
+
+public class OAuthConfiguration {
+
+ private String authorizationUri;
+ private String clientName;
+ private String clientId;
+ private String clientSecret;
+ private String fullNameAttributeName;
+ private String issuerUri;
+ private String jwkSetUri;
+ private String registrationId;
+ private String registrationName;
+ private String[] scopes;
+ private String tokenUri;
+ private String userInfoUri;
+ private String emailAttributeName;
+ private String userIdAttributeName;
+
+
+ public String getRegistrationId() {
+ return registrationId;
+ }
+
+ public void setRegistrationId(String registrationId) {
+ this.registrationId = registrationId;
+ }
+
+ public String[] getScopes() {
+ return scopes;
+ }
+
+ public void setScopes(String[] scopes) {
+ this.scopes = scopes;
+ }
+
+ public String getAuthorizationUri() {
+ return authorizationUri;
+ }
+
+ public void setAuthorizationUri(String authorizationUri) {
+ this.authorizationUri = authorizationUri;
+ }
+
+ public String getTokenUri() {
+ return tokenUri;
+ }
+
+ public void setTokenUri(String tokenUri) {
+ this.tokenUri = tokenUri;
+ }
+
+ public String getJwkSetUri() {
+ return jwkSetUri;
+ }
+
+ public void setJwkSetUri(String jwkSetUri) {
+ this.jwkSetUri = jwkSetUri;
+ }
+
+ public String getIssuerUri() {
+ return issuerUri;
+ }
+
+ public void setIssuerUri(String issuerUri) {
+ this.issuerUri = issuerUri;
+ }
+
+ public String getUserInfoUri() {
+ return userInfoUri;
+ }
+
+ public void setUserInfoUri(String userInfoUri) {
+ this.userInfoUri = userInfoUri;
+ }
+
+ public String getClientName() {
+ return clientName;
+ }
+
+ public void setClientName(String clientName) {
+ this.clientName = clientName;
+ }
+
+ public String getClientId() {
+ return clientId;
+ }
+
+ public void setClientId(String clientId) {
+ this.clientId = clientId;
+ }
+
+ public String getClientSecret() {
+ return clientSecret;
+ }
+
+ public void setClientSecret(String clientSecret) {
+ this.clientSecret = clientSecret;
+ }
+
+ public String getEmailAttributeName() {
+ return emailAttributeName;
+ }
+
+ public void setEmailAttributeName(String emailAttributeName) {
+ this.emailAttributeName = emailAttributeName;
+ }
+
+ public String getFullNameAttributeName() {
+ return fullNameAttributeName;
+ }
+
+ public void setFullNameAttributeName(String fullNameAttributeName) {
+ this.fullNameAttributeName = fullNameAttributeName;
+ }
+
+ public String getUserIdAttributeName() {
+ return userIdAttributeName;
+ }
+
+ public void setUserIdAttributeName(String userIdAttributeName) {
+ this.userIdAttributeName = userIdAttributeName;
+ }
+
+ public String getRegistrationName() {
+ return registrationName;
+ }
+
+ public void setRegistrationName(String registrationName) {
+ this.registrationName = registrationName;
+ }
+}
diff --git a/streampipes-commons/src/main/java/org/apache/streampipes/commons/environment/parser/OAuthConfigurationParser.java b/streampipes-commons/src/main/java/org/apache/streampipes/commons/environment/parser/OAuthConfigurationParser.java
new file mode 100644
index 0000000000..48168566d2
--- /dev/null
+++ b/streampipes-commons/src/main/java/org/apache/streampipes/commons/environment/parser/OAuthConfigurationParser.java
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.streampipes.commons.environment.parser;
+
+import org.apache.streampipes.commons.environment.model.OAuthConfiguration;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * The {@code OAuthConfigurationParser} class is responsible for parsing OAuth provider configurations
+ * from environment variables and converting them into a list of {@link OAuthConfiguration} objects.
+ *
+ * This class expects the environment variables to follow a specific naming convention:
+ * {@code SP_OAUTH_{provider}_{settings}}. The parser identifies each provider by its unique
+ * identifier (e.g., "github" or "azure") and maps the settings (such as "CLIENT_ID", "CLIENT_SECRET")
+ * to their corresponding properties in the {@link OAuthConfiguration} object.
+ *
+ * Since environment variables cannot be structured as lists, the configuration for each provider
+ * is derived from prefixed variables. For example, settings for a provider "github" could be
+ * specified as:
+ *
+ * - SP_OAUTH_GITHUB_CLIENT_ID=example-client-id
+ * - SP_OAUTH_GITHUB_CLIENT_SECRET=example-client-secret
+ * - ...
+ *
+ * The parser then groups these settings into a {@link OAuthConfiguration} object for "github".
+ */
+public class OAuthConfigurationParser {
+
+ private static final Logger LOG = LoggerFactory.getLogger(OAuthConfigurationParser.class);
+
+
+ private static final String OAUTH_PREFIX = "SP_OAUTH_PROVIDER";
+
+ public List parse(Map env) {
+ Map oAuthConfigurationsMap = new HashMap<>();
+
+
+ env.forEach((key, value) -> {
+ if (key.startsWith(OAUTH_PREFIX)) {
+ parseEnvironmentVariable(key, value, oAuthConfigurationsMap);
+ }
+ });
+
+ return new ArrayList<>(oAuthConfigurationsMap.values());
+ }
+
+ private void parseEnvironmentVariable(
+ String key,
+ String value,
+ Map oAuthConfigurationsMap
+ ) {
+ var parts = getParts(key);
+ if (parts.length >= 5) {
+ // containst the identifier of the provider (e.g. azure, github, ...)
+ var registrationId = getRegistrationId(parts);
+ var settingName = getSettingName(parts);
+
+ var oAuthConfiguration = getOrCreateOAuthConfiguration(oAuthConfigurationsMap, registrationId);
+ oAuthConfiguration.setRegistrationId(registrationId);
+
+ switch (settingName) {
+ case "AUTHORIZATION_URI" -> oAuthConfiguration.setAuthorizationUri(value);
+ case "CLIENT_NAME" -> oAuthConfiguration.setClientName(value);
+ case "CLIENT_ID" -> oAuthConfiguration.setClientId(value);
+ case "CLIENT_SECRET" -> oAuthConfiguration.setClientSecret(value);
+ case "FULL_NAME_ATTRIBUTE_NAME" -> oAuthConfiguration.setFullNameAttributeName(value);
+ case "ISSUER_URI" -> oAuthConfiguration.setIssuerUri(value);
+ case "JWK_SET_URI" -> oAuthConfiguration.setJwkSetUri(value);
+ case "SCOPES" -> oAuthConfiguration.setScopes(value.split(","));
+ case "TOKEN_URI" -> oAuthConfiguration.setTokenUri(value);
+ case "USER_INFO_URI" -> oAuthConfiguration.setUserInfoUri(value);
+ case "EMAIL_ATTRIBUTE_NAME" -> oAuthConfiguration.setEmailAttributeName(value);
+ case "USER_ID_ATTRIBUTE_NAME" -> oAuthConfiguration.setUserIdAttributeName(value);
+ case "NAME" -> oAuthConfiguration.setRegistrationName(value);
+ default -> LOG.warn(
+ "Unknown setting {} for oauth configuration in environment variable {}",
+ settingName,
+ key
+ );
+ }
+ } else {
+ LOG.warn("Invalid environment variable for oauth configuration: {}", key);
+ }
+ }
+
+ private static String[] getParts(String key) {
+ return key.split("_");
+ }
+
+ private static String getSettingName(String[] parts) {
+ return String.join("_", Arrays.copyOfRange(parts, 4, parts.length));
+ }
+
+ private static String getRegistrationId(String[] parts) {
+ return parts[3].toLowerCase();
+ }
+
+ /**
+ * Retrieves an existing OAuthConfiguration for the given providerId or creates a new one if it does not exist.
+ *
+ * @param oAuthConfigurationsMap The map containing existing OAuthConfiguration objects.
+ * @param registrationId The identifier of the OAuth provider.
+ * @return The existing or newly created OAuthConfiguration for the given providerId.
+ */
+ private OAuthConfiguration getOrCreateOAuthConfiguration(
+ Map oAuthConfigurationsMap,
+ String registrationId
+ ) {
+ var oAuthConfiguration = oAuthConfigurationsMap.computeIfAbsent(registrationId, k -> new OAuthConfiguration());
+ oAuthConfiguration.setRegistrationId(registrationId);
+ return oAuthConfiguration;
+ }
+}
diff --git a/streampipes-commons/src/test/java/org/apache/streampipes/commons/environment/parser/OAuthConfigurationParserTest.java b/streampipes-commons/src/test/java/org/apache/streampipes/commons/environment/parser/OAuthConfigurationParserTest.java
new file mode 100644
index 0000000000..b54c41ddf5
--- /dev/null
+++ b/streampipes-commons/src/test/java/org/apache/streampipes/commons/environment/parser/OAuthConfigurationParserTest.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.streampipes.commons.environment.parser;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+public class OAuthConfigurationParserTest {
+
+ private final Map env = new HashMap<>() {
+ {
+ put("SP_OAUTH_PROVIDER_AZURE_AUTHORIZATION_URI", "authorizationUriA");
+ put("SP_OAUTH_PROVIDER_AZURE_CLIENT_NAME", "clientNameA");
+ put("SP_OAUTH_PROVIDER_AZURE_CLIENT_ID", "clientIdA");
+ put("SP_OAUTH_PROVIDER_AZURE_CLIENT_SECRET", "clientSecretA");
+ put("SP_OAUTH_PROVIDER_AZURE_FULL_NAME_ATTRIBUTE_NAME", "fullNameA");
+ put("SP_OAUTH_PROVIDER_AZURE_ISSUER_URI", "issuerUriA");
+ put("SP_OAUTH_PROVIDER_AZURE_JWK_SET_URI", "jwkSetUriA");
+ put("SP_OAUTH_PROVIDER_AZURE_SCOPES", "scope1,scope2");
+ put("SP_OAUTH_PROVIDER_AZURE_TOKEN_URI", "tokenUriA");
+ put("SP_OAUTH_PROVIDER_AZURE_USER_INFO_URI", "userInfoUriA");
+ put("SP_OAUTH_PROVIDER_AZURE_USER_ID_ATTRIBUTE_NAME", "userNameA");
+ put("SP_OAUTH_PROVIDER_GITHUB_AUTHORIZATION_URI", "authorizationUriB");
+ }
+ };
+
+ @Test
+ public void testParser() {
+ var config = new OAuthConfigurationParser().parse(env);
+
+ assertEquals(2, config.size());
+
+ var azureConfig = config.get(1);
+ assertEquals("azure", azureConfig.getRegistrationId());
+ assertEquals("authorizationUriA", azureConfig.getAuthorizationUri());
+ assertEquals("clientNameA", azureConfig.getClientName());
+ assertEquals("clientIdA", azureConfig.getClientId());
+ assertEquals("clientSecretA", azureConfig.getClientSecret());
+ assertEquals("fullNameA", azureConfig.getFullNameAttributeName());
+ assertEquals("issuerUriA", azureConfig.getIssuerUri());
+ assertEquals("jwkSetUriA", azureConfig.getJwkSetUri());
+ assertEquals(2, azureConfig.getScopes().length);
+ assertEquals("scope1", azureConfig.getScopes()[0]);
+ assertEquals("tokenUriA", azureConfig.getTokenUri());
+ assertEquals("userInfoUriA", azureConfig.getUserInfoUri());
+ assertEquals("userNameA", azureConfig.getUserIdAttributeName());
+
+ var gitHubConfig = config.get(0);
+ assertEquals("github", gitHubConfig.getRegistrationId());
+ assertEquals("authorizationUriB", gitHubConfig.getAuthorizationUri());
+ assertNull(gitHubConfig.getTokenUri());
+
+
+ }
+}
diff --git a/streampipes-model-client/pom.xml b/streampipes-model-client/pom.xml
index 2c2538ae54..7674d6dc42 100644
--- a/streampipes-model-client/pom.xml
+++ b/streampipes-model-client/pom.xml
@@ -88,6 +88,9 @@
asClasses
true
true
+
+ import { Storable } from '@streampipes/platform-services'
+
cz.habarta.typescript.generator.ext.JsonDeserializationExtension
diff --git a/streampipes-model-client/src/main/java/org/apache/streampipes/model/client/user/UserAccount.java b/streampipes-model-client/src/main/java/org/apache/streampipes/model/client/user/UserAccount.java
index 3c6f5d96eb..6a1ebd34f1 100644
--- a/streampipes-model-client/src/main/java/org/apache/streampipes/model/client/user/UserAccount.java
+++ b/streampipes-model-client/src/main/java/org/apache/streampipes/model/client/user/UserAccount.java
@@ -27,6 +27,8 @@
@TsModel
public class UserAccount extends Principal {
+ public static final String LOCAL = "local";
+
protected String fullName;
protected String password;
@@ -39,6 +41,11 @@ public class UserAccount extends Principal {
protected boolean hideTutorial;
protected boolean darkMode = false;
+ /**
+ * The authentication provider (LOCAL or one of the configured OAuth providers
+ */
+ protected String provider;
+
public UserAccount() {
super(PrincipalType.USER_ACCOUNT);
this.hideTutorial = false;
@@ -46,6 +53,7 @@ public UserAccount() {
this.preferredDataProcessors = new ArrayList<>();
this.preferredDataSinks = new ArrayList<>();
this.preferredDataStreams = new ArrayList<>();
+ this.provider = UserAccount.LOCAL;
}
public static UserAccount from(String username,
@@ -156,4 +164,12 @@ public String getPassword() {
public void setPassword(String password) {
this.password = password;
}
+
+ public String getProvider() {
+ return provider;
+ }
+
+ public void setProvider(String provider) {
+ this.provider = provider;
+ }
}
diff --git a/streampipes-model-client/src/main/java/org/apache/streampipes/model/client/user/UserRegistrationData.java b/streampipes-model-client/src/main/java/org/apache/streampipes/model/client/user/UserRegistrationData.java
index 5457645e38..92b1a0edd7 100644
--- a/streampipes-model-client/src/main/java/org/apache/streampipes/model/client/user/UserRegistrationData.java
+++ b/streampipes-model-client/src/main/java/org/apache/streampipes/model/client/user/UserRegistrationData.java
@@ -20,5 +20,38 @@
import java.util.List;
-public record UserRegistrationData(String username, String password, List roles) {
+public class UserRegistrationData {
+
+ private String username;
+ private String password;
+ private List roles;
+ private String provider;
+
+ public UserRegistrationData(String username,
+ String password,
+ List roles) {
+ this.username = username;
+ this.password = password;
+ this.roles = roles;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public List getRoles() {
+ return roles;
+ }
+
+ public String getProvider() {
+ return provider;
+ }
+
+ public void setProvider(String provider) {
+ this.provider = provider;
+ }
}
diff --git a/streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management/UserResourceManager.java b/streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management/UserResourceManager.java
index e9e1630be9..9fd8273ffa 100644
--- a/streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management/UserResourceManager.java
+++ b/streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management/UserResourceManager.java
@@ -90,19 +90,19 @@ public Principal getAdminUser() {
public void registerUser(UserRegistrationData data) throws UsernameAlreadyTakenException {
try {
validateAndRegisterNewUser(data);
- createTokenAndSendActivationMail(data.username());
+ createTokenAndSendActivationMail(data.getUsername());
} catch (IOException e) {
LOG.error("Registration of user could not be completed: {}", e.getMessage());
}
}
private synchronized void validateAndRegisterNewUser(UserRegistrationData data) {
- if (db.checkUserExists(data.username())) {
+ if (db.checkUserExists(data.getUsername())) {
throw new UsernameAlreadyTakenException("Username already taken");
}
String encryptedPassword;
try {
- encryptedPassword = PasswordUtil.encryptPassword(data.password());
+ encryptedPassword = PasswordUtil.encryptPassword(data.getPassword());
} catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
throw new SpException("Error during password encryption: %s".formatted(e.getMessage()));
}
@@ -112,9 +112,9 @@ private synchronized void validateAndRegisterNewUser(UserRegistrationData data)
private synchronized void createNewUser(UserRegistrationData data, String encryptedPassword) {
- List roles = data.roles().stream().map(Role::valueOf).toList();
- UserAccount user = UserAccount.from(data.username(), encryptedPassword, new HashSet<>(roles));
- user.setUsername(data.username());
+ List roles = data.getRoles().stream().map(Role::valueOf).toList();
+ UserAccount user = UserAccount.from(data.getUsername(), encryptedPassword, new HashSet<>(roles));
+ user.setUsername(data.getUsername());
user.setPassword(encryptedPassword);
user.setAccountEnabled(false);
db.storeUser(user);
@@ -169,7 +169,7 @@ public void changePassword(String recoveryCode,
PasswordRecoveryToken token = getPasswordRecoveryTokenStorage().getElementById(recoveryCode);
Principal user = db.getUser(token.getUsername());
if (user instanceof UserAccount) {
- String encryptedPassword = PasswordUtil.encryptPassword(data.password());
+ String encryptedPassword = PasswordUtil.encryptPassword(data.getPassword());
((UserAccount) user).setPassword(encryptedPassword);
db.updateUser(user);
getPasswordRecoveryTokenStorage().deleteElement(token);
@@ -194,4 +194,7 @@ private Environment getEnvironment() {
}
+ public void registerOauthUser(UserAccount userAccount) {
+ db.storeUser(userAccount);
+ }
}
diff --git a/streampipes-rest-shared/src/main/java/org/apache/streampipes/rest/shared/exception/BadRequestException.java b/streampipes-rest-shared/src/main/java/org/apache/streampipes/rest/shared/exception/BadRequestException.java
new file mode 100755
index 0000000000..13e811d854
--- /dev/null
+++ b/streampipes-rest-shared/src/main/java/org/apache/streampipes/rest/shared/exception/BadRequestException.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.streampipes.rest.shared.exception;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.ResponseStatus;
+
+@ResponseStatus(HttpStatus.BAD_REQUEST)
+public class BadRequestException extends RuntimeException {
+
+ public BadRequestException(String message) {
+ super(message);
+ }
+
+ public BadRequestException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/Authentication.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/Authentication.java
index 2401ee61da..214651e97f 100644
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/Authentication.java
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/Authentication.java
@@ -18,6 +18,7 @@
package org.apache.streampipes.rest.impl;
+import org.apache.streampipes.commons.environment.Environments;
import org.apache.streampipes.commons.exceptions.UserNotFoundException;
import org.apache.streampipes.commons.exceptions.UsernameAlreadyTakenException;
import org.apache.streampipes.model.client.user.JwtAuthenticationResponse;
@@ -50,6 +51,7 @@
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
@RestController
@@ -98,8 +100,8 @@ public synchronized ResponseEntity doRegister(
return ResponseEntity.status(HttpStatus.FORBIDDEN).build();
}
var enrichedUserRegistrationData = new UserRegistrationData(
- userRegistrationData.username(),
- userRegistrationData.password(),
+ userRegistrationData.getUsername(),
+ userRegistrationData.getPassword(),
config.getDefaultUserRoles()
);
try {
@@ -139,6 +141,7 @@ public ResponseEntity