feat: protect write endpoints with JWT auth (story #08)

Add bcrypt user file auth, JWT middleware on all write routes, Pinia
authStore with localStorage persistence, login view with redirect
support, and v-if guards on all CRUD controls and admin nav link.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-19 11:18:42 +02:00
co-authored by Claude Sonnet 4.6
parent 649c9687ac
commit 1b381d9385
32 changed files with 895 additions and 56 deletions
+8 -1
View File
@@ -10,6 +10,7 @@ import (
"syscall"
"time"
"osdb/internal/auth"
"osdb/internal/config"
"osdb/internal/database"
"osdb/internal/migrate"
@@ -52,7 +53,13 @@ func serve(cfg *config.Config) {
defer pool.Close()
log.Println("database: connected")
e := New(pool)
users, err := auth.LoadUsers(cfg.UsersFile)
if err != nil {
log.Fatalf("auth: load users from %s: %v", cfg.UsersFile, err)
}
log.Printf("auth: loaded %d user(s)", len(users))
e := New(pool, users, cfg.JWTSecret)
// Start server; signal failures via a channel so the main goroutine can
// handle them without calling os.Exit from a goroutine (which would skip