Spring Cloud/Security how to do something useful with a JWT

70 views Asked by At

Using Auth0 I can receive and authenticate with a JWT. This was as simple as adding

public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

    @Value(value = "${auth0.audience}")
    private String audience;

    @Value(value = "${auth0.issuer}")
    private String issuer;

    @Override
    protected void configure(HttpSecurity http) throws Exception {

        http.cors().and()
                .headers()
                .frameOptions()
                .disable();

        JwtWebSecurityConfigurer
                .forRS256(audience, issuer)
                .configure(http)
                .authorizeRequests()
                .anyRequest().authenticated();

    }
}

What I'm confused about is where/how do I do something with each request such as saving the users details to a database, or say attach the user to a POJO for a relationship use?

Once I've got that user details saved somewhere, how do I do things with it such as get all the objects that belong to this user (assuming I've saved that against the user POJO) on each request?

I'm fresh to Spring so struggling with finding the correct resources for this workflow that don't go off on some adventure of creating and signing their own tokens...

0

There are 0 answers