[英]Spring Cloud Config Server/Client Security Issue
我有以下安全配置
服務器應用程序.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訪問屬性。 但是當我嘗試升級客戶端時,它說屬性未解決。 這里有什么問題嗎?
謝謝。
一段時間后,我能夠找到答案。 在僅具有該配置的配置服務器中,客戶端將被阻止。 所以必須禁用 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();
}
}
但是這里的默認安全性將被禁用。 這里的問題是如果用戶名或密碼從客戶端身份驗證發生更改。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.