-
Notifications
You must be signed in to change notification settings - Fork 433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spring security SPEL expressions support (@PreAuthorize and @PostAuthorize) #175
Comments
@markbanierink, can you please show how you configure the authentication manager with working |
You probably have |
No, we do not use @Configuration
public class BaseGrpcServerSecurityConfiguration extends GrpcSecurityConfigurerAdapter {
@Override
public void configure(GrpcSecurity builder) throws Exception {
builder.authenticationProvider(authenticationProvider(jwtDecoder()));
builder.authorizeRequests().anyMethod().authenticated();
}
private AuthenticationProvider authenticationProvider(JwtDecoder jwtDecoder) {
JwtAuthenticationConverter jwtAuthenticationConverter = new CustomAuthenticationConverter();
JwtAuthenticationProvider jwtAuthenticationProvider = new JwtAuthenticationProvider(jwtDecoder);
jwtAuthenticationProvider.setJwtAuthenticationConverter(jwtAuthenticationConverter);
return jwtAuthenticationProvider;
}
private JwtDecoder jwtDecoder() {
return new CustomJwtDecoder();
}
} Web service configuration: public abstract class CustomWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter {
@Value("${ourPath}")
private String ourPath;
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable();
http.authorizeRequests()
.antMatchers(getOurPath()).authenticated()
.anyRequest().denyAll()
.and()
.oauth2ResourceServer().jwt().decoder(jwtDecoder()).jwtAuthenticationConverter(jwtAuthenticationConverter());
}
private String getOurPath() {
return ourPath;
}
private JwtDecoder jwtDecoder() {
return new CustomJwtDecoder();
}
private JwtAuthenticationConverter jwtAuthenticationConverter() {
return new CustomAuthenticationConverter();
}
} And the security configuration: @Configuration
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class SecurityConfiguration {
// some beans
} |
I see, so you have same configuration for both authentication providers - |
Yes, we have a configuration for each, since it is very well possible that any of the api's in the future is going to use another type of authentication. Both are separate modules. Our domain model also is a separate module and that one contains the |
Great, now I'll need to figure out how to tell spring security NOT to proxy |
@PreAuthorize
and nice to have@PostAuthorize
The text was updated successfully, but these errors were encountered: