Skip to content

Management security configuration does not back off when SAML is configured #21620

@brettryan

Description

@brettryan

Spring actuator will disable any configuration that has been specified in the spring boot configuration YAML file unless you have an explicit WebSecurityConfigurerAdapter defined.

It took me a while to figure out why specifically integrating the new Spring Security 5.2 native support for saml2login which is demonstrated in the minimalist sample application. Simply adding actuator to that application will disable saml2. The reasons are the rules associated with the rules associated with ManagementWebSecurityAutoConfiguration.

@Configuration(proxyBeanMethods = false)
@ConditionalOnClass(WebSecurityConfigurerAdapter.class)
@ConditionalOnMissingBean(WebSecurityConfigurerAdapter.class)
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
@AutoConfigureBefore(SecurityAutoConfiguration.class)
@AutoConfigureAfter({ HealthEndpointAutoConfiguration.class, InfoEndpointAutoConfiguration.class,
		WebEndpointAutoConfiguration.class, OAuth2ClientAutoConfiguration.class,
		OAuth2ResourceServerAutoConfiguration.class })
@Import({ ManagementWebSecurityConfigurerAdapter.class, WebSecurityEnablerConfiguration.class })
public class ManagementWebSecurityAutoConfiguration {}

There are several problems with this:

  1. Boot tries to get configuration into the config files, not into the context of the application.
  2. It is defined to perform this configuration before SecurityAutoConfiguration which is again trying to circumvent the users configuration and enforce the configuration defined by actuator.
  3. The underlying cause is the forceful nature of ManagementWebSecurityConfigurerAdapter enforcing forms based authentication.

In this the simplest separation of concerns is to NOT perform the following in ManagementWebSecurityConfigurerAdapter:

http.formLogin(Customizer.withDefaults());
http.httpBasic(Customizer.withDefaults());

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions