mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2025-12-31 12:32:29 +00:00
CRITICAL: Add replay protection for authorization codes
Authorization codes were implemented as stateless JWTs with no tracking, allowing the same code to be exchanged for tokens multiple times. This violates OAuth 2.0 RFC 6749 Section 4.1.2 which mandates that authorization codes MUST be single-use. This change: - Adds oidc_authorization_codes table to track code usage - Stores authorization codes in database when generated - Validates code exists and hasn't been used before exchange - Marks code as used immediately after validation - Prevents replay attacks where intercepted codes could be reused Security impact: - Prevents attackers from reusing intercepted authorization codes - Ensures compliance with OAuth 2.0 security requirements - Adds database-backed single-use enforcement
This commit is contained in:
15
internal/model/oidc_authorization_code_model.go
Normal file
15
internal/model/oidc_authorization_code_model.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package model
|
||||
|
||||
type OIDCAuthorizationCode struct {
|
||||
Code string `gorm:"column:code;primaryKey"`
|
||||
ClientID string `gorm:"column:client_id;not null"`
|
||||
RedirectURI string `gorm:"column:redirect_uri;not null"`
|
||||
Used bool `gorm:"column:used;default:false"`
|
||||
ExpiresAt int64 `gorm:"column:expires_at;not null"`
|
||||
CreatedAt int64 `gorm:"column:created_at;not null"`
|
||||
}
|
||||
|
||||
func (OIDCAuthorizationCode) TableName() string {
|
||||
return "oidc_authorization_codes"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user