Skip to content

This is the parent project that groups all the smt-spring-security projects.

License

Notifications You must be signed in to change notification settings

shiver-me-timbers/smt-spring-security-parent

Repository files navigation

smt-spring-security-parent

Build Status Coverage Status Maven Central

This is the parent project that groups all the smt-spring-security libraries.

Libraries

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");
    }
}

About

This is the parent project that groups all the smt-spring-security projects.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages