forked from google/goblet
-
Notifications
You must be signed in to change notification settings - Fork 0
feat: upstream authentication improvements #7
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
Merged
Conversation
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
Merges google/goblet PR #11 by @mdehoog google#11 Allows custom token generation mechanisms for different upstreams. This is useful when Goblet caches repos from different organizations where each needs its own token (e.g., GitHub app installation tokens). Changes: - Modified TokenSource from oauth2.TokenSource to a function accepting upstream URL - Updated all token generation calls to pass upstream URL parameter
Merges google/goblet PR #10 by @mdehoog google#10 Respects the token type (Bearer vs Basic) for authentication. GitHub Enterprise expects personal access tokens using basic auth instead of bearer. This change uses the token type from the token itself rather than hardcoding 'Bearer'. Changes: - Changed hardcoded 'Bearer' to use t.Type() in git fetch commands - Combined with empty token check from previous merge - Already working for lsRefsUpstream via SetAuthHeader - No impact on existing users (Bearer is the default) Conflicts resolved: - managed_repository.go: Combined t.Type() usage with empty token checks
Comprehensive analysis of GitHub Enterprise and public GitHub OAuth support with respect to multi-tenancy isolation concerns. Covers: - Current state analysis of authentication flows - GitHub authentication models (Apps, PATs, OAuth Apps) - Multi-tenancy isolation requirements and threat model - Technical architecture for secure multi-tenant operation - Implementation strategy (5 phases) - Tradeoffs and recommendations - Migration path from current to full implementation Key findings: - PR #7 provides critical foundation (URL-aware tokens, dynamic type) - Complete solution requires: authorization layer + token manager + cache partitioning - GitHub Apps recommended for production multi-tenant (automatic rotation, org-scoped) - Estimated 12-16 weeks for full implementation Related: PR #7, RFC-001
Update repository URLs from github-cache-daemon to goblet to match upstream naming convention. Changes: - Updated RFC-002 PR link reference - Updated CHANGELOG unreleased comparison link
jrepp
added a commit
that referenced
this pull request
Nov 7, 2025
Comprehensive analysis of GitHub Enterprise and public GitHub OAuth support with respect to multi-tenancy isolation concerns. Covers: - Current state analysis of authentication flows - GitHub authentication models (Apps, PATs, OAuth Apps) - Multi-tenancy isolation requirements and threat model - Technical architecture for secure multi-tenant operation - Implementation strategy (5 phases) - Tradeoffs and recommendations - Migration path from current to full implementation Key findings: - PR #7 provides critical foundation (URL-aware tokens, dynamic type) - Complete solution requires: authorization layer + token manager + cache partitioning - GitHub Apps recommended for production multi-tenant (automatic rotation, org-scoped) - Estimated 12-16 weeks for full implementation Related: PR #7, RFC-001
- Format goblet-server/main.go with gofmt - Update test_proxy_server.go to use new TokenSource function signature with adapter
…-fixes # Conflicts: # docs/architecture/rfc-002-github-oauth-multi-tenancy.md
Add extensive test coverage for the URL-based TokenSource functionality that enables different upstream URLs to use different authentication credentials and token types. New test files: - managed_repository_auth_test.go: Integration tests for TokenSource with managed_repository, including token type handling (Bearer/Basic), URL passing, error propagation, and concurrent access - testing/upstream_auth_test.go: Unit tests for TokenSource function behavior, including URL-based selection, org-specific tokens, GitHub App patterns, error handling, and concurrency Test coverage includes: - URL-based token selection for different upstreams (GitHub, GitLab, etc) - Token type handling (Bearer, Basic, custom types) - Organization-specific token mapping from URLs - GitHub App installation token patterns - Error handling and propagation - Concurrent token requests (50+ concurrent calls) - Empty token handling for public repositories - Integration with managed_repository HTTP requests All tests passing with 14 new test cases covering the pluggable authentication feature.
- Add error checking for w.Write() calls in managed_repository_auth_test.go - Add nolint directives for intentional test patterns in upstream_auth_test.go - All lint checks now passing
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.
Summary
This PR implements pluggable upstream authentication for Goblet, enabling different upstream URLs to use different authentication credentials and token types. This is critical for multi-organization deployments and GitHub Enterprise compatibility.
Key Features:
Merged Upstream PRs
PR #11: Pass upstream URL to token generation
Source: google#11
Author: @mdehoog
Enables custom token generation mechanisms for different upstreams. Critical when Goblet caches repositories from different organizations requiring separate authentication tokens (e.g., GitHub App installation tokens).
Changes:
TokenSourcefromoauth2.TokenSourcetofunc(*url.URL) (*oauth2.Token, error)PR #10: Use token type for authentication
Source: google#10
Author: @mdehoog
Respects OAuth2 token type (Bearer vs Basic) for authentication. GitHub Enterprise expects personal access tokens to use Basic auth instead of Bearer tokens.
Changes:
token.Type()instead of hardcoded "Bearer" in git fetch commandsDocumentation
RFC-002: GitHub OAuth and Multi-Tenancy Architecture
Comprehensive RFC providing:
See RFC-002
Streamlined Documentation
README improvements:
New documentation:
docs/operations/offline-mode.md- Comprehensive offline mode guide with configuration examples, monitoring, testing, and best practicesTest Coverage
New Test Files (1,148 lines)
managed_repository_auth_test.go (475 lines)
Integration tests verifying TokenSource with managed_repository:
testing/upstream_auth_test.go (673 lines)
Unit tests for TokenSource function behavior:
Test Results
What This Enables
Multi-Organization Authentication
GitHub Enterprise Support
Files Changed
Core functionality:
goblet.go- Updated TokenSource type signaturegoblet-server/main.go- Adapted to new TokenSource function signaturemanaged_repository.go- Updated all token calls to pass upstream URL and use dynamic token typetesting/test_proxy_server.go- Updated test helpersDocumentation:
README.md- Streamlined, removed emojis, better structureSECURITY.md- Generalized automation tool referencesdocs/architecture/rfc-002-github-oauth-multi-tenancy.md- New comprehensive RFC (1200+ lines)docs/operations/offline-mode.md- New comprehensive guide with examplesTests:
managed_repository_auth_test.go- Integration tests (475 lines)testing/upstream_auth_test.go- Unit tests (673 lines)Validation
All checks passing:
Use Cases
Multi-Organization Deployments:
GitHub Enterprise:
Infrastructure as Code:
Breaking Changes
Minor API Change:
TokenSourceinServerConfigchanged fromoauth2.TokenSourcetofunc(*url.URL) (*oauth2.Token, error)Migration:
Security Implications
What This PR Provides:
What Still Needs Implementation:
See RFC-002 for complete security analysis and implementation roadmap.
Related Issues
Addresses needs for:
Credit: Upstream features by @mdehoog (google#11, google#10)
Total Changes: +2,516 lines (code + tests + documentation)