How to retrieve user information in spring-boot service ?

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 (Auth0 Spring Boot API SDK Quickstarts: Authorization)

@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 Likes