Search in sources :

Example 16 with SecurityFilterChain

use of org.springframework.security.web.SecurityFilterChain in project midpoint by Evolveum.

the class LdapModuleFactory method createModuleFilter.

@Override
public AuthModule createModuleFilter(AbstractAuthenticationModuleType moduleType, String sequenceSuffix, ServletRequest request, Map<Class<?>, Object> sharedObjects, AuthenticationModulesType authenticationsPolicy, CredentialsPolicyType credentialPolicy, AuthenticationChannel authenticationChannel) throws Exception {
    if (!(moduleType instanceof LdapAuthenticationModuleType)) {
        LOGGER.error("This factory support only LdapAuthenticationModuleType, but modelType is " + moduleType);
        return null;
    }
    isSupportedChannel(authenticationChannel);
    LdapModuleWebSecurityConfiguration configuration = LdapModuleWebSecurityConfiguration.build(moduleType, sequenceSuffix);
    configuration.setSequenceSuffix(sequenceSuffix);
    configuration.addAuthenticationProvider(getProvider((LdapAuthenticationModuleType) moduleType));
    LdapWebSecurityConfigurer<LdapModuleWebSecurityConfiguration> module = createModule(configuration);
    HttpSecurity http = getNewHttpSecurity(module);
    setSharedObjects(http, sharedObjects);
    ModuleAuthenticationImpl moduleAuthentication = createEmptyModuleAuthentication((LdapAuthenticationModuleType) moduleType, configuration);
    SecurityFilterChain filter = http.build();
    return AuthModuleImpl.build(filter, configuration, moduleAuthentication);
}
Also used : SecurityFilterChain(org.springframework.security.web.SecurityFilterChain) ModuleAuthenticationImpl(com.evolveum.midpoint.authentication.impl.module.authentication.ModuleAuthenticationImpl) HttpSecurity(org.springframework.security.config.annotation.web.builders.HttpSecurity) LdapModuleWebSecurityConfiguration(com.evolveum.midpoint.authentication.impl.module.configuration.LdapModuleWebSecurityConfiguration) LdapAuthenticationModuleType(com.evolveum.midpoint.xml.ns._public.common.common_3.LdapAuthenticationModuleType)

Example 17 with SecurityFilterChain

use of org.springframework.security.web.SecurityFilterChain in project midpoint by Evolveum.

the class AbstractCredentialModuleFactory method createModuleFilter.

@Override
public AuthModule createModuleFilter(AbstractAuthenticationModuleType moduleType, String sequenceSuffix, ServletRequest request, Map<Class<?>, Object> sharedObjects, AuthenticationModulesType authenticationsPolicy, CredentialsPolicyType credentialPolicy, AuthenticationChannel authenticationChannel) throws Exception {
    if (!(moduleType instanceof AbstractCredentialAuthenticationModuleType)) {
        LOGGER.error("This factory supports only AbstractPasswordAuthenticationModuleType, but modelType is " + moduleType);
        return null;
    }
    isSupportedChannel(authenticationChannel);
    C configuration = createConfiguration(moduleType, sequenceSuffix, authenticationChannel);
    configuration.addAuthenticationProvider(getProvider((AbstractCredentialAuthenticationModuleType) moduleType, credentialPolicy));
    CA module = createModule(configuration);
    HttpSecurity http = getNewHttpSecurity(module);
    setSharedObjects(http, sharedObjects);
    ModuleAuthenticationImpl moduleAuthentication = createEmptyModuleAuthentication(moduleType, configuration);
    moduleAuthentication.setFocusType(moduleType.getFocusType());
    SecurityFilterChain filter = http.build();
    return AuthModuleImpl.build(filter, configuration, moduleAuthentication);
}
Also used : SecurityFilterChain(org.springframework.security.web.SecurityFilterChain) ModuleAuthenticationImpl(com.evolveum.midpoint.authentication.impl.module.authentication.ModuleAuthenticationImpl) HttpSecurity(org.springframework.security.config.annotation.web.builders.HttpSecurity)

Example 18 with SecurityFilterChain

use of org.springframework.security.web.SecurityFilterChain in project midpoint by Evolveum.

the class HttpClusterModuleFactory method createModuleFilter.

@Override
public AuthModule createModuleFilter(AbstractAuthenticationModuleType moduleType, String sequenceSuffix, ServletRequest request, Map<Class<?>, Object> sharedObjects, AuthenticationModulesType authenticationsPolicy, CredentialsPolicyType credentialPolicy, AuthenticationChannel authenticationChannel) throws Exception {
    ModuleWebSecurityConfiguration configuration = createConfiguration(moduleType, sequenceSuffix);
    configuration.addAuthenticationProvider(createProvider());
    HttpClusterModuleWebSecurityConfigurer<ModuleWebSecurityConfiguration> module = createModule(configuration);
    HttpSecurity http = getNewHttpSecurity(module);
    setSharedObjects(http, sharedObjects);
    ModuleAuthenticationImpl moduleAuthentication = createEmptyModuleAuthentication(configuration);
    SecurityFilterChain filter = http.build();
    return AuthModuleImpl.build(filter, configuration, moduleAuthentication);
}
Also used : SecurityFilterChain(org.springframework.security.web.SecurityFilterChain) ModuleWebSecurityConfiguration(com.evolveum.midpoint.authentication.api.ModuleWebSecurityConfiguration) ModuleAuthenticationImpl(com.evolveum.midpoint.authentication.impl.module.authentication.ModuleAuthenticationImpl) HttpSecurity(org.springframework.security.config.annotation.web.builders.HttpSecurity)

Example 19 with SecurityFilterChain

use of org.springframework.security.web.SecurityFilterChain in project open-kilda by telstra.

the class SecurityConfig method samlFilter.

@Bean
public FilterChainProxy samlFilter() throws Exception {
    List<SecurityFilterChain> chains = new ArrayList<>();
    chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher(contextPath + SamlUrl.SAML_METADATA), metadataDisplayFilter()));
    chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher(contextPath + SamlUrl.SAML_LOGIN), samlEntryPoint()));
    chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher(contextPath + SamlUrl.SAML_SSO), samlWebSsoProcessingFilter()));
    chains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher(contextPath + SamlUrl.SAML_LOGOUT), samlLogoutFilter()));
    return new FilterChainProxy(chains);
}
Also used : DefaultSecurityFilterChain(org.springframework.security.web.DefaultSecurityFilterChain) SecurityFilterChain(org.springframework.security.web.SecurityFilterChain) FilterChainProxy(org.springframework.security.web.FilterChainProxy) ArrayList(java.util.ArrayList) AntPathRequestMatcher(org.springframework.security.web.util.matcher.AntPathRequestMatcher) DefaultSecurityFilterChain(org.springframework.security.web.DefaultSecurityFilterChain) Bean(org.springframework.context.annotation.Bean)

Example 20 with SecurityFilterChain

use of org.springframework.security.web.SecurityFilterChain in project app-template by xtuer.

the class DemoController method securityFilters.

/**
 * 获取 Spring Security 的 filters
 * URL: http://localhost:8080/demo/filters
 */
@GetMapping("/demo/filters")
@ResponseBody
public Map securityFilters() {
    Map<String, Map<String, String>> filterChains = new HashMap<>();
    int i = 1;
    for (SecurityFilterChain chain : this.filterChainProxy.getFilterChains()) {
        Map<String, String> filters = new HashMap<>();
        int j = 1;
        for (Filter filter : chain.getFilters()) {
            filters.put("" + (j++), filter.getClass().getName());
        }
        filterChains.put("" + (i++), filters);
    }
    return filterChains;
}
Also used : SecurityFilterChain(org.springframework.security.web.SecurityFilterChain) Filter(javax.servlet.Filter) ModelMap(org.springframework.ui.ModelMap)

Aggregations

SecurityFilterChain (org.springframework.security.web.SecurityFilterChain)35 FilterChainProxy (org.springframework.security.web.FilterChainProxy)22 Test (org.junit.jupiter.api.Test)15 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)11 HttpSecurity (org.springframework.security.config.annotation.web.builders.HttpSecurity)8 ModuleAuthenticationImpl (com.evolveum.midpoint.authentication.impl.module.authentication.ModuleAuthenticationImpl)7 DefaultSecurityFilterChain (org.springframework.security.web.DefaultSecurityFilterChain)7 Filter (jakarta.servlet.Filter)6 ArrayList (java.util.ArrayList)4 Bean (org.springframework.context.annotation.Bean)4 Filter (javax.servlet.Filter)3 AntPathRequestMatcher (org.springframework.security.web.util.matcher.AntPathRequestMatcher)3 Test (org.junit.Test)2 MotechURLSecurityRule (org.motechproject.security.domain.MotechURLSecurityRule)2 AnyRequestMatcher (org.springframework.security.web.util.matcher.AnyRequestMatcher)2 ModuleWebSecurityConfiguration (com.evolveum.midpoint.authentication.api.ModuleWebSecurityConfiguration)1 MidpointFilterChainProxy (com.evolveum.midpoint.authentication.impl.filter.MidpointFilterChainProxy)1 OidcClientModuleAuthenticationImpl (com.evolveum.midpoint.authentication.impl.module.authentication.OidcClientModuleAuthenticationImpl)1 RemoteModuleAuthenticationImpl (com.evolveum.midpoint.authentication.impl.module.authentication.RemoteModuleAuthenticationImpl)1 Saml2ModuleAuthenticationImpl (com.evolveum.midpoint.authentication.impl.module.authentication.Saml2ModuleAuthenticationImpl)1