Fixed DataIntegrityViolationException with OIDC (#1348) (#1458)

Signed-off-by: Vít Holásek <xvh@seznam.cz>
This commit is contained in:
Vít Holásek
2023-11-01 12:10:28 +01:00
committed by GitHub
parent 042e867e5d
commit 6428422eed

View File

@@ -25,6 +25,7 @@ import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.context.SecurityContextImpl;
import org.springframework.security.oauth2.core.oidc.user.OidcUser;
/**
* A {@link TenantAware} implementation which retrieves the ID of the tenant
@@ -75,6 +76,9 @@ public class SecurityContextTenantAware implements TenantAware {
if (principal instanceof UserPrincipal) {
return ((UserPrincipal) principal).getUsername();
}
if (principal instanceof OidcUser) {
return ((OidcUser) principal).getPreferredUsername();
}
}
return null;
}