Skip to content

Commit

Permalink
fix: handle server error when refresh token requests come same time (#…
Browse files Browse the repository at this point in the history
…3207)

Signed-off-by: sawadashota <shota@sslife.tech>
  • Loading branch information
sawadashota authored and aeneasr committed Aug 18, 2022
1 parent 943d01a commit 68755ac
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions persistence/sql/persister_oauth2.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,19 @@ func (p *Persister) deleteSessionBySignature(ctx context.Context, signature stri

signature = p.hashSignature(ctx, signature, table)

/* #nosec G201 table is static */
return sqlcon.HandleError(
err := sqlcon.HandleError(
p.QueryWithNetwork(ctx).
Where("signature=?", signature).
Delete(&OAuth2RequestSQL{Table: table}))

if errors.Is(err, sqlcon.ErrNoRows) {
return errorsx.WithStack(fosite.ErrNotFound)
} else if errors.Is(err, sqlcon.ErrConcurrentUpdate) {
return errors.Wrap(fosite.ErrSerializationFailure, err.Error())
} else if err != nil {
return err
}
return nil
}

func (p *Persister) deleteSessionByRequestID(ctx context.Context, id string, table tableName) error {
Expand Down

0 comments on commit 68755ac

Please sign in to comment.