Skip to content
This repository was archived by the owner on Apr 5, 2022. It is now read-only.
This repository was archived by the owner on Apr 5, 2022. It is now read-only.

AccessTokenContextRelay does not renew expired access tokens #223

@HJK181

Description

@HJK181

Spring cloud version: Greenwich.SR3

My UAA service is also an oauth2 client, which needs to relay JWT tokens coming in from Zuul. When configuring the oauth2 client the following way

@Configuration
@EnableOAuth2Client
@RibbonClient(name = "downstream")
public class OAuthClientConfiguration {

	@Bean
	public OAuth2RestTemplate restTemplate(OAuth2ProtectedResourceDetails resource, OAuth2ClientContext context) {
		return new OAuth2RestTemplate(resource, context);
	}
}

I do get a 401 response from the downstream service as my access token has a very short validity and the AccessTokenContextRelay#copyToken() which get's executed by the autowired ResourceServerTokenRelayRegistrationAutoConfiguration drops the validity and refresh token information.

This leads to the following behavior:

  • Zuul does renew expired access tokens by calling OAuth2RestTemplate#getAccessToken
  • The UAA service also call OAuth2RestTemplate#getAccessToken but, as the access token populated by AccessTokenContextRelay in the OAuth2ClientContext does always return false for accessToken.isExpired(), the token is neither renewed nor does AccessTokenContextRelay refresh updated incoming access tokens. Instead the expired token is used again and again.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions