Java Code Examples for org.springframework.security.web.DefaultSecurityFilterChain

The following examples show how to use org.springframework.security.web.DefaultSecurityFilterChain. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * Used to add necessary filter for Grafana Authentication
 * 
 * @return
 * @throws Exception
 */
@Bean
@Conditional(InsightsNativeBeanInitializationCondition.class)
public FilterChainProxy insightsFilter() throws Exception {
	LOG.debug("message Inside FilterChainProxy, initial bean InsightsSecurityConfigurationAdapter **** ");

	List<Filter> filters = new ArrayList<>();
	filters.add(0, new InsightsCustomCsrfFilter());
	filters.add(1, new InsightsCrossScriptingFilter());
	filters.add(2, insightsProcessingFilter());
	filters.add(3, new InsightsResponseHeaderWriterFilter());

	AuthenticationUtils
			.setSecurityFilterchain(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/**"), filters));//chains.add

	return new FilterChainProxy(AuthenticationUtils.getSecurityFilterchains());
}
 
Example 2
Source Project: spring-tsers-auth   Source File: WebSecurityConfig.java    License: Apache License 2.0 6 votes vote down vote up
@Bean
public FilterChainProxy samlFilter() throws Exception {
    List<SecurityFilterChain> chains = new ArrayList<SecurityFilterChain>();
    chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/login/**"),
            samlEntryPoint()));
    chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/logout/**"),
            samlLogoutFilter()));
    chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/metadata/**"),
            metadataDisplayFilter()));
    chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/SSO/**"),
            samlWebSSOProcessingFilter()));
    chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/SSOHoK/**"),
            samlWebSSOHoKProcessingFilter()));
    chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/SingleLogout/**"),
            samlLogoutProcessingFilter()));
    chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/discovery/**"),
            samlIDPDiscovery()));
    return new FilterChainProxy(chains);
}
 
Example 3
Source Project: spring-security-saml-dsl   Source File: SAMLConfigurer.java    License: MIT License 6 votes vote down vote up
private FilterChainProxy samlFilter(SAMLEntryPoint samlEntryPoint, SAMLLogoutFilter samlLogoutFilter,
									SAMLLogoutProcessingFilter samlLogoutProcessingFilter, SAMLContextProvider contextProvider) {
	List<SecurityFilterChain> chains = new ArrayList<>();
	chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/login/**"),
		samlEntryPoint));
	chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/logout/**"),
		samlLogoutFilter));
	chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/metadata/**"),
		metadataDisplayFilter(contextProvider)));
	try {
		chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/SSO/**"),
			samlWebSSOProcessingFilter(samlAuthenticationProvider, contextProvider, samlProcessor)));
	} catch (Exception e) {
		e.printStackTrace();
	}
	chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/SingleLogout/**"),
			samlLogoutProcessingFilter));
	SAMLDiscovery samlDiscovery = new SAMLDiscovery();
	samlDiscovery.setMetadata(cachingMetadataManager);
	samlDiscovery.setContextProvider(contextProvider);
	chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/discovery/**"),
		samlDiscovery));
	return new FilterChainProxy(chains);
}
 
Example 4
Source Project: cosmo   Source File: SecurityFilterConfig.java    License: Apache License 2.0 6 votes vote down vote up
@Bean
public FilterRegistrationBean<?> securityFilterChain() {
    FilterSecurityInterceptor securityFilter = new FilterSecurityInterceptor();
    securityFilter.setAuthenticationManager(this.authManager);
    securityFilter.setAccessDecisionManager(this.davDecisionManager);
    LinkedHashMap<RequestMatcher, Collection<ConfigAttribute>> metadata = new LinkedHashMap<RequestMatcher, Collection<ConfigAttribute>>();
    metadata.put(AnyRequestMatcher.INSTANCE, SecurityConfig.createList(ROLES));
    securityFilter.setSecurityMetadataSource(new DefaultFilterInvocationSecurityMetadataSource(metadata));

    /*
     * Note that the order in which filters are defined is highly important.
     */
    SecurityFilterChain filterChain = new DefaultSecurityFilterChain(AnyRequestMatcher.INSTANCE,
            this.cosmoExceptionFilter, this.extraTicketFilter, this.ticketFilter,
            new BasicAuthenticationFilter(authManager, this.authEntryPoint), securityFilter);
    FilterChainProxy proxy = new FilterChainProxy(filterChain);
    proxy.setFirewall(this.httpFirewall);
    FilterRegistrationBean<?> filterBean = new FilterRegistrationBean<>(proxy);
    filterBean.addUrlPatterns(PATH_DAV);
    return filterBean;
}
 
Example 5
/**
* Define the security filter chain in order to support SSO Auth by using SAML 2.0
* 
* @return Filter chain proxy
* @throws Exception
*/
  @Bean
  public FilterChainProxy samlFilter() throws Exception {
      List<SecurityFilterChain> chains = new ArrayList<SecurityFilterChain>();
      chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/login/**"),
              samlEntryPoint()));
      chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/logout/**"),
              samlLogoutFilter()));
      chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/metadata/**"),
              metadataDisplayFilter()));
      chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/SSO/**"),
              samlWebSSOProcessingFilter()));
      chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/SSOHoK/**"),
              samlWebSSOHoKProcessingFilter()));
      chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/SingleLogout/**"),
              samlLogoutProcessingFilter()));
      chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/discovery/**"),
              samlIDPDiscovery()));
      return new FilterChainProxy(chains);
  }
 
Example 6
Source Project: Spring   Source File: CustomSpringSecurityFilterChain.java    License: Apache License 2.0 5 votes vote down vote up
private static List<SecurityFilterChain> filterChains() {
    final List<SecurityFilterChain> filterChain = new ArrayList<>();

    final LogoutFilter customLogoutFilter =
            new LogoutFilter(new CustomLogoutSuccessHandler(), new SecurityContextLogoutHandler());
    customLogoutFilter.setFilterProcessesUrl("/customlogout");
    filterChain.add(new DefaultSecurityFilterChain(
            new AntPathRequestMatcher("/customlogout**"), customLogoutFilter));
    return filterChain;
}
 
Example 7
Source Project: blackduck-alert   Source File: AuthenticationHandler.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public FilterChainProxy samlFilter() throws Exception {
    List<SecurityFilterChain> chains = new ArrayList<>();

    chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/login/**"), samlEntryPoint()));
    chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/SSO/**"), samlWebSSOProcessingFilter()));
    chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/logout/**"), samlLogoutFilter()));
    chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/SingleLogout/**"), samlLogoutProcessingFilter()));
    return new AlertFilterChainProxy(chains, samlContext());
}
 
Example 8
/**
 * Used to add filter in saml flow, This will call right filter based on Request
 * Matcher pattern
 * 
 * @return
 * @throws Exception
 */
@Bean
@Conditional(InsightsSAMLBeanInitializationCondition.class)
public FilterChainProxy samlFilter() throws Exception {
	LOG.debug("message Inside FilterChainProxy, initial bean **** ");

	AuthenticationUtils.setSecurityFilterchain(
			new DefaultSecurityFilterChain(new AntPathRequestMatcher("/metadata/**"), metadataDisplayFilter()));//chains.add

	AuthenticationUtils.setSecurityFilterchain(
			new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/login/**"), samlEntryPoint()));

	AuthenticationUtils.setSecurityFilterchain(new DefaultSecurityFilterChain(
			new AntPathRequestMatcher("/saml/SSO/**"), samlWebSSOProcessingFilter()));

	AuthenticationUtils.setSecurityFilterchain(
			new DefaultSecurityFilterChain(new AntPathRequestMatcher("/saml/logout/**"), samlLogoutFilter()));

	AuthenticationUtils.setSecurityFilterchain(new DefaultSecurityFilterChain(
			new AntPathRequestMatcher("/saml/SingleLogout/**"), samlLogoutProcessingFilter()));

	AuthenticationUtils.setSecurityFilterchain(new DefaultSecurityFilterChain(
			new AntPathRequestMatcher("/user/insightsso/**"), insightsSSOProcessingFilter()));

	List<Filter> filters = new ArrayList<>();
	filters.add(0, new InsightsCustomCsrfFilter());
	filters.add(1, new InsightsCrossScriptingFilter());
	filters.add(2, insightsServiceProcessingFilter());
	filters.add(3, new InsightsResponseHeaderWriterFilter());

	AuthenticationUtils
			.setSecurityFilterchain(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/**"), filters));

	return new FilterChainProxy(AuthenticationUtils.getSecurityFilterchains());//chains

}
 
Example 9
/**
 * Used to add filter chain based on Request Matcher
 * 
 * @return
 * @throws Exception
 */
@Bean
@Conditional(InsightsKerberosBeanInitializationCondition.class)
public FilterChainProxy kerberosFilter() throws Exception {
	LOG.debug("message Inside InsightsSecurityConfigurationAdapterKerberos FilterChainProxy, initial bean **** ");

	/*AuthenticationUtils.setSecurityFilterchain(
			new DefaultSecurityFilterChain(new AntPathRequestMatcher("/kerberos/login/**"), spnegoEntryPoint()));*/

	/*AuthenticationUtils.setSecurityFilterchain(new DefaultSecurityFilterChain(
			new AntPathRequestMatcher("/user/insightsso/**"), insightsSSOProcessingFilter()));*/

	List<Filter> filters = new ArrayList<>();
	filters.add(0, new InsightsCustomCsrfFilter());
	filters.add(1, new InsightsCrossScriptingFilter());
	filters.add(2, insightsServiceProcessingFilter());
	filters.add(3, new InsightsResponseHeaderWriterFilter());

	AuthenticationUtils
			.setSecurityFilterchain(new DefaultSecurityFilterChain(new AntPathRequestMatcher("/**"), filters));

	ListIterator<SecurityFilterChain> securityFilters = AuthenticationUtils.getSecurityFilterchains()
			.listIterator();
	while (securityFilters.hasNext()) {
		SecurityFilterChain as = securityFilters.next();
		LOG.debug("message Inside FilterChainProxy, initial bean name {} **** ",
				Arrays.toString(as.getFilters().toArray()));
	}

	return new FilterChainProxy(AuthenticationUtils.getSecurityFilterchains());//chains
}
 
Example 10
Source Project: boot-examples   Source File: Application.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void configure(HttpSecurity http) throws Exception {

    http.csrf().disable();
    http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);

    String[] restEndpointsToSecure = { "news"};
    for (String endpoint : restEndpointsToSecure) {
        http.authorizeRequests().antMatchers("/" + endpoint + "/**").hasRole(CustomUserDetailsService.ROLE_USER);
    }

    SecurityConfigurer<DefaultSecurityFilterChain, HttpSecurity> securityConfigurerAdapter = new XAuthTokenConfigurer(userDetailsServiceBean());
    http.apply(securityConfigurerAdapter);
}
 
Example 11
Source Project: cola   Source File: AbstractChannelSecurityConfigurer.java    License: MIT License 4 votes vote down vote up
protected AbstractChannelSecurityConfigurer(SecurityConfigurerAdapter<DefaultSecurityFilterChain, HttpSecurity> adapter) {
	this.adapter = adapter;
}
 
Example 12
Source Project: gocd   Source File: FilterChainBuilder.java    License: Apache License 2.0 4 votes vote down vote up
FilterChainBuilder addFilterChain(String antPattern, Filter... filters) {
    filterChain.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher(antPattern), filters));
    return this;
}