Added generateRandomWorkdayId method in SecurityConfig to create random IDs if workday id shall be ignored
This commit is contained in:
parent
21e8a9e43a
commit
62e911caf5
1 changed files with 6 additions and 5 deletions
|
|
@ -47,10 +47,7 @@ import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
||||||
import org.springframework.web.filter.OncePerRequestFilter;
|
import org.springframework.web.filter.OncePerRequestFilter;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.*;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -288,7 +285,7 @@ public class SecurityConfig {
|
||||||
|
|
||||||
if (user == null && email != null && (ignoreWorkdayClaim || workdayId != null)) {
|
if (user == null && email != null && (ignoreWorkdayClaim || workdayId != null)) {
|
||||||
var isFirstUser = userRepository.count() == 0;
|
var isFirstUser = userRepository.count() == 0;
|
||||||
userId = userRepository.update(LccOidcUser.createDatabaseUser(email, oidcUser.getGivenName(), oidcUser.getFamilyName(), ignoreWorkdayClaim ? email : workdayId, isFirstUser));
|
userId = userRepository.update(LccOidcUser.createDatabaseUser(email, oidcUser.getGivenName(), oidcUser.getFamilyName(), ignoreWorkdayClaim ? generateRandomWorkdayId() : workdayId, isFirstUser));
|
||||||
mappedAuthorities.add(new SimpleGrantedAuthority(isFirstUser ? "ROLE_SERVICE" : "ROLE_NONE"));
|
mappedAuthorities.add(new SimpleGrantedAuthority(isFirstUser ? "ROLE_SERVICE" : "ROLE_NONE"));
|
||||||
} else {
|
} else {
|
||||||
log.debug("Unable to create user {} / {}", email, workdayId);
|
log.debug("Unable to create user {} / {}", email, workdayId);
|
||||||
|
|
@ -308,6 +305,10 @@ public class SecurityConfig {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String generateRandomWorkdayId() {
|
||||||
|
return UUID.randomUUID().toString().replaceAll("-", "").substring(0, 32);
|
||||||
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@Profile("!dev & !test")
|
@Profile("!dev & !test")
|
||||||
public BearerTokenResolver bearerTokenResolver(JwtTokenService jwtTokenService) {
|
public BearerTokenResolver bearerTokenResolver(JwtTokenService jwtTokenService) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue