2

I've integrated SBA to the project. Without any authentication all clients register for SBA server and I can see all actuator endpoints, which I've opened. I wish to have login page at SBA admin page and wish open registration only for SBA clients with proper permissions. I've added user/password properties at both sides, according to SBA documentation. If I just add at SBA server user and password, and the same user and password I also configure for all SBA clients, all clients got responses 403 FORBIDDEN Failed to register application as Application() SBA server part: application.properties

    spring.security.user.name=admin
    spring.security.user.password=admin

    spring.boot.admin.client.instance.metadata.user.name=admin
    spring.boot.admin.client.instance.metadata.user.password=admin
    server.port=8090

    management.endpoints.web.exposure.include=
    management.endpoints.web.base-path=/_manage
    management.endpoints.jmx.exposure.include=
    management.endpoint.shutdown.enabled=true
    management.server.port=8090

security configuration with opened permissions to /instances

    @Configuration
    @ConditionalOnProperty(value = "spring.security.enabled", havingValue = "true")
    @EnableWebSecurity
    public class WebSecurityConfig  extends WebSecurityConfigurerAdapter {

      @Override
      protected void configure(HttpSecurity http) throws Exception {
        http
            .formLogin()
            .loginPage("/login.html")
            .loginProcessingUrl("/login")
            .permitAll();
        http
            .logout().logoutUrl("/logout");
        http
            .csrf().disable();
        http
            .authorizeRequests()
            .antMatchers("/login.html", "/** ** /** .css", "/img/** ** ", "/third-party/** ** ")
            .permitAll();
        http
            .authorizeRequests()
            .antMatchers("/instances")
            .permitAll();
            //.authenticated();
        http.httpBasic();
      }
    }

SBA client has the same user and password, to be able to register at SBA server: application.properties


    instance.name=clientdemo
    feed.generation.type=CLIENTDEMO

    spring.boot.admin.url=http://localhost:8090
    spring.boot.admin.client.url=http://localhost:8090  

    spring.boot.admin.client.username=admin
    spring.boot.admin.client.password=admin
    spring.security.user.name=admin
    spring.security.user.password=admin

    server.port=8091
    # ACTUATOR
    management.endpoints.web.exposure.include=*
    #management.endpoints.web.base-path=/_manage
    management.endpoint.shutdown.enabled=true
    management.server.port=8091

As result at SBA client side I see from the logs an error :

    : Writing [Application(name=demo-worker, managementUrl=http://http://localhost:8091/actuator, healthUrl=http://localhost:8091/actuator/health, serviceUrl=http://localhost:8091/)] as "application/json"
    : sun.net.www.MessageHeader@4089d6fd8 pairs: {POST /instances HTTP/1.1: null}{Accept: application/json}{Content-Type: application/json}{Authorization: Basic YWRtaW46YWRtaW4=}{User-Agent: Java/1.8.0_211}{Host: localhost:8090}{Connection: keep-alive}{Content-Length: 267}
    : sun.net.www.MessageHeader@50cf05ff11 pairs: {null: HTTP/1.1 403}{Content-Type: text/plain}{Cache-Control: no-cache, no-store, max-age=0, must-revalidate}{Pragma: no-cache}{Expires: 0}{X-Content-Type-Options: nosniff}{X-Frame-Options: DENY}{X-XSS-Protection: 1 ; mode=block}{Referrer-Policy: no-referrer}{Transfer-Encoding: chunked}{Date: Wed, 13 Nov 2019 12:48:32 GMT}
    : Response 403 FORBIDDEN
    : Failed to register application as Application(name=demo-worker, managementUrl=http://localhost:8091/actuator, healthUrl=http://localhost:8091/actuator/health, serviceUrl=http://localhost:8091/) at spring-boot-admin ([http://localhost:8090/instances]): 403 null
    : HTTP POST http://localhost:8090/instances
    : Accept=[application/json, application/*+json]

And from SBA server side I see at the logs :

    {"name":"demo-worker","managementUrl":"http://localhost:8091/actuator","healthUrl":"http://localhost:8091/actuator/health","serviceUrl":"http://localhost:8091/","metadata":o.a.c.a.AuthenticatorBase: Security checking request POST /instances

My SBA server is registered at port 8090 and SBA client is registered at port 8091.

1 Answers1

0

you should add this: .antMatchers(HttpMethod.POST, "/actuator/**") .permitAll()