Skip to content
Snippets Groups Projects
Verified Commit d7267073 authored by Martin Weise's avatar Martin Weise
Browse files

Hotfix change user password

parent 58e4c180
No related branches found
No related tags found
1 merge request!310Dev
......@@ -428,7 +428,7 @@ services:
BROKER_EXCHANGE_NAME: ${BROKER_EXCHANGE_NAME:-dbrepo}
BROKER_QUEUE_NAME: ${BROKER_QUEUE_NAME:-dbrepo}
BROKER_HOST: "${BROKER_ENDPOINT:-broker-service}"
BROKER_PASSWORD: ${SYSTEM_USERNAME:-admin}
BROKER_PASSWORD: ${SYSTEM_PASSWORD:-admin}
BROKER_PORT: ${BROKER_PORT:-5672}
BROKER_SERVICE_ENDPOINT: ${BROKER_SERVICE_ENDPOINT:-http://gateway-service/admin/broker}
BROKER_USERNAME: ${SYSTEM_USERNAME:-admin}
......
......@@ -326,7 +326,7 @@ public class UserEndpoint {
}
@PutMapping("/{userId}/password")
@Transactional
@Transactional(rollbackFor = {Exception.class})
@PreAuthorize("isAuthenticated()")
@Observed(name = "dbrepo_user_password_modify")
@Operation(summary = "Update user password",
......@@ -367,12 +367,11 @@ public class UserEndpoint {
AuthServiceConnectionException, UserNotFoundException, DatabaseNotFoundException, DataServiceException,
DataServiceConnectionException, CredentialsInvalidException {
log.debug("endpoint modify a user password, userId={}, data.password=(hidden)", userId);
User user = userService.findById(userId);
final User user = userService.findById(userId);
if (!user.equals(principal)) {
log.error("Failed to modify user password: not current user");
throw new NotAllowedException("Failed to modify user password: not current user");
}
user = userService.findByUsername(principal.getName());
userService.updatePassword(user, data);
authenticationService.updatePassword(user, data);
for (Database database : databaseService.findAllAccess(userId)) {
......
......@@ -60,5 +60,6 @@ public interface AuthenticationService {
* @throws AuthServiceException The auth service responded with unexpected behavior.
* @throws AuthServiceConnectionException The connection with the auth service could not be established.
*/
void updatePassword(User user, UserPasswordDto data) throws AuthServiceException, AuthServiceConnectionException, CredentialsInvalidException;
void updatePassword(User user, UserPasswordDto data) throws AuthServiceException, AuthServiceConnectionException,
CredentialsInvalidException, UserNotFoundException;
}
......@@ -43,7 +43,8 @@ public class AuthenticationServiceImpl implements AuthenticationService {
@Override
public void delete(User user) throws AuthServiceException, AuthServiceConnectionException, UserNotFoundException,
CredentialsInvalidException {
keycloakGateway.deleteUser(user.getId());
final UserDto keycloakUser = findByUsername(user.getUsername());
keycloakGateway.deleteUser(keycloakUser.getId());
}
@Override
......@@ -72,8 +73,9 @@ public class AuthenticationServiceImpl implements AuthenticationService {
@Override
public void updatePassword(User user, UserPasswordDto data) throws AuthServiceException,
AuthServiceConnectionException, CredentialsInvalidException {
keycloakGateway.updateUserCredentials(user.getId(), data);
AuthServiceConnectionException, CredentialsInvalidException, UserNotFoundException {
final UserDto keycloakUser = findByUsername(user.getUsername());
keycloakGateway.updateUserCredentials(keycloakUser.getId(), data);
}
}
......@@ -493,7 +493,7 @@ services:
BROKER_EXCHANGE_NAME: ${BROKER_EXCHANGE_NAME:-dbrepo}
BROKER_QUEUE_NAME: ${BROKER_QUEUE_NAME:-dbrepo}
BROKER_HOST: "${BROKER_ENDPOINT:-broker-service}"
BROKER_PASSWORD: ${SYSTEM_USERNAME:-admin}
BROKER_PASSWORD: ${SYSTEM_PASSWORD:-admin}
BROKER_PORT: ${BROKER_PORT:-5672}
BROKER_SERVICE_ENDPOINT: ${BROKER_SERVICE_ENDPOINT:-http://gateway-service/admin/broker}
BROKER_USERNAME: ${SYSTEM_USERNAME:-admin}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment