mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-05-31 09:12:14 +00:00
Merge branch '6.0.x' into 6.1.x
This commit is contained in:
commit
b7efa15591
@ -241,16 +241,15 @@ fun rest(): RestTemplate {
|
|||||||
val rest = RestTemplate()
|
val rest = RestTemplate()
|
||||||
rest.interceptors.add(ClientHttpRequestInterceptor { request, body, execution ->
|
rest.interceptors.add(ClientHttpRequestInterceptor { request, body, execution ->
|
||||||
val authentication: Authentication? = SecurityContextHolder.getContext().authentication
|
val authentication: Authentication? = SecurityContextHolder.getContext().authentication
|
||||||
if (authentication != null) {
|
if (authentication == null) {
|
||||||
execution.execute(request, body)
|
return execution.execute(request, body)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (authentication!!.credentials !is AbstractOAuth2Token) {
|
if (authentication.credentials !is AbstractOAuth2Token) {
|
||||||
execution.execute(request, body)
|
return execution.execute(request, body)
|
||||||
}
|
}
|
||||||
|
|
||||||
val token: AbstractOAuth2Token = authentication.credentials as AbstractOAuth2Token
|
request.headers.setBearerAuth(authentication.credentials.tokenValue)
|
||||||
request.headers.setBearerAuth(token.tokenValue)
|
|
||||||
execution.execute(request, body)
|
execution.execute(request, body)
|
||||||
})
|
})
|
||||||
return rest
|
return rest
|
||||||
|
Loading…
x
Reference in New Issue
Block a user