-1

So some after fighting with spring-authorisation-server, it now mostly works behind the oauth2-proxy.

One final problem is now, that the oauth2-proxy is not happy, that there is no email adress provided during the flow.

But i haven't found anything inside the documentaion how an email adress can be provided. The userdetails services looks as simple as below.

So if anyone can give me an idea how to add emails for oauth2 .. that would be great

    @Bean
    public UserDetailsService userDetailsService() {

        UserDetails userDetails = User.withDefaultPasswordEncoder()
                .username("user1")
                .password("user1")
                .roles("USER")
                //.authorities(authority)
                .build();


        return new InMemoryUserDetailsManager(userDetails);
    }

I would expect that email adresses could be added

Andreas
  • 71
  • 4

1 Answers1

1

For anyone stumbling upon these, there is a good blog post describing the solution:

https://www.appsdeveloperblog.com/add-roles-to-jwt-issued-by-new-spring-authorization-server/

Fairly easy. In my case as easy as the below code, to get the Oauth2Proxy working. Of course this is only for testing

@Bean
OAuth2TokenCustomizer<JwtEncodingContext> jwtCustomizer() {
    return context -> {
            context.getClaims().claim("email", "user1@user1.de");
    };
}
Andreas
  • 71
  • 4