Sign session tokens with HMAC #2
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Blocks
Depends on
#3 Add Bearer token authentication for API access
austin/vektor
#1 Fix nil pointer panic in local auth mode
austin/vektor
Reference
austin/vektor#2
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
CreateSessionTokenininternal/auth/oidc.gojust base64-encodes a JSON blob with claims and expiry. Anyone who knows the format can forge a session as any user. This is a blocking security issue.What needs to happen
Generate a random 32-byte secret on first startup. Store it in the data directory as a file, or in a
settingstable in SQLite. Use HMAC-SHA256 to sign the session payload. Token format becomesbase64(payload).base64(signature). On validation, recompute the HMAC and compare.Uses only the standard library:
crypto/hmac,crypto/sha256,crypto/rand.Consider a
SessionManagerstruct that holds the signing key — both auth modes share it. This is a good learning exercise for understanding how JWTs work conceptually without pulling in a JWT library.Key files
internal/auth/oidc.go—CreateSessionToken()(line 158) andvalidateSession()(line 132)