This repository has been archived by the owner on Dec 7, 2020. It is now read-only.
fix cookie expiration issue when exp claim is zero #355
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
Thanks for your excellent work!
I've encountered an issue with an infinite redirect loop after authentication which I tracked down to being caused by session cookies having 1970-01-01T00:00:00Z expiration dates.
After more digging, this was caused by the refresh token emitted by Keycloak which had a "exp" claim set to zero!
{
"jti": "f6bdb3b4-409f-43d1-9675-24ab06404c9a",
"exp": 0,
"nbf": 0,
"iat": 1525834984,
"iss": "https://example.com/auth/realms/hello",
"aud": "kubernetes",
"sub": "a7c5ce69-657e-45a2-9904-3cb85d51be36",
"typ": "Offline",
"azp": "kubernetes",
"nonce": "35e9f093d45483d1857c2e82c81fee51",
"auth_time": 0,
"session_state": "ba2e7a6f-985d-4647-b497-cb6e05809e3d",
"realm_access": {
"roles": [
"offline_access",
"uma_authorization"
]
},
"resource_access": {
"account": {
"roles": [
"manage-account",
"manage-account-links",
"view-profile"
]
}
}
}
Then the time difference time.Until(ident.ExpiresAt) was producing a negative duration, which caused the cookie to be in the 70', which of course prevented the browser from keeping it, thus causing the infinite loop.
Hope this helps,
Morgan