Extracted get-realm to service since statics cannot be overwritten
This commit is contained in:
parent
1683f9521c
commit
e15769b010
@ -31,10 +31,5 @@ public class KeycloakSecurity {
|
||||
}
|
||||
|
||||
|
||||
public Optional<String> getRealm() {
|
||||
|
||||
var authentication = (JwtAuthenticationToken) SecurityContextHolder.getContext().getAuthentication();
|
||||
return Optional.of(TokenUtils.toTenant(authentication.getToken().getTokenValue()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,20 @@
|
||||
package com.knecon.fforesight.keycloakcommons.security;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.knecon.fforesight.keycloakcommons.security.TokenUtils;
|
||||
|
||||
@Service
|
||||
public class TokenRealmService {
|
||||
|
||||
public Optional<String> getRealm() {
|
||||
|
||||
var authentication = (JwtAuthenticationToken) SecurityContextHolder.getContext().getAuthentication();
|
||||
return Optional.of(TokenUtils.toTenant(authentication.getToken().getTokenValue()));
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user