spring-cloud / spring-cloud/spring-cloud-gateway

Allow setting the refresh token clock skew

Open
#2,079 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement help wanted
Dominant language
Java
Stars
4.9k
Forks
3.5k
Avg merge
20h 57m
Merged PRs (30d)
8

Description

Describe the bug
Spring Cloud Gateway didn't support refresh token until last milestone. (https://spring.io/blog/2020/11/18/spring-cloud-2020-0-0-m5-aka-ilford-is-available) I upgraded my project to support and use refresh token, and now i am using TokenRelay filter in spring-cloud-gateway, not in spring-cloud-security. But, access token is refreshed at every request although access token is not expired.

Sample
Here is the sample log in my first request

2020-12-15 14:08:16.036 TRACE 10828 --- [ioEventLoop-7-2] o.s.w.r.f.client.ExchangeFunctions : [5bbf4c1f] HTTP POST http://localhost:8443/cas/oauth2.0/accessToken, headers={masked}
2020-12-15 14:08:16.041 TRACE 10828 --- [ctor-http-nio-8] o.s.http.codec.FormHttpMessageWriter : [5bbf4c1f] Writing form fields [grant_type, code, redirect_uri] (content masked)
2020-12-15 14:08:17.328 TRACE 10828 --- [ctor-http-nio-8] o.s.http.codec.json.Jackson2JsonDecoder : [5bbf4c1f] Decoded [{access_token=eyJ***.ey***.dD***, refresh_token=RT-2-b0yk***, token_type=bearer, expires_in=60, scope=custom_mod}]

the access token will expires in 60 seconds as you can see in log. But it is refreshing before expired.

2020-12-15 14:08:21.920 TRACE 10828 --- [ioEventLoop-7-2] o.s.w.r.f.client.ExchangeFunctions : [7a6b8bbd] HTTP POST http://localhost:8443/cas/oauth2.0/accessToken, headers={masked}
2020-12-15 14:08:21.922 TRACE 10828 --- [ctor-http-nio-8] o.s.http.codec.FormHttpMessageWriter : [7a6b8bbd] Writing form fields [grant_type, refresh_token] (content masked)
2020-12-15 14:08:22.737 TRACE 10828 --- [ctor-http-nio-8] o.s.http.codec.json.Jackson2JsonDecoder : [7a6b8bbd] Decoded [{access_token=ey***.ey***.5O***, token_type=bearer, expires_in=60, scope=custom_mod}]

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the TokenRelay filter in spring-cloud-gateway and trace the refresh-token path described in the issue. Determine where the refresh decision uses token expiry, then make the clock skew configurable so a token is not refreshed before the configured threshold; verify the behavior against the logged 60-second token example.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.