Skip to content

Instantly share code, notes, and snippets.

@ugurcemozturk
Created December 6, 2017 10:08
Show Gist options
  • Save ugurcemozturk/93fde24874d4bb9e34e7cd1b7711fe38 to your computer and use it in GitHub Desktop.
Save ugurcemozturk/93fde24874d4bb9e34e7cd1b7711fe38 to your computer and use it in GitHub Desktop.
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable().authorizeRequests()
.antMatchers("/").permitAll()
.antMatchers(HttpMethod.POST, "/login").permitAll()
.anyRequest().authenticated()
.and()
.addFilterBefore(new JWTLoginFilter("/login", authenticationManager()),
UsernamePasswordAuthenticationFilter.class)
.addFilterBefore(new JWTAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class);
}
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication()
.withUser("cem")
.password("pass")
.roles("ADMIN");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment