com.iovation.launchkey.sdk.example.springmvc.SecurityConfig Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sdk-examples-spring-mvc Show documentation
Show all versions of sdk-examples-spring-mvc Show documentation
Example application for using the LaunchKey SDK in a Spring MVC application
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