Example usage for org.springframework.security.config.annotation.web.builders HttpSecurity formLogin

List of usage examples for org.springframework.security.config.annotation.web.builders HttpSecurity formLogin

Introduction

In this page you can find the example usage for org.springframework.security.config.annotation.web.builders HttpSecurity formLogin.

Prototype

public FormLoginConfigurer<HttpSecurity> formLogin() throws Exception 

Source Link

Document

Specifies to support form based authentication.

Usage

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:com.iservport.auth.SecurityWebConfig.java

@Override
protected void configure(HttpSecurity http) throws Exception {
    http.formLogin().loginPage("/login").failureUrl("/login?error=bad_credentials")
            .failureHandler(authenticationFailureHandler).permitAll().and()
            //habilita csrf e remember-me
            .csrf().disable()// www  .  j a v a 2  s.  c o  m
            //           .csrfTokenRepository(csrfTokenRepository())
            //          .and()
            .rememberMe().tokenRepository(persistentTokenRepository())
            .tokenValiditySeconds(REMEMBER_ME_DEFAULT_DURATION)
            //Configures the logout function
            .and().logout().deleteCookies("JSESSIONID").deleteCookies("remember-me")
            .deleteCookies("X-XSRF-TOKEN").logoutUrl("/logout").logoutSuccessUrl("/login").permitAll()
            //Configures url based authorization
            .and().authorizeRequests().antMatchers("/**").permitAll();
}

From source file:com.wiiyaya.consumer.web.initializer.config.SecurityConfig.java

private void configBackendFormLogin(HttpSecurity http) throws Exception {
    http.formLogin().loginPage(ConfigURIResource.PATH_LOGIN)
            .defaultSuccessUrl(ConfigURIResource.PATH_LOGIN_SUCCESS, true)
            //            .failureUrl(FwResource.PATH_LOGIN_FAILED)
            .permitAll().and().logout().logoutUrl(ConfigURIResource.PATH_LOGOUT)
            .addLogoutHandler(userCacheLogoutHandler())
            //            .logoutSuccessUrl(FwResource.PATH_LOGOUT_SUCCESS)
            .permitAll();/*from  ww w . j  a v  a 2  s . c  o  m*/
}

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 ww .  ja v a2 s .  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  ava  2s.  c o m
    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:de.dlopes.stocks.facilitator.config.SecurityConfig.java

@Override
protected void configure(HttpSecurity http) throws Exception {

    // retrieve configured contextPath for dispatcher servlet
    String cxtpth = config.getDispatcherServletCxtpth();

    http.formLogin().loginPage(cxtpth + "/login").loginProcessingUrl(cxtpth + "/loginProcess")
            .defaultSuccessUrl(cxtpth + "/stock-info").failureUrl(cxtpth + "/login?login_error=1").and()
            .logout().logoutUrl(cxtpth + "/logout").logoutSuccessUrl(cxtpth + "/index")

            // Disable CSRF (won't work with JSF) but ensure last HTTP POST request is saved
            // See https://jira.springsource.org/browse/SEC-2498

            .and().csrf().disable().requestCache().requestCache(new HttpSessionRequestCache());

}

From source file:shiver.me.timbers.spring.security.JwtSpringSecurityAdaptor.java

@Override
public void init(HttpSecurity http) throws Exception {
    autowireThis(http);//from   w w w  .j  a v a2s .co  m

    http.logout().addLogoutHandler(logoutHandler);
    fieldMutator.update(http.formLogin(), "authFilter", AbstractAuthenticationProcessingFilter.class,
            new UsernamePasswordAuthenticationFilterWrapper());
    http.addFilterBefore(authenticationFilter, UsernamePasswordAuthenticationFilter.class);
}

From source file:fi.helsinki.opintoni.config.LocalSecurityConfiguration.java

@Override
protected void configure(HttpSecurity http) throws Exception {
    http.csrf().disable();//ww  w . j a v 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.JwtCustomPrincipleSecurityConfigurationApply.java

@Override
protected final void configure(HttpSecurity http) throws Exception {
    http.apply(jwt());/*from  w  ww  .  j a  va  2  s.c o  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: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();/*from  w  w w. j a va 2 s . 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);

}