스프링 시큐리티는 봄 클라우드 구성 서버에서 활성화 될 때 봄 클라우드 구성 클라이언트 설정을 가져 오는 없습니다

느고 혼 :

나는 봄 보안없이 봄 클라우드 설정 서버를 실행하면 서비스가 문제없이 설정을 가져옵니다하지만 난 봄 보안을 활성화 할 때이 설정 파일을 가져 오지 않습니다. 401 HTTP 오류를 던질 것으로 보인다. 같은 문제와 함께 인증의 암호 @ URL 방법 : I는 사용자 이름과 암호가 올바른지 확인, 나는 또한 사용자를 시도했다.

내가 URL을 액세스하는 경우 http://localhost:8888/service/default브라우저에서 직접 사용자 이름과 암호를 입력 CONFIGS이 표시됩니다.

어떤 도움을 내 클라우드 설정 또는 내 보안 설정에 문제가있는 경우에 나는 확실하지 않다, 이해할 수있을 것이다.

봄 부트 버전 '2.2.4.RELEASE'
스프링 클라우드 설정 서버 버전 '2.2.1.RELEASE'
빌드 시스템 : Gradle을
자바 (8)

이 설정은 항상 내가 내가 가진 기존 서비스에 추가 시도하고 나는 새로운 설정 서버 및 새로운 클라이언트를 생성 등등 초기화 봄 통해 작동하지 않았다, 실패 https://start.spring.io/ 설정 아래로 및 여전히 작동하지 않습니다.

보안이 활성화 된 경우 로그 :

2020-02-19 14:29:16.553  INFO 14996 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8888
2020-02-19 14:29:16.577 DEBUG 14996 --- [           main] o.s.web.client.RestTemplate              : HTTP GET http://localhost:8888/service/default
2020-02-19 14:29:16.634 DEBUG 14996 --- [           main] o.s.web.client.RestTemplate              : Accept=[application/json, application/*+json]
2020-02-19 14:29:16.647 DEBUG 14996 --- [           main] o.s.web.client.RestTemplate              : Response 401 UNAUTHORIZED
2020-02-19 14:29:16.652  WARN 14996 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Could not locate PropertySource: 401 : [{"timestamp":"2020-02-19T12:29:16.642+0000","status":401,"error":"Unauthorized","message":"Unauthorized","path":"/service/default"}]

보안이 비활성화 로그인 할 때 / 모든 허용

2020-02-19 12:43:13.756  INFO 4972 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8888
2020-02-19 12:43:17.563  INFO 4972 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=service, profiles=[default], label=null, version=fb9ccb6e46098bfe425130d6447a0797206e5c2f, state=null

설정 서버 application.yml 파일
GitHub의이 URI는 개인의 repo에 연결이 문제가되지 않습니다, 가려한다.

server:
  port: 8888

spring:
  application:
    name: config-server
  security:
    user:
      name: 'root'
      password: '1234'
  cloud:
    config:
      server:
        git:
          uri: <github-uri>
          ignore-local-ssh-settings: false
          strict-host-key-checking: false
          private-key: 'classpath:resources/id_rsa'

서비스 application.yml 파일

spring:
  application:
    name: service
  cloud:
    config:
      uri: http://localhost:8888
      username: 'root'
      password: '1234'
      fail-fast: true

웹 보안은 매우 기본적이지만 아래의 보안 설정입니다 :

@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    // Secure the endpoints with HTTP Basic authentication
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests().antMatchers("/**").fullyAuthenticated();
        http.httpBasic().and().exceptionHandling();
    }
}
nmyk :

당신은 사용해야합니다 bootstrap.yaml(하지 application.yaml클라이언트 앱).

그것은 당신의 클라이언트가 사용자 이름과 암호가없는 기본 설정을 사용하는 경우에만 있기 때문에 보안없이 작동합니다. 보안을 사용하면 기본 사용자 이름과 암호가 비어 있기 때문에 401를 반환합니다.

추천

출처http://10.200.1.11:23101/article/api/json?id=478756&siteId=1