feat: secure API authentication system#27
Open
venkidesh04 wants to merge 10 commits into
Open
Conversation
- add cli/keychain/keychain.go wrapping go-keyring - migrate set-api-key cmd to write into OS keychain - migrate deploy and logs cmds to read API key from keychain - remove api_key field from cli/config/config.go (no longer stored on disk) - add github.com/zalando/go-keyring to cli/go.mod
- add cli/signer/signer.go with Sign() and Headers() helpers - update cli/client/client.go to attach X-Timestamp and X-Signature on every request - add NewSignedRequest helper for commands that build requests directly (logs) - update cli/cmd/logs.go to use NewSignedRequest
- add controller/internal/auth/hmac.go with ValidateTimestamp and ValidateHMAC - update controller/internal/auth/middleware.go to run timestamp and HMAC checks after API key validation - expose AuthService.Secret() for use within the auth package
- add controller/internal/ratelimit/ratelimit.go - per-IP token-bucket limiter using golang.org/x/time/rate - respects X-Forwarded-For for clients behind proxies
- wrap all protected routes with ratelimit.Middleware - apply rate limiter globally (before routing) using ratelimit.DefaultConfig - no handler logic changes; purely middleware wiring in main.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR introduces a secure authentication and request validation pipeline between the CLI and controller, replacing the previous plaintext API key approach.
Key Improvements
CLI Enhancements
Secure API Key Storage
go-keyring)~/.mini/config.jsonRequest Signing
All outgoing requests include:
Authorization: Bearer <api_key>X-TimestampX-SignatureCentralized Auth Handling
attachAuth()andNewSignedRequest()ensure consistent signing across all CLI commands (deploy,logs, etc.)Controller Enhancements
Authentication Middleware
Sequential validation pipeline:
Replay Protection
Request Integrity
Rate Limiting