-
Notifications
You must be signed in to change notification settings - Fork 0
Step 39: API key authentication for goshipd #24
Copy link
Copy link
Open
Labels
enhancementNew feature or requestNew feature or requestphase:securityPhase 6: Security & PolishPhase 6: Security & Polish
Milestone
Description
Summary
Add API key authentication to goshipd. Keys are generated via CLI, stored as SHA256 hashes in the state store, and validated via middleware on every API request.
What Changes
pkg/domain/entities/auth.go(new) —APIKeystruct (Name,KeyHash,CreatedAt)pkg/domain/entities/state.go(modified) — AddAPIKeys map[string]*APIKeytoLocalStateinternal/api/middleware/auth.go(new) — Auth middleware: extractsAuthorization: Bearer <key>header, hashes key, compares against stored hashes, rejects unauthorized requestsinternal/api/handlers/auth.go(new) — Handlers:CreateAPIKey,ListAPIKeys,RevokeAPIKeyinternal/client/auth.go(new) — Client methods for key management,Clientstores API key for authenticated requestscmd/goshipctl/commands/auth.go(new) — CLI:goshipctl auth create-key,auth list-keys,auth revoke-key
Acceptance Criteria
-
goshipctl auth create-key NAMEgenerates and displays a new API key - Raw key shown only once; SHA256 hash stored in state
-
goshipctl auth list-keysshows key names and creation dates (not raw keys) -
goshipctl auth revoke-key NAMEremoves a key - Auth middleware validates
Authorization: Bearerheader on all API routes - Auth can be enabled/disabled via
GOSHIP_AUTH_ENABLEDconfig - HTTP client sends API key header when configured
-
go test ./...passes
Dependencies
- Depends on Step 14: REST API server (goshipd) #2 (REST API server)
- Depends on Step 15: CLI HTTP client for goshipd #3 (CLI HTTP client)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestphase:securityPhase 6: Security & PolishPhase 6: Security & Polish