smt-spring-security-parent
This is the parent project that groups all the smt-spring-security libraries.
Libraries
smt-spring-security-jwt
This library will automatically enable stateless JWT authentication for any Spring Security configuration.
Usage
Annotation
@EnableWebSecurity
// Just add this annotation and configure Spring Security how ever you normally would.
@EnableJwtAuthentication
public class JwtSecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected final void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().anyRequest().authenticated();
http.formLogin().loginPage("/signIn").defaultSuccessUrl("/").permitAll();
http.logout().logoutUrl("/signOut").logoutSuccessUrl("/");
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication().withUser("user").password("password").roles("USER");
}
}
Adaptor
@EnableWebSecurity
public class JwtApplySecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected final void configure(HttpSecurity http) throws Exception {
// Just apply this adaptor and configure Spring Security how ever you normally would.
http.apply(jwt());
http.formLogin().loginPage("/signIn").defaultSuccessUrl("/").permitAll();
http.logout().logoutUrl("/jwt/signOut").logoutSuccessUrl("/");
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication().withUser("user").password("password").roles("USER");
}
}