Search in sources :

Example 6 with ModuleAuthenticationImpl

use of com.evolveum.midpoint.authentication.impl.module.authentication.ModuleAuthenticationImpl in project midpoint by Evolveum.

the class MidpointAuthFilter method changeLogoutToNewSequence.

private void changeLogoutToNewSequence(MidpointAuthentication mpAuthentication, AuthenticationWrapper authWrapper, HttpServletRequest httpRequest) {
    if (AuthSequenceUtil.isBasePathForSequence(httpRequest, authWrapper.sequence)) {
        mpAuthentication.getAuthenticationChannel().setPathAfterLogout(httpRequest.getServletPath());
        ModuleAuthenticationImpl authenticatedModule = (ModuleAuthenticationImpl) AuthUtil.getAuthenticatedModule();
        if (authenticatedModule != null) {
            authenticatedModule.setInternalLogout(true);
        }
    }
}
Also used : ModuleAuthenticationImpl(com.evolveum.midpoint.authentication.impl.module.authentication.ModuleAuthenticationImpl)

Example 7 with ModuleAuthenticationImpl

use of com.evolveum.midpoint.authentication.impl.module.authentication.ModuleAuthenticationImpl 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 8 with ModuleAuthenticationImpl

use of com.evolveum.midpoint.authentication.impl.module.authentication.ModuleAuthenticationImpl 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 9 with ModuleAuthenticationImpl

use of com.evolveum.midpoint.authentication.impl.module.authentication.ModuleAuthenticationImpl in project midpoint by Evolveum.

the class AbstractCredentialProvider method supports.

public boolean supports(Class<?> authenticationClass, Authentication authentication) {
    if (!(authentication instanceof MidpointAuthentication)) {
        return supports(authenticationClass);
    }
    MidpointAuthentication mpAuthentication = (MidpointAuthentication) authentication;
    ModuleAuthenticationImpl moduleAuthentication = (ModuleAuthenticationImpl) getProcessingModule(mpAuthentication);
    if (moduleAuthentication == null || moduleAuthentication.getAuthentication() == null) {
        return false;
    }
    if (moduleAuthentication.getAuthentication() instanceof AnonymousAuthenticationToken) {
        // hack for specific situation when user is anonymous, but accessDecisionManager resolve it
        return true;
    }
    if (moduleAuthentication instanceof CredentialModuleAuthenticationImpl) {
        Class<? extends CredentialPolicyType> moduleCredentialType = ((CredentialModuleAuthenticationImpl) moduleAuthentication).getCredentialType();
        if (moduleCredentialType == null) {
            return false;
        }
        if (!getTypeOfCredential().equals(moduleCredentialType)) {
            return false;
        }
    }
    return supports(moduleAuthentication.getAuthentication().getClass());
}
Also used : ModuleAuthenticationImpl(com.evolveum.midpoint.authentication.impl.module.authentication.ModuleAuthenticationImpl) CredentialModuleAuthenticationImpl(com.evolveum.midpoint.authentication.impl.module.authentication.CredentialModuleAuthenticationImpl) CredentialModuleAuthenticationImpl(com.evolveum.midpoint.authentication.impl.module.authentication.CredentialModuleAuthenticationImpl) AnonymousAuthenticationToken(org.springframework.security.authentication.AnonymousAuthenticationToken) MidpointAuthentication(com.evolveum.midpoint.authentication.api.config.MidpointAuthentication)

Example 10 with ModuleAuthenticationImpl

use of com.evolveum.midpoint.authentication.impl.module.authentication.ModuleAuthenticationImpl in project midpoint by Evolveum.

the class MidPointLdapAuthenticationProvider method doAuthentication.

protected DirContextOperations doAuthentication(DirContextOperations originalDirContextOperations) {
    if (originalDirContextOperations instanceof DirContextAdapter) {
        Authentication actualAuthentication = SecurityContextHolder.getContext().getAuthentication();
        if (actualAuthentication instanceof MidpointAuthentication) {
            MidpointAuthentication mpAuthentication = (MidpointAuthentication) actualAuthentication;
            ModuleAuthenticationImpl moduleAuthentication = (ModuleAuthenticationImpl) getProcessingModule(mpAuthentication);
            if (moduleAuthentication instanceof LdapModuleAuthentication) {
                // HACK because of NP in DirContextAdapter(DirContextAdapter master)
                if (!originalDirContextOperations.isUpdateMode()) {
                    ((DirContextAdapter) originalDirContextOperations).setUpdateMode(true);
                    ((DirContextAdapter) originalDirContextOperations).setUpdateMode(false);
                }
                LdapDirContextAdapter mpDirContextAdapter = new LdapDirContextAdapter((DirContextAdapter) originalDirContextOperations);
                mpDirContextAdapter.setNamingAttr(((LdapModuleAuthentication) moduleAuthentication).getNamingAttribute());
                if (moduleAuthentication.getFocusType() != null) {
                    Class<FocusType> focusType = PrismContext.get().getSchemaRegistry().determineCompileTimeClass(moduleAuthentication.getFocusType());
                    mpDirContextAdapter.setFocusType(focusType);
                }
                return mpDirContextAdapter;
            }
        }
    }
    return originalDirContextOperations;
}
Also used : LdapDirContextAdapter(com.evolveum.midpoint.authentication.impl.ldap.LdapDirContextAdapter) ModuleAuthenticationImpl(com.evolveum.midpoint.authentication.impl.module.authentication.ModuleAuthenticationImpl) LdapModuleAuthentication(com.evolveum.midpoint.authentication.impl.module.authentication.LdapModuleAuthentication) MidpointAuthentication(com.evolveum.midpoint.authentication.api.config.MidpointAuthentication) Authentication(org.springframework.security.core.Authentication) LdapDirContextAdapter(com.evolveum.midpoint.authentication.impl.ldap.LdapDirContextAdapter) DirContextAdapter(org.springframework.ldap.core.DirContextAdapter) LdapModuleAuthentication(com.evolveum.midpoint.authentication.impl.module.authentication.LdapModuleAuthentication) MidpointAuthentication(com.evolveum.midpoint.authentication.api.config.MidpointAuthentication)

Aggregations

ModuleAuthenticationImpl (com.evolveum.midpoint.authentication.impl.module.authentication.ModuleAuthenticationImpl)19 MidpointAuthentication (com.evolveum.midpoint.authentication.api.config.MidpointAuthentication)9 Authentication (org.springframework.security.core.Authentication)8 HttpSecurity (org.springframework.security.config.annotation.web.builders.HttpSecurity)7 SecurityFilterChain (org.springframework.security.web.SecurityFilterChain)7 ModuleAuthentication (com.evolveum.midpoint.authentication.api.config.ModuleAuthentication)2 LdapModuleAuthentication (com.evolveum.midpoint.authentication.impl.module.authentication.LdapModuleAuthentication)2 AnonymousAuthenticationToken (org.springframework.security.authentication.AnonymousAuthenticationToken)2 AuthModule (com.evolveum.midpoint.authentication.api.AuthModule)1 AuthenticationChannel (com.evolveum.midpoint.authentication.api.AuthenticationChannel)1 ModuleWebSecurityConfiguration (com.evolveum.midpoint.authentication.api.ModuleWebSecurityConfiguration)1 MidpointAnonymousAuthenticationFilter (com.evolveum.midpoint.authentication.impl.filter.MidpointAnonymousAuthenticationFilter)1 LdapDirContextAdapter (com.evolveum.midpoint.authentication.impl.ldap.LdapDirContextAdapter)1 CredentialModuleAuthenticationImpl (com.evolveum.midpoint.authentication.impl.module.authentication.CredentialModuleAuthenticationImpl)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 HttpHeaderModuleWebSecurityConfiguration (com.evolveum.midpoint.authentication.impl.module.configuration.HttpHeaderModuleWebSecurityConfiguration)1 LdapModuleWebSecurityConfiguration (com.evolveum.midpoint.authentication.impl.module.configuration.LdapModuleWebSecurityConfiguration)1 OidcClientModuleWebSecurityConfiguration (com.evolveum.midpoint.authentication.impl.module.configuration.OidcClientModuleWebSecurityConfiguration)1