From fdfbec01efff0fbb036fb8a48537ca1335bd01f2 Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Fri, 13 Feb 2026 10:13:26 -0500 Subject: [PATCH] docs: Fix device authentication implementation plan - Update section 1.6.3 to pass baseURL as template parameter instead of hardcoding - Add handler update note for passing cfg.BaseURL to template - Fix TypeScript event handling in section 1.6.4: - Add event parameter to regenerateDeviceToken function signature - Update all onclick handlers to explicitly pass event object - Fixes deprecated implicit event in modern browsers - Remove section 1.9 (Device Identifier Verification) as it was never implemented - Clarify device authentication strategy: Kobo uses URL path tokens, KOReader uses Bearer headers --- IMPLEMENTATION_EXACT.md | 67 ++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/IMPLEMENTATION_EXACT.md b/IMPLEMENTATION_EXACT.md index 1a08c50..46f3819 100644 --- a/IMPLEMENTATION_EXACT.md +++ b/IMPLEMENTATION_EXACT.md @@ -11,15 +11,12 @@ ## Table of Contents 1. [Phase 1: Enhanced Authentication (Week 1)](#phase-1-enhanced-authentication) - - Database Query Addition - - Middleware Enhancement - - Router Updates - - Backend Handler Addition - - Frontend Template Updates - - Bruno API Tests + - Database Query Addition + - Middleware Enhancement + - Router Updates + - Backend Handler Addition + - Frontend Template Updates 2. [Phase 2: Kobo Integration (Week 1-2)](#phase-2-kobo-integration) - - Documentation Updates - - Test Updates 3. [Phase 3: OPDS Security (Week 2-3)](#phase-3-opds-security) - Router Enhancement - Bruno API Tests @@ -337,7 +334,7 @@ koboSync.POST("/sync-from-server", cfg.DeviceAuthMiddleware.Authenticate(koboHan **File**: `internal/router/device.go` -**Location**: After device registration routes (around line 50) +**Location**: After device registration routes (around line 25) **Current Implementation**: Need to check what device routes exist @@ -350,23 +347,16 @@ koboSync.POST("/sync-from-server", cfg.DeviceAuthMiddleware.Authenticate(koboHan devices.PUT("/:id/regenerate-token", jwtMiddleware, h.RegenerateDeviceToken) ``` -**Complete Context** (assuming placement after device registration routes): - + **Complete Context** (token regeneration route added to existing device routes): ```go -// Device registration endpoints -devices.POST("/register", h.InitiateRegistration) -devices.POST("/approve/:registration_id", jwtMiddleware, h.ApproveDevice) -devices.POST("/reject/:registration_id", jwtMiddleware, h.RejectDevice) -devices.GET("/pending", jwtMiddleware, h.ListPendingRegistrations) +// Existing device management routes (unchanged) +devices.GET("", jwtMiddleware, cfg.DeviceHandler.ListDevices) +devices.GET("/:id", jwtMiddleware, cfg.DeviceHandler.GetDevice) +devices.PUT("/:id", jwtMiddleware, cfg.DeviceHandler.UpdateDevice) +devices.DELETE("/:id", jwtMiddleware, cfg.DeviceHandler.DeleteDevice) -// Device management endpoints -devices.GET("", jwtMiddleware, h.ListDevices) -devices.GET("/:id", jwtMiddleware, h.GetDevice) -devices.PUT("/:id", jwtMiddleware, h.UpdateDevice) -devices.DELETE("/:id", jwtMiddleware, h.DeleteDevice) - -// Token regeneration endpoint (JWT authentication required) -devices.PUT("/:id/regenerate-token", jwtMiddleware, h.RegenerateDeviceToken) +// NEW: Token regeneration endpoint (JWT authentication required) +devices.PUT("/:id/regenerate-token", jwtMiddleware, cfg.DeviceHandler.RegenerateDeviceToken) ``` **Verification**: Run `go build ./internal/router` @@ -573,13 +563,16 @@ deviceList[i] = DeviceInfo{ **File**: `templates/devices.templ` -**Location**: Lines 46-98 (device card in grid) +**Location**: Template function signature (line 5) and device card (lines 46-98) -**Current Implementation**: Device card shows device info and settings buttons +**Required Changes**: -**Required Addition**: Add buttons for copy sync URL and regenerate token +1. **Update template signature** to accept baseURL parameter (line 5): +```templ +templ Devices(user User, devices []handlers.DeviceInfo, pendingRegistrations []PendingRegistrationData, baseURL string) { +``` -**REPLACE DEVICE CARD CONTENT** (lines 46-98) with: +2. **REPLACE DEVICE CARD CONTENT** (lines 46-98) with: ```templ for _, device := range devices { @@ -647,12 +640,12 @@ for _, device := range devices { type="text" id="sync-url-{ device.ID }" readonly - value="{ fmt.Sprintf("http://YOUR_IP:8765/api/sync/kobo/%s", device.AuthToken) }" + value="{ fmt.Sprintf("%s/api/sync/kobo/%s", baseURL, device.AuthToken) }" class="flex-1 px-3 py-2 text-xs rounded border" style="background-color: var(--bg-primary); color: var(--text-primary); border-color: var(--border);" />