You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 5, 2022. It is now read-only.
Hi,
After fixing token relay in spring-cloud-security 1.2.1.RELEASE I have problem with expiring OAuth2 JWT token. My application is configured with @EnableOAuth2Client, @EnableResourceServer and security.oauth2.client.grantType=client_credentials. Also I am using Feign clients in async tasks.
When I call endpoint secured with OAuth2 to activate async tasks I am sending JWT token generated for resource owner (grantType=password). This token is valid for 5 minutes and is copied to OAuth2ClientContext. Next when Feign client is calling another application from async task, token is relayed.
When I call same endpoint second time after 5 minutes with new resource owner token, I am getting exception. After debugging I found that Feign client is getting HTTP 401 - Token expired and this problem is caused by not refreshed token in OAuth2ClientContext.
I was expecting that Feign clients from async task will use token generated for my application with client_credentials flow, not relay token passed in user reguest which will never be refreshed.
To fix this problem below configuration should be enabled only when property security.oauth2.client.grantType is diffrent from "client_credentials" value
@Configuration
public static class ResourceServerTokenRelayRegistrationAutoConfiguration extends WebMvcConfigurerAdapter {
@Autowired
AccessTokenContextRelay accessTokenContextRelay;
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(
new HandlerInterceptorAdapter() {
@Override
public boolean preHandle(HttpServletRequest request,
HttpServletResponse response, Object handler) throws Exception {
accessTokenContextRelay.copyToken();
return true;
}
}
);
}
}
The text was updated successfully, but these errors were encountered:
darnok87
pushed a commit
to darnok87/spring-cloud-security
that referenced
this issue
Jun 13, 2017
Hi,
After fixing token relay in spring-cloud-security 1.2.1.RELEASE I have problem with expiring OAuth2 JWT token. My application is configured with @EnableOAuth2Client, @EnableResourceServer and security.oauth2.client.grantType=client_credentials. Also I am using Feign clients in async tasks.
When I call endpoint secured with OAuth2 to activate async tasks I am sending JWT token generated for resource owner (grantType=password). This token is valid for 5 minutes and is copied to OAuth2ClientContext. Next when Feign client is calling another application from async task, token is relayed.
When I call same endpoint second time after 5 minutes with new resource owner token, I am getting exception. After debugging I found that Feign client is getting HTTP 401 - Token expired and this problem is caused by not refreshed token in OAuth2ClientContext.
I was expecting that Feign clients from async task will use token generated for my application with client_credentials flow, not relay token passed in user reguest which will never be refreshed.
To fix this problem below configuration should be enabled only when property security.oauth2.client.grantType is diffrent from "client_credentials" value
The text was updated successfully, but these errors were encountered: