@Override protected void configure(HttpSecurity http) throws Exception { SimpleUrlAuthenticationSuccessHandler authSuccessHandler = new SimpleUrlAuthenticationSuccessHandler(); authSuccessHandler.setUseReferer(true); http.authorizeRequests() .antMatchers("/login").permitAll() .anyRequest().authenticated() .and().formLogin().defaultSuccessUrl("/test", true); }
@Override protected void configure(HttpSecurity http) throws Exception { SimpleUrlAuthenticationSuccessHandler simpleUrlAuthenticationSuccessHandler = new SimpleUrlAuthenticationSuccessHandler("/"); simpleUrlAuthenticationSuccessHandler.setUseReferer(false); simpleUrlAuthenticationSuccessHandler.setTargetUrlParameter("url"); DefaultRedirectStrategy defaultRedirectStrategy = new DefaultRedirectStrategy(); simpleUrlAuthenticationSuccessHandler.setRedirectStrategy(defaultRedirectStrategy); SimpleUrlLogoutSuccessHandler simpleUrlLogoutSuccessHandler = new SimpleUrlLogoutSuccessHandler(); simpleUrlLogoutSuccessHandler.setUseReferer(true); // @formatter:off http .authorizeRequests() .antMatchers(ckfinder.getServlet().getPath()).hasAnyRole("ADMIN") .and() .csrf() .disable() .exceptionHandling() .authenticationEntryPoint(authenticationEntryPoint()) .and() .formLogin() .loginPage("/login") .usernameParameter("user_id1") .passwordParameter("password1") .successHandler(simpleUrlAuthenticationSuccessHandler) .failureHandler(failureHandler()) .permitAll() .and() .headers() .cacheControl().disable() .httpStrictTransportSecurity().disable() .frameOptions().sameOrigin() .and() .logout() .logoutUrl("/logout.html") .logoutSuccessHandler(simpleUrlLogoutSuccessHandler) .permitAll() .and() .rememberMe() .rememberMeParameter("rememberMe") .tokenRepository(persistentTokenRepository) .and() .requestCache() .requestCache(new NullRequestCache()) .and() .servletApi(); // @formatter:on }
private AuthenticationSuccessHandler getSuccessHandler() { SimpleUrlAuthenticationSuccessHandler successHandler = new SimpleUrlAuthenticationSuccessHandler( "/"); successHandler.setTargetUrlParameter("redirect"); return successHandler; }
@Bean public SimpleUrlAuthenticationSuccessHandler pac4jAuthenticationSuccessHandler() { return new Pac4jAuthenticationSuccessHandler(); }