use of com.evolveum.midpoint.authentication.impl.handler.MidPointAuthenticationSuccessHandler in project midpoint by Evolveum.
the class MailNonceFormModuleWebSecurityConfigurer method configure.
@Override
protected void configure(HttpSecurity http) throws Exception {
super.configure(http);
http.antMatcher(AuthUtil.stripEndingSlashes(getPrefix()) + "/**");
getOrApply(http, new MidpointFormLoginConfigurer<>(new MailNonceAuthenticationFilter())).loginPage(getConfiguration().getSpecificLoginUrl() == null ? "/emailNonce" : getConfiguration().getSpecificLoginUrl()).failureHandler(new MidpointAuthenticationFailureHandler()).successHandler(getObjectPostProcessor().postProcess(new MidPointAuthenticationSuccessHandler())).permitAll();
getOrApply(http, new MidpointExceptionHandlingConfigurer<>()).authenticationEntryPoint(new WicketLoginUrlAuthenticationEntryPoint(getConfiguration().getSpecificLoginUrl() == null ? "/emailNonce" : getConfiguration().getSpecificLoginUrl()));
http.logout().clearAuthentication(true).logoutRequestMatcher(getLogoutMatcher(http, getPrefix() + "/logout")).invalidateHttpSession(true).deleteCookies("JSESSIONID").logoutSuccessHandler(createLogoutHandler());
}
use of com.evolveum.midpoint.authentication.impl.handler.MidPointAuthenticationSuccessHandler in project midpoint by Evolveum.
the class OidcClientModuleWebSecurityConfigurer method configure.
@Override
protected void configure(HttpSecurity http) throws Exception {
super.configure(http);
OidcLoginConfigurer configurer = new OidcLoginConfigurer(auditProvider);
configurer.midpointFailureHandler(new MidpointAuthenticationFailureHandler()).clientRegistrationRepository(clientRegistrationRepository()).loginProcessingUrl(AuthUtil.stripEndingSlashes(getPrefix()) + RemoteModuleAuthenticationImpl.AUTHENTICATION_REQUEST_PROCESSING_URL_SUFFIX_WITH_REG_ID).authorizationRequestBaseUri(AuthUtil.stripEndingSlashes(getPrefix()) + RemoteModuleAuthenticationImpl.AUTHORIZATION_REQUEST_PROCESSING_URL_SUFFIX).successHandler(getObjectPostProcessor().postProcess(new MidPointAuthenticationSuccessHandler()));
try {
configurer.authenticationManager(new ProviderManager(Collections.emptyList(), authenticationManager()));
} catch (Exception e) {
LOGGER.error("Couldn't initialize authentication manager for oidc module");
}
getOrApply(http, configurer);
}
use of com.evolveum.midpoint.authentication.impl.handler.MidPointAuthenticationSuccessHandler in project midpoint by Evolveum.
the class LoginFormModuleWebSecurityConfigurer method configure.
@Override
protected void configure(HttpSecurity http) throws Exception {
super.configure(http);
http.antMatcher(AuthUtil.stripEndingSlashes(getPrefix()) + "/**");
getOrApply(http, getMidpointFormLoginConfigurer()).loginPage("/login").loginProcessingUrl(AuthUtil.stripEndingSlashes(getPrefix()) + "/spring_security_login").failureHandler(new MidpointAuthenticationFailureHandler()).successHandler(getObjectPostProcessor().postProcess(new MidPointAuthenticationSuccessHandler())).permitAll();
getOrApply(http, new MidpointExceptionHandlingConfigurer<>()).authenticationEntryPoint(new WicketLoginUrlAuthenticationEntryPoint("/login"));
http.logout().clearAuthentication(true).logoutRequestMatcher(getLogoutMatcher(http, getPrefix() + "/logout")).invalidateHttpSession(true).deleteCookies("JSESSIONID").logoutSuccessHandler(createLogoutHandler());
if (Arrays.stream(environment.getActiveProfiles()).anyMatch(p -> p.equalsIgnoreCase("cas"))) {
http.addFilterAt(casFilter, CasAuthenticationFilter.class);
http.addFilterBefore(requestSingleLogoutFilter, LogoutFilter.class);
}
if (Arrays.stream(environment.getActiveProfiles()).anyMatch(p -> p.equalsIgnoreCase("ssoenv"))) {
http.addFilterBefore(requestAttributeAuthenticationFilter, LogoutFilter.class);
}
}
use of com.evolveum.midpoint.authentication.impl.handler.MidPointAuthenticationSuccessHandler in project midpoint by Evolveum.
the class SamlModuleWebSecurityConfigurer method configure.
@Override
protected void configure(HttpSecurity http) throws Exception {
super.configure(http);
MidpointSaml2LoginConfigurer configurer = new MidpointSaml2LoginConfigurer<>(auditProvider);
configurer.relyingPartyRegistrationRepository(relyingPartyRegistrations()).loginProcessingUrl(getConfiguration().getPrefixOfModule() + SamlModuleWebSecurityConfiguration.SSO_LOCATION_URL_SUFFIX).successHandler(getObjectPostProcessor().postProcess(new MidPointAuthenticationSuccessHandler())).failureHandler(new MidpointAuthenticationFailureHandler());
try {
configurer.authenticationManager(new ProviderManager(Collections.emptyList(), authenticationManager()));
} catch (Exception e) {
LOGGER.error("Couldn't initialize authentication manager for saml2 module");
}
getOrApply(http, configurer);
Saml2MetadataFilter filter = new Saml2MetadataFilter(new MidpointMetadataRelyingPartyRegistrationResolver(relyingPartyRegistrations()), new OpenSamlMetadataResolver());
filter.setRequestMatcher(new AntPathRequestMatcher(getConfiguration().getPrefixOfModule() + "/metadata/*"));
http.addFilterAfter(filter, Saml2WebSsoAuthenticationFilter.class);
}
use of com.evolveum.midpoint.authentication.impl.handler.MidPointAuthenticationSuccessHandler in project midpoint by Evolveum.
the class HttpHeaderModuleWebSecurityConfigurer method requestHeaderAuthenticationFilter.
private RequestHeaderAuthenticationFilter requestHeaderAuthenticationFilter() {
MidpointRequestHeaderAuthenticationFilter filter = new MidpointRequestHeaderAuthenticationFilter();
filter.setPrincipalRequestHeader(getConfiguration().getPrincipalRequestHeader());
filter.setExceptionIfHeaderMissing(false);
filter.setAuthenticationManager(authenticationManager);
filter.setAuthenticationFailureHandler(new MidpointAuthenticationFailureHandler() {
@Override
protected String getPathAfterUnsuccessfulAuthentication(AuthenticationChannel authenticationChannel) {
return "/error/401";
}
});
MidPointAuthenticationSuccessHandler successHandler = new MidPointAuthenticationSuccessHandler() {
@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws ServletException, IOException {
if (getRequestCache().getRequest(request, response) == null) {
getRequestCache().saveRequest(request, response);
}
super.onAuthenticationSuccess(request, response, authentication);
}
};
filter.setAuthenticationSuccessHandler(getObjectPostProcessor().postProcess(successHandler));
filter.setSessionRegistry(getSessionRegistry());
return filter;
}
Aggregations