mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2026-04-18 03:36:09 +00:00
Compare commits
2 Commits
8622736718
...
51a6559324
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
51a6559324 | ||
|
|
5b836ee8c4 |
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 "";
|
|
||||||
@@ -275,9 +275,9 @@ func (controller *OIDCController) Token(c *gin.Context) {
|
|||||||
case "authorization_code":
|
case "authorization_code":
|
||||||
entry, err := controller.oidc.GetCodeEntry(c, controller.oidc.Hash(req.Code), client.ClientID)
|
entry, err := controller.oidc.GetCodeEntry(c, controller.oidc.Hash(req.Code), client.ClientID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Delete the access token just in case
|
if err := controller.oidc.DeleteTokenByCodeHash(c, controller.oidc.Hash(req.Code)); err != nil {
|
||||||
controller.oidc.DeleteTokenByCodeHash(c, controller.oidc.Hash(req.Code))
|
tlog.App.Error().Err(err).Msg("Failed to delete access token by code hash")
|
||||||
|
}
|
||||||
if errors.Is(err, service.ErrCodeNotFound) {
|
if errors.Is(err, service.ErrCodeNotFound) {
|
||||||
tlog.App.Warn().Msg("Code not found")
|
tlog.App.Warn().Msg("Code not found")
|
||||||
c.JSON(400, gin.H{
|
c.JSON(400, gin.H{
|
||||||
|
|||||||
@@ -387,7 +387,7 @@ func TestOIDCController(t *testing.T) {
|
|||||||
err = json.Unmarshal(secondRecorder.Body.Bytes(), &secondRes)
|
err = json.Unmarshal(secondRecorder.Body.Bytes(), &secondRes)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
assert.Equal(t, secondRes["error"], "invalid_grant")
|
assert.Equal(t, "invalid_grant", secondRes["error"])
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user