我有以下 Spring Security 配置:
security:
oauth2:
resourceserver:
jwt:
issuer-uri: ${issuer-uri-of-identity}
client:
registration:
some-app:
client-id: ${qwerty.server.client.client-id}
client-secret: ${qwerty.server.client.client-secret}
scope: ${qwerty.server.client.some-app-scope}
authorization-grant-type: client_credentials
provider: qwerty
qwerty:
server:
max-clock-skew: 60
url: ....
scope: my-scope
client:
client-id: ...
client-secret: ....
some-app-scope: my-ticket-scope
并使用以下配置:
private static final Authentication ANONYMOUS_AUTHENTICATION = new AnonymousAuthenticationToken(
"anonymous", "anonymousUser", AuthorityUtils.createAuthorityList("ROLE_ANONYMOUS"));
...
@Bean("someAppRestTemplate")
@Autowired
public RestTemplate buildRestTemplateForSomeApp(RestTemplateBuilder builder) {
return builder
.messageConverters(converter)
.additionalInterceptors(Arrays.asList(contentTypeInterceptor(), oauthInterceptor("some-app")))
.build();
}
...
private ClientHttpRequestInterceptor oauthInterceptor(String id) {
return (r, b, e) -> {
OAuth2AuthorizedClient client = manager.authorize(
OAuth2AuthorizeRequest
.withClientRegistrationId(id)
.principal(ANONYMOUS_AUTHENTICATION)
.build()
);
Assert.notNull(client, "Can not access File Storage Service");
r.getHeaders().setBearerAuth(client.getAccessToken().getTokenValue());
return e.execute(r, b);
};
}
現在我需要進行模擬(https://datatracker.ietf.org/doc/html/rfc8693)。所以我需要假裝成某個用戶。由于某些應用程式應用程式中的“當前用戶”邏輯,我需要它。
我該如何重新配置??以實作它?
PS我試圖谷歌它,但我沒有找到任何相關的東西。
uj5u.com熱心網友回復:
RFC 8693 Token Exchange于 2020 年 1 月發布,涵蓋了此功能。Spring security 目前還不支持這個功能,但應該很快就會發布。
您可以在此處關注 Spring Security 中的未解決問題:
為客戶端提供對 OAuth 2.0 Token Exchange 的支持
您可以在這里代表流程閱讀更多關于流程的一般資訊
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/396572.html
標籤:爪哇 春天 弹簧安全 spring-security-oauth2 代币交换
上一篇:Mqtt訊息轉換為Java物件
