简体   繁体   English

Spring Cloud Config Server 在运行 main() 时不强制执行 BASIC 身份验证

[英]Spring Cloud Config Server not enforcing BASIC Authentication when running main()

I have configured a Spring Cloud Config server to force BASIC authentication and here is my application.yml file:我已经配置了一个 Spring Cloud Config 服务器来强制进行 BASIC 身份验证,这是我的 application.yml 文件:

# Config Repo:
spring:
  cloud:
    config:
      server:
        git:
          uri: file:///${HOME}/microservices_config_repo

# Show sensitive information for endpoints:
endpoints:
  sensitive: true

# Security for endpoints:
management:
  security:
    enabled: true

security:
  user:
    name: user1
    password: changeme

My issue I am having is that when I start the server up as: mvn spring-boot:run我遇到的问题是当我启动服务器时: mvn spring-boot:run

The server endpoints FORCE BASIC Authentication.服务器端点强制基本身份验证。 But when I start the Application.main() method, BASIC Authentication is enabled, but NOT enforced.但是当我启动 Application.main() 方法时,启用了 BASIC 身份验证,但没有强制执行。

Meaning I can access configuration on: http://localhost:8888/client-config and http://user1:changeme@localhost:8888/client-config这意味着我可以访问配置: http://localhost:8888/client-confighttp://user1:changeme@localhost:8888/client-config

Can anyone help me understand why this is occuring and how to enforce BASIC Authentication while running the Application.main(), and not just through the Maven spring-boot plugin?谁能帮助我理解为什么会发生这种情况以及如何在运行 Application.main() 时强制执行 BASIC 身份验证,而不仅仅是通过 Maven spring-boot 插件?

Note, when I use maven to package the app into a jar, then run the generated jar, BASIC Authentication is enforced, but still not through the IDE running just the Application.main directly.注意,当我使用 maven 将应用程序打包成 jar,然后运行生成的 jar 时,会强制执行 BASIC Authentication,但仍然不是通过 IDE 直接运行 Application.main。

Maybe the format the oy Yaml for example to me seems works like this:也许 oy Yaml 的格式对我来说似乎是这样的:

server:
  port:9999
spring:
  application:
    name: config-server-sample
  cloud:
    config:
      name: ${spring.application.name}
      fail-fast: true
      server:
        git:
          uri: url
          username: xx
          password: zz
          default-label: master
          basedir: '${user.home}/${spring.application.name}/default'
          timeout: 10
          clone-on-start: true
          force-pull: true
  security:
    basic:
        enabled: true
    path: /**
    ignored: /health**,/info**,/metrics**,/trace**
    user:
       name: admin
       password: tupassword

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM