Example usage for org.springframework.security.oauth2.config.annotation.web.configurers ResourceServerSecurityConfigurer configure

List of usage examples for org.springframework.security.oauth2.config.annotation.web.configurers ResourceServerSecurityConfigurer configure

Introduction

In this page you can find the example usage for org.springframework.security.oauth2.config.annotation.web.configurers ResourceServerSecurityConfigurer configure.

Prototype

@Override
    public void configure(HttpSecurity http) throws Exception 

Source Link

Usage

From source file:it.reply.orchestrator.config.security.WebSecurityConfig.java

@Override
public void configure(HttpSecurity http) throws Exception {
    if (oidcProperties.isEnabled()) {
        http.csrf().disable();//w w  w .  j  a  v a 2  s .co  m
        http.authorizeRequests().anyRequest().fullyAuthenticated().anyRequest()
                .access("#oauth2.hasScopeMatching('openid')").and().sessionManagement()
                .sessionCreationPolicy(SessionCreationPolicy.STATELESS);
        ResourceServerSecurityConfigurer configurer = new ResourceServerSecurityConfigurer();
        configurer.setBuilder(http);
        configurer.tokenServices(applicationContext.getBean(ResourceServerTokenServices.class));
        configurer.configure(http);

        // TODO Customize the authentication entry point in order to align the response body error
        // coming from the security filter chain to the ones coming from the REST controllers
        // see https://github.com/spring-projects/spring-security-oauth/issues/605
        // configurer.authenticationEntryPoint(new CustomAuthenticationEntryPoint());
    } else {
        super.configure(http);
    }
}