Search in sources :

Example 1 with WebSecurityConfigurerAdapter

use of org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter in project spring-boot by spring-projects.

the class OAuth2SsoCustomConfiguration method postProcessAfterInitialization.

@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
    if (this.configType.isAssignableFrom(bean.getClass()) && bean instanceof WebSecurityConfigurerAdapter) {
        ProxyFactory factory = new ProxyFactory();
        factory.setTarget(bean);
        factory.addAdvice(new SsoSecurityAdapter(this.applicationContext));
        bean = factory.getProxy();
    }
    return bean;
}
Also used : ProxyFactory(org.springframework.aop.framework.ProxyFactory) WebSecurityConfigurerAdapter(org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter)

Example 2 with WebSecurityConfigurerAdapter

use of org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter in project cas by apereo.

the class CasConfigurationServerWebApplication method casConfigurationServerWebSecurityConfigurerAdapter.

/**
 * Cas configuration server web security configurer adapter.
 *
 * @param serverProperties the server properties
 * @return the web security configurer adapter
 */
@Bean
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
public WebSecurityConfigurerAdapter casConfigurationServerWebSecurityConfigurerAdapter(final ServerProperties serverProperties) {
    return new WebSecurityConfigurerAdapter() {

        @Override
        protected void configure(final HttpSecurity http) throws Exception {
            val path = serverProperties.getServlet().getContextPath();
            http.authorizeRequests().antMatchers(path + "/decrypt/**").authenticated().and().csrf().disable();
            http.authorizeRequests().antMatchers(path + "/encrypt/**").authenticated().and().csrf().disable();
            super.configure(http);
        }
    };
}
Also used : lombok.val(lombok.val) HttpSecurity(org.springframework.security.config.annotation.web.builders.HttpSecurity) WebSecurityConfigurerAdapter(org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) Bean(org.springframework.context.annotation.Bean)

Aggregations

WebSecurityConfigurerAdapter (org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter)2 lombok.val (lombok.val)1 ProxyFactory (org.springframework.aop.framework.ProxyFactory)1 RefreshScope (org.springframework.cloud.context.config.annotation.RefreshScope)1 Bean (org.springframework.context.annotation.Bean)1 HttpSecurity (org.springframework.security.config.annotation.web.builders.HttpSecurity)1