-
-
Notifications
You must be signed in to change notification settings - Fork 12
Add Private Hosting Authentication Support #192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add Private Hosting Authentication Support #192
Conversation
…re correct format for filename suffix
…traversal attacks
… prevent path traversal vulnerabilities
…and Basic Auth support
|
| GitGuardian id | GitGuardian status | Secret | Commit | Filename | |
|---|---|---|---|---|---|
| - | - | Username Password | eaf2a39 | auth_test.go | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secret safely. Learn here the best practices.
- Revoke and rotate this secret.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds comprehensive private hosting authentication support to the Docker Image Save service, along with multi-platform image support. The changes enable secure private deployments with Basic Auth and API key authentication, while adding the ability to download platform-specific images (e.g., linux/amd64, linux/arm64).
Key changes:
- Authentication middleware with support for Basic Auth and API keys (header and query parameter)
- Platform parameter support for multi-architecture image downloads
- Enhanced security with path traversal prevention and constant-time credential comparison
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| auth.go | New authentication middleware implementing Basic Auth and API key validation with constant-time comparison |
| auth_test.go | Comprehensive test coverage for authentication scenarios (457 lines) |
| config.go | Added AuthConfig structure with validation for authentication credentials |
| config_test.go | Tests for authentication configuration loading and validation |
| main.go | Integrated authentication configuration loading with fallback to config.yaml if it exists |
| server.go | Protected /image endpoint with auth middleware, added platform parameter support, path traversal prevention, and platform validation |
| server_test.go | Added 470+ lines of tests for platform support, authentication integration, and path sanitization |
| image.go | Modified to accept platform parameter and generate platform-specific filenames |
| image_test.go | Tests for platform-aware image downloads and filename generation |
| registry.go | Added Platform struct and parsing, improved manifest selection to return errors for unsupported platforms instead of silent fallback |
| registry_test.go | Tests for platform parsing and string representation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…rsal vulnerabilities
…ests for improved clarity and coverage
This PR adds support for private hosting of the Docker Image Save service, allowing the server to be protected by authentication (Basic Auth and/or API keys). This enables users to run their own instance securely, restricting access to image downloads.
Features
/imageendpoint with Basic Auth and/or API keys.authis not configured, the service remains public.Configuration Example
enabled: Set totrueto require authentication.username/password: Credentials for HTTP Basic Auth.api_keys: List of valid API keys for programmatic access (via header or query param).How It Works
auth.enabled: true.Authorization: Basic ...)X-API-Key: ...)?api_key=...)/health,/metrics,/logo.png,/) remain public.How to Test
1. Start the server with auth enabled
go build -o dockerimagesave.exe . ./dockerimagesave.exe -config config.test.yaml2. Test without authentication (should fail)
3. Test with Basic Auth
4. Test with API Key (header)
5. Test with API Key (query param)
6. Health endpoint remains public
Code Changes
config.goAuthConfigstruct andauthfield toConfig.auth.go(new)server.goAuthMiddleware./imageendpoint when auth is enabled.main.goconfig.example.yamlauthsection.Checklist