2

저는 Spring Cloud Dalston으로 최근에 업그레이드되었으므로 스프링 부트 1.5.1을 의미하며 더 이상 oauth2 범위를 검사하여 관리 끝점을 보호 할 수 없습니다. Spring Cloud Camden에서 이전에 작동했습니다. 스프링 액추에이터 관리 끝점을 확보하기 위해 역할 대신 oauth2 범위를 사용하십시오.

전에 일한 구성입니다 :

@Configuration 
public class SecurityConfiguration extends ResourceServerConfigurerAdapter { 

    @Value("${management.context-path}") 
    private String managementContextPath; 

    @Override 
    public void configure(HttpSecurity http) throws Exception { 
     http.authorizeRequests() 
       // some paths I don't want to secure at all 
       .antMatchers("/path1/**", "/path2/**").permitAll() 
       // access to health endpoint is open to anyone 
       .antMatchers(HttpMethod.GET, managementContextPath + "/health").permitAll() 
       // but app.admin scope is necessary for other management endpoints 
       .antMatchers(managementContextPath + "/**").access("#oauth2.hasScope('my-super-scope')") // 
       // And we make sure the user is authenticated for all the other cases 
       .anyRequest().authenticated(); 
    } 
} 

그리고 이것은 설정의 중요한 부분입니다 : 내가 /my-context/refresh에 POST 할 때

security: 
    oauth2: 
    client: 
     clientId: a-client 
     clientSecret: the-client-password 
    resource: 
     tokenInfoUri: http://my-spring-oauth2-provider/oauth/check_token 

management: 
    context-path: /my-context 
    security: 
    enabled: true 
endpoints: 
    health: 
    sensitive: false 

가 나는 HTTP 401 "전체를 얻을 수 유효한 OAuth2 토큰을 제공하더라도 인증이 필요합니다.

로그를보고 보면 내 요청이 익명으로 처리되어 Fi lterChainProxy 로그에서 OAuth2AuthenticationProcessingFilter이 호출되지 않았 음을 알았습니다. I found that I could change the oauth2 resource filter order 파기 조금 후에, 나는 그것을 시도하고 이제 OAuth2 인증을 가지고, 예, 맞아 끝났어?

흠, 아니요, 이제 Access is denied. User must have one of the these roles: ACTUATOR 오류가 있습니다.

관리 보안을 사용하지 않도록 설정했는데 (내 규칙이 적용되지 않고 액세스가 모든 사람에게 공개됨), (변경 사항 없음) @Order (노 변경)을 가지고 놀았으며, 심지어는 reading and applying the documentation 말한다 :

응용 프로그램 액세스 규칙 유형 WebSecurityConfigurerAdapter의 @Bean을 추가하고 재정에 액추에이터 액세스 규칙을 원하지 않는 경우 @Order (SecurityProperties.ACCESS_OVERRIDE_ORDER)를 사용하거나 @Order 무시하려면 (ManagementServerProperties.ACCESS_OVERRIDE_ORDER) 할 경우 하려는 액추에이터 액세스 규칙을 무시하십시오. User must have one of these roles: ACTUATOR

아무도 해결/생각이 있습니까 :

하지만이 오류를 변경하지 않은?


업데이트 : 나는 또한 Zuul를 사용하고, 그래서 결국, 그렇지 않으면 노출되지 않은 다른 백엔드 서비스에서 특정 zuul 나는 (내 경우에는 클라우드 버스 새로 고침)를 필요로하는 엔드 포인트 경로 보호를 생성 oauth2로 경로를 보호했습니다.

그럼에도 불구하고 아무도 해결 방법을 찾으면 유용 할 수 있습니다.

+0

행운이 있나요? 나는 비슷한 문제에 직면하고있다. –

+0

아니 슬프게도, 나는 Dalston을 원했다 .RC1은 이것을 고칠 것이나 운은 없다. 나는 곧 다시 확인 하겠지만, 그 동안 무언가를 발견하면 나는 정말로 interrested입니다. :) –

답변

1

아마도 캡틴이 분명 할 수도 있지만, http://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-monitoring.html을 참조하십시오. management.security.roles를 사용하여 역할을 재정의하고 Oauth2 자격 증명의 역할을 간단히 추가 할 수 있습니다.

+1

이 링크가 질문에 대답 할 수 있지만 여기에 답의 핵심 부분을 포함시키고 참고. 링크 된 페이지가 변경되면 [링크 전용] (https://meta.stackexchange.com/tags/link-only-answers/info) 답변이 무효화 될 수 있습니다. – mmichael

+0

고마워요.하지만, # oauth2.hasScope ('my-super-scope')와 같이 범위를 검사하고 싶지는 않았습니다. –