Skip to content

Instantly share code, notes, and snippets.

@MrSnyder
Last active February 4, 2020 16:06
Show Gist options
  • Save MrSnyder/0a72a2d0eae431fa8a605307640e8658 to your computer and use it in GitHub Desktop.
Save MrSnyder/0a72a2d0eae431fa8a605307640e8658 to your computer and use it in GitHub Desktop.
Spring Security Cheatsheet

Spring Security Cheatsheet

HttpSecurity

	@Override
	protected void configure(HttpSecurity http) throws Exception {
	    http
	        .authorizeRequests()
	            .antMatchers("/", "/images/**", "/styles.css", "/webjars/**").permitAll()
	            .antMatchers("/books", "/books/search").hasAnyRole("ADMIN", "CUSTOMER")
	            .anyRequest().hasRole("ADMIN") // ANY OTHER REQUEST NOT MATCHED ABOVE!
	            .and()
	        .formLogin()
	            .and()
	        .httpBasic();
	}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment