Search in sources :

Example 1 with OidcClientProvider

use of com.evolveum.midpoint.authentication.impl.provider.OidcClientProvider in project midpoint by Evolveum.

the class OidcClientModuleFactory 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 OidcAuthenticationModuleType)) {
        LOGGER.error("This factory support only OidcAuthenticationModuleType, but modelType is " + moduleType);
        return null;
    }
    if (((OidcAuthenticationModuleType) moduleType).getClient().isEmpty()) {
        LOGGER.error("Client configuration of OidcAuthenticationModuleType is null");
        return null;
    }
    isSupportedChannel(authenticationChannel);
    OidcClientModuleWebSecurityConfiguration.setProtector(getProtector());
    OidcClientModuleWebSecurityConfiguration configuration = OidcClientModuleWebSecurityConfiguration.build((OidcAuthenticationModuleType) moduleType, sequenceSuffix, getPublicUrlPrefix(request), request);
    configuration.setSequenceSuffix(sequenceSuffix);
    configuration.addAuthenticationProvider(getObjectObjectPostProcessor().postProcess(new OidcClientProvider(configuration.getAdditionalConfiguration())));
    OidcClientModuleWebSecurityConfigurer<OidcClientModuleWebSecurityConfiguration> module = getObjectObjectPostProcessor().postProcess(new OidcClientModuleWebSecurityConfigurer<>(configuration));
    module.setObjectPostProcessor(getObjectObjectPostProcessor());
    HttpSecurity http = module.getNewHttpSecurity();
    setSharedObjects(http, sharedObjects);
    ModuleAuthenticationImpl moduleAuthentication = createEmptyModuleAuthentication(configuration, request);
    moduleAuthentication.setFocusType(moduleType.getFocusType());
    SecurityFilterChain filter = http.build();
    return AuthModuleImpl.build(filter, configuration, moduleAuthentication);
}
Also used : OidcClientModuleWebSecurityConfiguration(com.evolveum.midpoint.authentication.impl.module.configuration.OidcClientModuleWebSecurityConfiguration) SecurityFilterChain(org.springframework.security.web.SecurityFilterChain) ModuleAuthenticationImpl(com.evolveum.midpoint.authentication.impl.module.authentication.ModuleAuthenticationImpl) OidcClientModuleAuthenticationImpl(com.evolveum.midpoint.authentication.impl.module.authentication.OidcClientModuleAuthenticationImpl) HttpSecurity(org.springframework.security.config.annotation.web.builders.HttpSecurity) OidcClientProvider(com.evolveum.midpoint.authentication.impl.provider.OidcClientProvider)

Aggregations

ModuleAuthenticationImpl (com.evolveum.midpoint.authentication.impl.module.authentication.ModuleAuthenticationImpl)1 OidcClientModuleAuthenticationImpl (com.evolveum.midpoint.authentication.impl.module.authentication.OidcClientModuleAuthenticationImpl)1 OidcClientModuleWebSecurityConfiguration (com.evolveum.midpoint.authentication.impl.module.configuration.OidcClientModuleWebSecurityConfiguration)1 OidcClientProvider (com.evolveum.midpoint.authentication.impl.provider.OidcClientProvider)1 HttpSecurity (org.springframework.security.config.annotation.web.builders.HttpSecurity)1 SecurityFilterChain (org.springframework.security.web.SecurityFilterChain)1