Cloud Foundry에 배포되는 SpringBoot에 응용 프로그램이 있습니다. 그것은 VCAP_SERVICES에 보안 관련 데이터를 받기 위해 application.properties 파일에서 사용할 수있는 정보를 첨부하는 바운드 서비스를 가지고 있습니다.CF 환경에서 @ConfigurationProperties를 사용하여 JSON을 중첩했습니다.
이 서비스 변수는 전체 VCAP_SERVICE 환경 변수의 user-provided
하위 JSON에 있고 다음과 같습니다 : 내 application.properties에서
"user-provided": [
{
"credentials": {
"auth-scopes": {
"group-1": "superadmin",
"group-2": "admin"
},
"base64ClientCredential": "SSBBTSBOT1QgVEhBVCBTSUxMWSA6LUQ=",
"client-id": "my-app",
"client-secret": "g1234567890",
"token-info-uri": "https://XYZ.predix.io/check_token",
"user-info-uri": "https://XYZ.predix.io/userinfo"
},
"label": "user-provided",
"name": "my-app-creds",
"syslog_drain_url": "",
"tags": [],
"volume_mounts": []
}
]
내가
security.properties.client-id=${vcap.services.my-app-creds.credentials.client-id}
security.properties.client-secret=${vcap.services.my-app-creds.credentials.client-secret}
security.properties.token-info-uri=${vcap.services.my-app-creds.credentials.token-info-uri}
security.properties.user-info-uri=${vcap.services.my-app-creds.credentials.user-info-uri}
security.properties.auth-scopes=${vcap.services.my-app-creds.credentials.auth-scopes}
이 나는 또한 생성 된 클래스 SecurityProperties
Java에서 이러한 속성 및 저장소를 읽습니다.
@Component
@PropertySource("classpath:application.properties")
@ConfigurationProperties(prefix = "security.properties")
public class SecurityProperties {
String clientId;
String clientSecret;
String tokenInfoUri;
String userInfoUri;
//Required getters and setters
}
그리고이 클래스는 성공적으로 해당 필드를 application.properties
에서받은 정보에 바인딩합니다.
내가지도 수신 할 때 문제가 발생합니다 : 내가 SecurityProperties
클래스 필드에 추가 시도
"auth-scopes": {
"group-1": "superadmin",
"group-2": "admin"
}
을 :
HashMap<String, String> authScopes;
하지만
나는 또한 내부 클래스
으로 시도 실패AuthScopes authScopes;
public static class AuthScopes {
//various different implementations
//to read this but no success at all
}
다른 아이디어가 없어졌습니다. 나는 이것을 얻는 방법을 알아낼 수 없다. 나는 또한 auth-scopes
json을 VCAPS
에서 문자열로 읽은 다음이를 구문 분석 할 것입니다. 문제 없습니다. 문제는 내가 SecurityProperties
필드에 String authScopes
을 추가하더라도 정확하게 다음 문자열과 바인딩된다는 것입니다 : "${vcap.services.my-app-creds.credentials.auth-scopes}"
. 유용한 것은 없습니다.
의견이 있으시면 공유하십시오.
답장을 보내 주셔서 감사합니다. 이것이 내가 두려워했던 것입니다.나는 vcap을 뒤집어 권위가 부여 된 그룹의 목록 (내가 이미 확인한 것)을 만들 것이라고 생각한다. – Zychoo