配置Springboot Cloud Config Server-management.security.enabled = false标志不起作用

时间:2019-07-10 11:05:00

标签: java spring spring-boot spring-security spring-config

我正在尝试实现Spring Boot云配置服务器。

我的application.properties文件:

#Server port
server.port=8888

#Git repo location.
spring.cloud.config.server.git.uri=/home/pawan/git/config-server-repo

#Disable security of the Management endpoint
management.security.enabled=false

主类:

@EnableConfigServer
@SpringBootApplication
public class ConfigServer {

    public static void main(String[] args) {
        SpringApplication.run(ConfigServer.class, args);
    }
}

问题是,当我尝试从浏览器网址(如http://localhost:8888/client-config/test)访问客户端配置属性时,我被重定向到登录页面。

config-server-browser-screenshot

配置服务器启动日志:

    > Task :bootRun
2019-07-10 16:14:29.117  INFO 8935 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$a652cf6] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.6.RELEASE)

2019-07-10 16:14:30.390  INFO 8935 --- [           main] com.bizlers.cloud.config.ConfigServer    : No active profile set, falling back to default profiles: default
2019-07-10 16:14:32.036  INFO 8935 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=6f9cbfc9-e5b5-3f1c-b6b3-2dde90ebde06
2019-07-10 16:14:32.107  INFO 8935 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$a652cf6] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-07-10 16:14:32.558  INFO 8935 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8888 (http)
2019-07-10 16:14:32.602  INFO 8935 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2019-07-10 16:14:32.603  INFO 8935 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.21]
2019-07-10 16:14:32.744  INFO 8935 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2019-07-10 16:14:32.744  INFO 8935 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 2335 ms
2019-07-10 16:14:34.095  INFO 8935 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2019-07-10 16:14:34.638  INFO 8935 --- [           main] .s.s.UserDetailsServiceAutoConfiguration : 

Using generated security password: 844bac77-1ec4-4f76-bebc-0460c3b36e6f

2019-07-10 16:14:34.773  INFO 8935 --- [           main] o.s.s.web.DefaultSecurityFilterChain     : Creating filter chain: any request, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@1ab53860, org.springframework.security.web.context.SecurityContextPersistenceFilter@3ffd4b12, org.springframework.security.web.header.HeaderWriterFilter@274fdea6, org.springframework.security.web.csrf.CsrfFilter@5d7f8467, org.springframework.security.web.authentication.logout.LogoutFilter@2dd0a0d0, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@24a04257, org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter@633ddc0c, org.springframework.security.web.authentication.ui.DefaultLogoutPageGeneratingFilter@7b5ac347, org.springframework.security.web.authentication.www.BasicAuthenticationFilter@6d6039df, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@2ad7bd26, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@76a6f045, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@57b9389f, org.springframework.security.web.session.SessionManagementFilter@2a484710, org.springframework.security.web.access.ExceptionTranslationFilter@3f6c2763, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@150d6eaf]
2019-07-10 16:14:34.808  INFO 8935 --- [           main] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 2 endpoint(s) beneath base path '/actuator'
2019-07-10 16:14:35.881  INFO 8935 --- [           main] o.s.cloud.commons.util.InetUtils         : Cannot determine local hostname
2019-07-10 16:14:36.223  INFO 8935 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8888 (http) with context path ''
2019-07-10 16:14:36.225  INFO 8935 --- [           main] com.bizlers.cloud.config.ConfigServer    : Started ConfigServer in 9.234 seconds (JVM running for 9.956)
2019-07-10 16:14:45.838  INFO 8935 --- [nio-8888-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2019-07-10 16:14:45.838  INFO 8935 --- [nio-8888-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2019-07-10 16:14:45.849  INFO 8935 --- [nio-8888-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 11 ms

我也曾尝试在application.properties中添加security.basic.enabled=false,但这无济于事。

依赖项:

  • springBootVersion ='2.1.6.RELEASE'
  • springCloudVersion =“ Greenwich.SR1”

1 个答案:

答案 0 :(得分:0)

management.security.enabled与Spring Boot执行器版本1一起使用。从Spring Boot 2开始,您必须/可以使用以下命令配置端点的安全性:

<dependency>
     <groupId>org.springframework.boot</groupId>
     <artifactId>spring-boot-starter-security</artifactId>
</dependency>

有关更多信息,请参见此链接:https://spring.io/guides/gs/securing-web/

我建议您检查安全配置,其中一项规则要求经过身份验证的用户。