Browse Source
The management security autoconfiguration wanted to come last in the chain but that won't suit the fallback that was already in place for gh-568. This change re-orders the autoconfig so that @EnableWebSecurity is still added if the user sets security.basic.enabled=false and includes the actuator endpoints. Fixes gh-568pull/578/merge
5 changed files with 52 additions and 24 deletions
@ -0,0 +1,46 @@ |
|||||||
|
/* |
||||||
|
* Copyright 2012-2013 the original author or authors. |
||||||
|
* |
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
* you may not use this file except in compliance with the License. |
||||||
|
* You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
package org.springframework.boot.autoconfigure.security; |
||||||
|
|
||||||
|
import org.springframework.boot.autoconfigure.AutoConfigureAfter; |
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; |
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; |
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; |
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; |
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; |
||||||
|
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; |
||||||
|
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration; |
||||||
|
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; |
||||||
|
|
||||||
|
/** |
||||||
|
* If the user explicitly disables the basic security features and forgets to |
||||||
|
* <code>@EnableWebSecurity</code>, and yet still wants a bean of type |
||||||
|
* WebSecurityConfigurerAdapter, he is trying to use a custom security setup. The app |
||||||
|
* would fail in a confusing way without this shim configuration, which just helpfully |
||||||
|
* defines an empty <code>@EnableWebSecurity</code>. |
||||||
|
* |
||||||
|
* @author Dave Syer |
||||||
|
*/ |
||||||
|
@ConditionalOnExpression("!${security.basic.enabled:true}") |
||||||
|
@ConditionalOnBean(WebSecurityConfigurerAdapter.class) |
||||||
|
@ConditionalOnClass(EnableWebSecurity.class) |
||||||
|
@ConditionalOnMissingBean(WebSecurityConfiguration.class) |
||||||
|
@ConditionalOnWebApplication |
||||||
|
@AutoConfigureAfter(SecurityAutoConfiguration.class) |
||||||
|
@EnableWebSecurity |
||||||
|
public class FallbackWebSecurityAutoConfiguration { |
||||||
|
} |
||||||
Loading…
Reference in new issue