mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2026-04-14 17:57:56 +00:00
fix: review comments
This commit is contained in:
1
internal/assets/migrations/000008_oidc_code_reuse.up.sql
Normal file
1
internal/assets/migrations/000008_oidc_code_reuse.up.sql
Normal file
@@ -0,0 +1 @@
|
||||
ALTER TABLE "oidc_tokens" ADD COLUMN "code_hash" TEXT NOT NULL DEFAULT "";
|
||||
@@ -1 +0,0 @@
|
||||
ALTER TABLE "oidc_tokens" ADD COLUMN "code_hash" TEXT DEFAULT "";
|
||||
@@ -1,6 +1,7 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
@@ -275,9 +276,10 @@ func (controller *OIDCController) Token(c *gin.Context) {
|
||||
case "authorization_code":
|
||||
entry, err := controller.oidc.GetCodeEntry(c, controller.oidc.Hash(req.Code), client.ClientID)
|
||||
if err != nil {
|
||||
// Delete the access token just in case
|
||||
controller.oidc.DeleteTokenByCodeHash(c, controller.oidc.Hash(req.Code))
|
||||
|
||||
err := controller.oidc.DeleteTokenByCodeHash(c, controller.oidc.Hash(req.Code))
|
||||
if err != nil && !errors.Is(err, sql.ErrNoRows) {
|
||||
tlog.App.Error().Err(err).Msg("Failed to delete access token by code hash")
|
||||
}
|
||||
if errors.Is(err, service.ErrCodeNotFound) {
|
||||
tlog.App.Warn().Msg("Code not found")
|
||||
c.JSON(400, gin.H{
|
||||
|
||||
Reference in New Issue
Block a user