-
Notifications
You must be signed in to change notification settings - Fork 24.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Always return 401 for not valid tokens #49736
Conversation
Return a 401 in all cases when a request is submitted with an access token that we can't consume. Before this change, we would throw a 500 when a request came in with an access token that we had generated but was then invalidated/expired and deleted from the tokens index. Resolves: elastic#38866
Pinging @elastic/es-security (:Security/Authentication) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM , a missing token document is more likely a sign of an invalid token (401 Unauthorized) than of a bug which might have deleted or otherwise erroneously stored the token document, in both the encrypted and the hashed token cases.
Return a 401 in all cases when a request is submitted with an access token that we can't consume. Before this change, we would throw a 500 when a request came in with an access token that we had generated but was then invalidated/expired and deleted from the tokens index. Resolves: elastic#38866
Return a 401 in all cases when a request is submitted with an access token that we can't consume. Before this change, we would throw a 500 when a request came in with an access token that we had generated but was then invalidated/expired and deleted from the tokens index. Resolves: #38866 Backport of #49736
This test was fixed as part of elastic#49736 so that it used a TokenService mock instance that was enabled, so that token verification fails because the token is invalid and not because the token service is not enabled. When the randomly generated token we send, decodes to being of version > 7.2 , we need to have mocked a GetResponse for the call that TokenService#getUserTokenFromId will make, otherwise this hangs and times out.
This test was fixed as part of #49736 so that it used a TokenService mock instance that was enabled, so that token verification fails because the token is invalid and not because the token service is not enabled. When the randomly generated token we send, decodes to being of version > 7.2 , we need to have mocked a GetResponse for the call that TokenService#getUserTokenFromId will make, otherwise this hangs and times out.
This test was fixed as part of elastic#49736 so that it used a TokenService mock instance that was enabled, so that token verification fails because the token is invalid and not because the token service is not enabled. When the randomly generated token we send, decodes to being of version > 7.2 , we need to have mocked a GetResponse for the call that TokenService#getUserTokenFromId will make, otherwise this hangs and times out.
This test was fixed as part of #49736 so that it used a TokenService mock instance that was enabled, so that token verification fails because the token is invalid and not because the token service is not enabled. When the randomly generated token we send, decodes to being of version > 7.2 , we need to have mocked a GetResponse for the call that TokenService#getUserTokenFromId will make, otherwise this hangs and times out.
Return a 401 in all cases when a request is submitted with an access token that we can't consume. Before this change, we would throw a 500 when a request came in with an access token that we had generated but was then invalidated/expired and deleted from the tokens index. Resolves: elastic#38866
This test was fixed as part of elastic#49736 so that it used a TokenService mock instance that was enabled, so that token verification fails because the token is invalid and not because the token service is not enabled. When the randomly generated token we send, decodes to being of version > 7.2 , we need to have mocked a GetResponse for the call that TokenService#getUserTokenFromId will make, otherwise this hangs and times out.
Return a 401 in all cases when a request is submitted with an
access token that we can't consume. Before this change, we would
throw a 500 when a request came in with an access token that we
had generated but was then invalidated/expired and deleted from
the tokens index.
Resolves: #38866