Auth0 Home Blog Docs

How to retrieve user information in spring-boot service ?

java
backend
spring-boot
spring-security
principal

#1

Dear all,
I wonder how to retrieve the user information (especially the user name / identifier) in a spring-boot service ?

I would like to be able to do something like this in my REST controler

    public User user() {
        return (User) SecurityContextHolder
                .getContext()
                .getAuthentication()
                .getPrincipal();
    }

There is no information about that in the documentation explaining how to secure a back-end with Spring Security (https://auth0.com/docs/quickstart/backend/java-spring-security)

@auth0 team > it should definitely be there, as it is a basic use case!

@all > can you please help on that?

Thanks a lot!


#2