package com.example.springboot.actuator.security.config;

import java.util.Arrays;

import org.springframework.context.annotation.Bean;
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.core.userdetails.User;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;

@Configuration
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {

  @Bean
  public InMemoryUserDetailsManager inMemoryUserDetailsManager() {
    return new InMemoryUserDetailsManager(Arrays.asList(//
        User.withUsername("user") //
            .password("password") //
            .authorities("ROLE_USER") //
            .build(), //
        User.withUsername("admin") //
            .password("admin") //
            .authorities("ROLE_ACTUATOR", "ROLE_USER") //
            .build() //
    ));
  }

  @Override
  protected void configure(HttpSecurity http) throws Exception {
    http.authorizeRequests() //
//        .requestMatchers(EndpointRequest.to("status", "info")) //
//        .permitAll() //
//        .requestMatchers(EndpointRequest.toAnyEndpoint()) //
//        .hasRole("ACTUATOR") //
//        .requestMatchers(StaticResourceRequest.toCommonLocations()) //
//        .permitAll() //
        .antMatchers("/foo") //
        .permitAll() //
        .antMatchers("/**") //
        .hasRole("USER") //
        .and() //
        .cors() //
        .and() //
        .httpBasic();
  }

}

@@ -1177,26 +1177,24 @@
 uests() //%0D%0A
-//
         .req
@@ -1182,38 +1182,34 @@
 () //%0D%0A        .
-reques
+an
 tMatchers(Endpoi
@@ -1206,28 +1206,10 @@
 ers(
-EndpointRequest.to(
 %22
+/
 stat
@@ -1218,22 +1218,17 @@
 %22, %22
+/
 info%22)
-) //%0D%0A//
+%0D%0A
     
@@ -1244,26 +1244,24 @@
 itAll() //%0D%0A
-//
         .req
@@ -1249,38 +1249,34 @@
 () //%0D%0A        .
-reques
+an
 tMatchers(Endpoi
@@ -1273,47 +1273,18 @@
 ers(
-EndpointRequest.toAnyEndpoint()
+%22/*%22
 ) //%0D%0A
-//
     
@@ -1308,26 +1308,24 @@
 UATOR%22) //%0D%0A
-//
         .req
@@ -1325,14 +1325,10 @@
    .
-reques
+an
 tMat
@@ -1337,57 +1337,81 @@
 ers(
-StaticResourceRequest.toCommonLocations()
+%22/css/**%22, %22/js/**%22, %22/images/**%22, %22/webjars/**%22, %22/**/favicon.ico%22
 ) //%0D%0A
-//
     

add security config.