Created
March 31, 2019 12:48
-
-
Save talfco/16541994f51c444c0618b355678498fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.cloudburo.app; | |
import org.springframework.boot.actuate.autoconfigure.security.servlet.EndpointRequest; | |
import org.springframework.boot.actuate.health.HealthEndpoint; | |
import org.springframework.boot.actuate.info.InfoEndpoint; | |
import org.springframework.context.annotation.Configuration; | |
import org.springframework.security.config.annotation.web.builders.HttpSecurity; | |
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; | |
import org.springframework.security.config.http.SessionCreationPolicy; | |
@Configuration | |
public class SecurityConfiguration extends WebSecurityConfigurerAdapter { | |
@Override | |
protected void configure(HttpSecurity http) throws Exception { | |
http | |
.authorizeRequests() | |
.requestMatchers(EndpointRequest.to(InfoEndpoint.class, HealthEndpoint.class)).permitAll() | |
.requestMatchers(EndpointRequest.toAnyEndpoint()).hasRole("ACTUATOR") | |
.antMatchers("/*-api/**").hasRole("REST") | |
.anyRequest().authenticated() | |
.and() | |
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.NEVER).and() | |
.csrf().disable() | |
.httpBasic(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment