I have a spring-boot(2.5.0 version) application with org.springframework.boot:spring-boot-starter-oauth2-resource-server dependency and application.properties:
spring.security.oauth2.resourceserver.jwt.jwk-set-uri=https://www.googleapis.com/oauth2/v3/certs
.
When I use @AuthenticationPrincipal annotation it injects org.springframework.security.oauth2.jwt.Jwt. Instead how to get OidcUser?
If in your security configuration the oauth2Login()
client is configured with an OIDC provider you can just inject it using @AuthenticationPrincipal
.
@GetMapping("/user")
public String userInfo(@AuthenticationPrincipal OidcUser oidcUser) {
...
}