【问题标题】:Spring Cloud Config Server/Client Security IssueSpring Cloud 配置服务器/客户端安全问题
【发布时间】:2021-05-08 10:55:15
【问题描述】:

我有以下安全配置

服务器应用程序.yml

management:
    security:
        enabled: false
server:
    port: 8888
spring:
    cloud:
        config:
            server:
                jdbc:
                    order: 1
                    sql: SELECT prop_key,value FROM xlabs.properties where application=?
                        and profile=? and label=?
    datasource:
        password: XXXXX
        url: jdbc:postgresql://localhost:8000/finos?currentSchema=xlabs
        username: XXXXX
    profiles:
        active: jdbc
    security:
        user:
            name: mufg
            password: mufg

在客户端。

客户端应用程序.properties

server:
    port: 8082
spring:
    application:
        name: config-server
    cloud:
        config:
            label: latest
            profile: development
            uri: http://localhost:8888
            username: mufg
            password: mufg

使用此设置 配置服务器安全工作正常我可以在输入用户名和密码后通过 http://localhost:8888/config-server/development/latest 访问属性。但是当我尝试升级客户端时,它说属性未解决。这里有什么问题吗?

谢谢。

【问题讨论】:

    标签: spring-boot client-server spring-cloud spring-cloud-config


    【解决方案1】:

    经过一段时间后,我能够找到答案。在只有该配置的配置服务器中,客户端将被阻止。所以必须禁用 csrf 并允许任何请求,如下所示。

    只需添加服务器端。

    @Configuration
    public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
    
        @Override
        public void configure(HttpSecurity http) throws Exception {
            http
                    .csrf()
                    .disable()
                    .httpBasic()
                    .and()
                    .authorizeRequests()
                    .antMatchers("/encrypt/**").authenticated()
                    .antMatchers("/decrypt/**").authenticated();
            
        }
    }
    

    但是这里默认的安全性将被禁用。这里的问题是如果用户名或密码从客户端身份验证发生更改。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-27
      • 2016-09-12
      • 2015-07-13
      • 2020-02-04
      • 2020-07-23
      • 2018-02-15
      • 2016-11-26
      • 2021-02-26
      相关资源
      最近更新 更多