org.springframework.security.web.DefaultSecurityFilterChain Java Examples
The following examples show how to use
org.springframework.security.web.DefaultSecurityFilterChain.
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
Source File: InsightsSecurityConfigurationAdapter.java From Insights with Apache License 2.0 | 6 votes |
/** * 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 File: WebSecurityConfig.java From spring-tsers-auth with Apache License 2.0 | 6 votes |
@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 File: SAMLConfigurer.java From spring-security-saml-dsl with MIT License | 6 votes |
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 File: SecurityFilterConfig.java From cosmo with Apache License 2.0 | 6 votes |
@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
Source File: WebSecurityConfig.java From spring-boot-security-saml-sample with Apache License 2.0 | 6 votes |
/** * 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 File: CustomSpringSecurityFilterChain.java From Spring with Apache License 2.0 | 5 votes |
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 File: AuthenticationHandler.java From blackduck-alert with Apache License 2.0 | 5 votes |
@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
Source File: InsightsSecurityConfigurationAdapterSAML.java From Insights with Apache License 2.0 | 5 votes |
/** * 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
Source File: InsightsSecurityConfigurationAdapterKerberos.java From Insights with Apache License 2.0 | 5 votes |
/** * 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 File: Application.java From boot-examples with Apache License 2.0 | 5 votes |
@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 File: AbstractChannelSecurityConfigurer.java From cola with MIT License | 4 votes |
protected AbstractChannelSecurityConfigurer(SecurityConfigurerAdapter<DefaultSecurityFilterChain, HttpSecurity> adapter) { this.adapter = adapter; }
Example #12
Source File: FilterChainBuilder.java From gocd with Apache License 2.0 | 4 votes |
FilterChainBuilder addFilterChain(String antPattern, Filter... filters) { filterChain.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher(antPattern), filters)); return this; }