-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
fix: handle server error when refresh token requests come same time #3207
fix: handle server error when refresh token requests come same time #3207
Conversation
persistence/sql/persister_oauth2.go
Outdated
Exec()) | ||
if err := p.Connection(ctx). | ||
RawQuery(fmt.Sprintf("DELETE FROM %s WHERE signature=?", OAuth2RequestSQL{Table: table}.TableName()), signature). | ||
Exec(); errors.Is(err, sql.ErrNoRows) { |
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.
This can never be true because Exec()
is no longer wrapped in sqlcon.HandleError
persistence/sql/persister_oauth2.go
Outdated
} else if err := sqlcon.HandleError(err); err != nil { | ||
if errors.Is(err, sqlcon.ErrConcurrentUpdate) { | ||
return errors.Wrap(fosite.ErrSerializationFailure, err.Error()) | ||
} else if strings.Contains(err.Error(), "Error 1213") { // InnoDB Deadlock? |
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.
Could we handle this in sqlcon.HandleError
instead :)
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.
fixed at 1ad6caa!
Signed-off-by: sawadashota <shota@sslife.tech>
Signed-off-by: sawadashota <shota@sslife.tech>
1ad6caa
to
4574761
Compare
Codecov Report
@@ Coverage Diff @@
## master #3207 +/- ##
==========================================
- Coverage 79.55% 79.31% -0.24%
==========================================
Files 112 111 -1
Lines 7971 8077 +106
==========================================
+ Hits 6341 6406 +65
- Misses 1225 1258 +33
- Partials 405 413 +8
Help us with your feedback. Take ten seconds to tell us how you rate us. |
…3207) Signed-off-by: sawadashota <shota@sslife.tech>
…3207) Signed-off-by: sawadashota <shota@sslife.tech>
…3207) Signed-off-by: sawadashota <shota@sslife.tech>
…3207) Signed-off-by: sawadashota <shota@sslife.tech>
…3207) Signed-off-by: sawadashota <shota@sslife.tech>
…3207) Signed-off-by: sawadashota <shota@sslife.tech>
Related issue(s)
Handle server error when refresh token requests come same time.
Hydra usually handles this as
ErrInactiveToken
. But sometimes, when requests come very bad timing, this will beErrServerError
with very poor error log ({msg: 'An error occurred', error: {debug: 'server_error', status: 'Internal Server Error'}}
).As stack trace log (debug mode), it turns out that
Persister.deleteSessionBySignature
returnssqlconn
's error without any handling. If it'sforsite
's error, fosite will handle error asErrInvalidRequest
at RefreshTokenGrantHandler.handleRefreshTokenEndpointStorageError.StackTrace(debug mode)
Checklist
If this pull request addresses a security. vulnerability,
I confirm that I got green light (please contact security@ory.sh) from the maintainers to push the changes.
Further Comments