Repository navigation
Description
Overview
Implement comprehensive Google Cloud Platform (GCP) authentication support including Service Accounts
Tasks
Task 4.1: Create GCP Authentication Factory
Description: Implement the GCP-specific authentication factory that integrates with the core authentication framework. This factory will handle GCP-specific configuration and credential instantiation.
Time Estimate: 1 day
Dependencies: Core Framework (Task Group 1)
Deliverables:
pkg/auth/gcp/factory.gowith Factory implementation- Registration handled externally
- GCP-specific configuration types
Implementation Status:
- Factory struct with Create() and SupportedAuthTypes()
- Supports ServiceAccount, WorkloadIdentity, Default auth types
- Configuration extraction from auth.Config.Extra
- Project ID discovery and override support
- Integration with Google OAuth2 libraries
Acceptance Criteria:
- Factory identifies GCP auth types
- Validates provider type
- Handles project ID from config
- Returns appropriate errors
- Unit tests implemented
Task 4.2: Implement Service Account Key Authentication
Description: Implement authentication using GCP service account JSON key files. This includes JWT creation, token exchange, and proper scope handling.
Time Estimate: 3 days
Dependencies: Task 4.1
Deliverables:
- Service account logic in factory.go
- ServiceAccountConfig struct in credentials.go
- Google libraries handle JWT/OAuth2
Implementation Status:
- Reads service account JSON from file or config
- ServiceAccountConfig with validation
- Environment variable support (GOOGLE_APPLICATION_CREDENTIALS)
- Scope configuration support
- Google SDK handles JWT creation
- Google SDK manages token exchange
- Automatic token refresh via TokenSource
Acceptance Criteria:
- Reads JSON key files
- Validates required fields
- Google SDK creates JWT tokens
- Google SDK exchanges tokens
- TokenSource handles refresh
- Custom scopes supported
- OAuth2 scopes managed
- Unit tests implemented
Task 4.3: Implement Application Default Credentials
Description: Implement GCP's Application Default Credentials (ADC) which provides a consistent way to find credentials across different environments.
Time Estimate: 3 days
Dependencies: Task 4.1, Task 4.2
Deliverables:
- Default credentials logic in factory.go
- Uses google.FindDefaultCredentials
- Project ID extraction
Implementation Status:
- createDefaultCredentials method implemented
- Uses Google's ADC implementation
- Checks GOOGLE_APPLICATION_CREDENTIALS
- Searches well-known locations
- Supports gcloud credentials
- Falls back to metadata service
- Scope configuration support
- Project ID discovery from credentials
Acceptance Criteria:
- Checks env variable
- Well-known locations via Google SDK
- gcloud support via Google SDK
- GCE metadata fallback
- Quota project via scopes
- Credential validation by SDK
- ADC precedence by Google SDK
- Unit tests implemented
- Integration tests need environments
Task 4.4: Implement Compute Engine Metadata Service
Description: Implement authentication for Compute Engine instances using the metadata service. This allows applications on GCE to authenticate without explicit credentials.
Time Estimate: 2 days
Dependencies: Task 4.1
Deliverables:
- Metadata service handled by Google ADC
- Part of default credentials chain
- No separate implementation needed
Implementation Status:
- Google ADC detects GCE environment
- ADC retrieves service account from metadata
- ADC fetches tokens from metadata service
- Automatic token refresh
- Scope configuration via createDefaultCredentials
Acceptance Criteria:
- Google SDK detects GCE/GKE
- SDK retrieves service account
- SDK fetches access tokens
- SDK handles custom accounts
- Scopes configurable
- Implements proper retry logic
- Validates metadata server certificates
- Unit tests with mocked metadata service
- Integration tests on GCE instance
Task 4.5: Implement GKE Workload Identity
Description: Implement authentication for GKE Workload Identity, allowing Kubernetes workloads to authenticate as Google Service Accounts.
Time Estimate: 2 days
Dependencies: Task 4.1
Deliverables:
- GKE Workload Identity in factory.go
- Enhanced WorkloadIdentityConfig
- Metadata service integration via Google SDK
Implementation Status:
- Uses Google ADC for GKE metadata service
- Enhanced WorkloadIdentityConfig for GKE
- Supports service account binding info
- Kubernetes service account tracking
- Cluster name and location metadata
- Project ID discovery from metadata
- Automatic token refresh via SDK
- Thread-safe credential caching
Acceptance Criteria:
- Detects GKE environment via ADC
- Retrieves tokens from metadata service
- Supports bound service accounts
- Handles token refresh automatically
- Validates configuration
- Unit tests implemented
Activity