List of usage examples for org.springframework.security.config.annotation.web.builders HttpSecurity logout
public LogoutConfigurer<HttpSecurity> logout() throws Exception
From source file:com.chortitzer.web.WebSecurityConfig.java
@Override protected void configure(HttpSecurity http) throws Exception { // Have to disable it for POST methods: // http://stackoverflow.com/a/20608149/1199132 http.csrf().disable();//from w w w.j a v a2 s .c om // Logout and redirection: // http://stackoverflow.com/a/24987207/1199132 http.logout().logoutRequestMatcher(new AntPathRequestMatcher("/logout")).invalidateHttpSession(true) .logoutSuccessUrl("/login.xhtml"); http.authorizeRequests() // Some filters enabling url regex: // http://stackoverflow.com/a/8911284/1199132 .regexMatchers("\\A/page1.xhtml\\?param1=true\\Z", "\\A/page2.xhtml.*").permitAll() //Permit access for all to error and denied views .antMatchers("/500.xhtml", "/denied.xhtml").permitAll() // Only access with admin role .antMatchers("/admin/**").hasRole("ADMIN") //Permit access only for some roles .antMatchers("/usi/**").hasAnyRole("ADMIN", "energia") //If user doesn't have permission, forward him to login page .and().formLogin().loginPage("/login.xhtml").loginProcessingUrl("/login") .defaultSuccessUrl("/index.xhtml").and().exceptionHandling().accessDeniedPage("/denied.xhtml"); }
From source file:shiver.me.timbers.spring.security.integration.SpringSecurityConfiguration.java
@Override protected final void configure(HttpSecurity http) throws Exception { http.antMatcher("/normal/**"); http.csrf().disable();/*w w w. ja v a 2s . c o m*/ http.authorizeRequests().anyRequest().authenticated(); http.formLogin().successHandler(new NoRedirectAuthenticationSuccessHandler()).loginPage("/normal/signIn") .permitAll(); http.logout().logoutUrl("/normal/signOut") .logoutSuccessHandler(new HttpStatusReturningLogoutSuccessHandler()); http.exceptionHandling().authenticationEntryPoint(new Http403ForbiddenEntryPoint()); }
From source file:shiver.me.timbers.spring.security.integration.JwtCustomPrincipleSecurityConfigurationAnnotation.java
@Override protected final void configure(HttpSecurity http) throws Exception { http.antMatcher("/custom/**"); http.csrf().disable();//from w w w.j a v a 2s .c om http.authorizeRequests().anyRequest().authenticated(); http.formLogin().successHandler(new NoRedirectAuthenticationSuccessHandler()).loginPage("/custom/signIn") .permitAll(); http.logout().logoutUrl("/custom/signOut") .logoutSuccessHandler(new HttpStatusReturningLogoutSuccessHandler()); http.exceptionHandling().authenticationEntryPoint(new Http403ForbiddenEntryPoint()); }
From source file:oobbit.security.SecurityConfig.java
@Override protected void configure(HttpSecurity http) throws Exception { // Oletuksena saa tehd mit haluaa http.authorizeRequests().anyRequest().permitAll(); http.formLogin().loginPage("/login").loginProcessingUrl("/authenticate").defaultSuccessUrl("/me") .usernameParameter("username").passwordParameter("password").permitAll(); http.logout().logoutUrl("/logout").logoutSuccessUrl("/login").permitAll().invalidateHttpSession(true); }
From source file:shiver.me.timbers.spring.security.integration.JwtCustomPrincipleSecurityConfigurationApply.java
@Override protected final void configure(HttpSecurity http) throws Exception { http.apply(jwt());/* w w w. ja v a 2 s . co m*/ http.antMatcher("/custom/**"); http.csrf().disable(); http.authorizeRequests().anyRequest().authenticated(); http.formLogin().successHandler(new NoRedirectAuthenticationSuccessHandler()).loginPage("/custom/signIn") .permitAll(); http.logout().logoutUrl("/custom/signOut") .logoutSuccessHandler(new HttpStatusReturningLogoutSuccessHandler()); http.exceptionHandling().authenticationEntryPoint(new Http403ForbiddenEntryPoint()); }
From source file:shiver.me.timbers.spring.security.integration.AllAnnotationAuthenticationConfiguration.java
@Override protected final void configure(HttpSecurity http) throws Exception { http.antMatcher("/all/**"); http.csrf().disable();// w ww . ja v a 2 s.c om http.authorizeRequests().antMatchers("/all/one").access("hasRole('ONE')").antMatchers("/all/two") .access("hasRole('TWO')").anyRequest().authenticated(); http.formLogin().successHandler(new NoRedirectAuthenticationSuccessHandler()).loginPage("/all/signIn") .permitAll(); http.logout().logoutUrl("/all/signOut").logoutSuccessHandler(new HttpStatusReturningLogoutSuccessHandler()); http.exceptionHandling().authenticationEntryPoint(new Http403ForbiddenEntryPoint()); }
From source file:com.github.fedorchuck.webstore.config.SecurityConfig.java
@Override protected void configure(HttpSecurity http) throws Exception { http.csrf().disable().authorizeRequests().antMatchers("/resources/**", "/**").permitAll().anyRequest() .permitAll().and();//ww w. j a v a 2s.c o m http.formLogin().loginPage("/login").loginProcessingUrl("/j_spring_security_check") .failureUrl("/login?error").usernameParameter("j_username").passwordParameter("j_password") .permitAll(); http.logout().permitAll().logoutUrl("/user/logout")//.logoutUrl("/logout") .logoutSuccessUrl("/user/authorize")//.logoutSuccessUrl("/login?logout") .invalidateHttpSession(true); }
From source file:shiver.me.timbers.spring.security.integration.StormpathAuthenticationConfiguration.java
@Override protected final void configure(HttpSecurity http) throws Exception { http.antMatcher("/stormpath/**"); http.csrf().disable();/*from w w w.j a va 2 s .com*/ http.authorizeRequests().antMatchers("/stormpath/one").access("hasRole('ONE')") .antMatchers("/stormpath/two").access("hasRole('TWO')").anyRequest().authenticated(); http.formLogin().successHandler(new NoRedirectAuthenticationSuccessHandler()).loginPage("/stormpath/signIn") .permitAll(); http.logout().logoutUrl("/stormpath/signOut") .logoutSuccessHandler(new HttpStatusReturningLogoutSuccessHandler()); http.exceptionHandling().authenticationEntryPoint(new Http403ForbiddenEntryPoint()); }
From source file:fi.helsinki.opintoni.config.LocalSecurityConfiguration.java
@Override protected void configure(HttpSecurity http) throws Exception { http.csrf().disable();// w w w .j av a 2 s . c o m http.exceptionHandling().authenticationEntryPoint(authenticationEntryPoint); http.formLogin().permitAll().loginPage("/login").loginProcessingUrl("/login").usernameParameter("username") .passwordParameter("password").successHandler(authSuccessHandler) .failureHandler(authFailureHandler); http.logout().logoutUrl("/logout").permitAll().logoutSuccessHandler(localLogoutSuccessHandler); http.sessionManagement().maximumSessions(1); http.authorizeRequests().antMatchers("/").permitAll().antMatchers("/error").permitAll() .antMatchers("/login").permitAll().antMatchers("/redirect").permitAll() .antMatchers("/api/public/v1/**").permitAll().antMatchers("/api/private/v1/admin/*") .hasIpAddress("127.0.0.1").antMatchers("/api/admin/**").access(Constants.ADMIN_ROLE_REQUIRED) .anyRequest().authenticated(); }
From source file:shiver.me.timbers.spring.security.integration.AllApplyAuthenticationConfiguration.java
@Override protected final void configure(HttpSecurity http) throws Exception { http.apply(jwt());/* w ww . ja v a2 s . c om*/ http.antMatcher("/all/**"); http.csrf().disable(); http.authorizeRequests().antMatchers("/all/one").access("hasRole('ONE')").antMatchers("/all/two") .access("hasRole('TWO')").anyRequest().authenticated(); http.formLogin().successHandler(new NoRedirectAuthenticationSuccessHandler()).loginPage("/all/signIn") .permitAll(); http.logout().logoutUrl("/all/signOut").logoutSuccessHandler(new HttpStatusReturningLogoutSuccessHandler()); http.exceptionHandling().authenticationEntryPoint(new Http403ForbiddenEntryPoint()); }