Skip to content

Commit 9b98b55

Browse files
authored
fix: properly propagate request ID (#756)
1 parent 0c340c4 commit 9b98b55

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

handler/oauth2/flow_refresh.go

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ func (c *RefreshTokenGrantHandler) HandleTokenEndpointRequest(ctx context.Contex
7777
return errorsx.WithStack(fosite.ErrInvalidGrant.WithHint("The OAuth 2.0 Client ID from this request does not match the ID during the initial token issuance."))
7878
}
7979

80+
request.SetID(originalRequest.GetID())
8081
request.SetSession(originalRequest.GetSession().Clone())
8182
request.SetRequestedScopes(originalRequest.GetRequestedScopes())
8283
request.SetRequestedAudience(originalRequest.GetRequestedAudience())

handler/oauth2/flow_refresh_test.go

+5
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,11 @@ func TestRefreshFlow_HandleTokenEndpointRequest(t *testing.T) {
159159
require.NoError(t, err)
160160

161161
areq.Form.Add("refresh_token", token)
162+
163+
orReqID := areq.GetID() + "_OR"
164+
areq.Form.Add("or_request_id", orReqID)
162165
err = store.CreateRefreshTokenSession(context.Background(), sig, &fosite.Request{
166+
ID: orReqID,
163167
Client: areq.Client,
164168
GrantedScope: fosite.Arguments{"foo", "offline"},
165169
RequestedScope: fosite.Arguments{"foo", "bar", "offline"},
@@ -177,6 +181,7 @@ func TestRefreshFlow_HandleTokenEndpointRequest(t *testing.T) {
177181
assert.NotEqual(t, url.Values{"foo": []string{"bar"}}, areq.Form)
178182
assert.Equal(t, time.Now().Add(time.Hour).UTC().Round(time.Second), areq.GetSession().GetExpiresAt(fosite.AccessToken))
179183
assert.Equal(t, time.Now().Add(time.Hour).UTC().Round(time.Second), areq.GetSession().GetExpiresAt(fosite.RefreshToken))
184+
assert.EqualValues(t, areq.Form.Get("or_request_id"), areq.GetID(), "Requester ID should be replaced based on the refresh token session")
180185
},
181186
},
182187
{

0 commit comments

Comments
 (0)