All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.iovation.launchkey.sdk.example.springmvc.SecurityConfig Maven / Gradle / Ivy

There is a newer version: 4.8.0
Show newest version
package com.iovation.launchkey.sdk.example.springmvc;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;

@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    private LogoutSuccessHandler logoutSuccessHandler;

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests()
                .antMatchers("/favicon.ico", "/webhook", "/authorized", "/images/**").permitAll()
                .anyRequest().authenticated()
                .and().formLogin().loginPage("/login").permitAll()
                .and().logout().permitAll().logoutSuccessHandler(logoutSuccessHandler)
                .and().csrf().ignoringAntMatchers("/webhook", "/authorized");
    }


    @Autowired
    public void configureGlobal(AuthenticationManagerBuilder auth, AuthManager authManager, LogoutSuccessHandler logoutSuccessHandler) throws Exception {
        this.logoutSuccessHandler = logoutSuccessHandler;
        auth.authenticationProvider(new LaunchKeyAuthenticationProvider(authManager));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy