-
Notifications
You must be signed in to change notification settings - Fork 21
[WIP] Add mTLS and OAuth authentication to event REST API #588
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: main
Are you sure you want to change the base?
Conversation
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jzding The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
250d7be to
dc9e1a9
Compare
74c2da8 to
c853d2d
Compare
|
/ok-to-test |
c853d2d to
5a4eb9a
Compare
3f58685 to
0906180
Compare
|
/ok-to-test |
|
/test e2e-aws |
0e11e52 to
2b84ada
Compare
|
/ok-to-test |
2b84ada to
b454979
Compare
|
/ok-to-test |
b454979 to
5a6e19e
Compare
|
/ok-to-test |
51da820 to
49ae3fa
Compare
030c0f0 to
6a0a606
Compare
This commit introduces comprehensive authentication support for the cloud-event-proxy, enabling secure communication for both event consumers and producers in production OpenShift environments. **Authentication Infrastructure:** - mTLS (Mutual TLS) authentication with client certificate validation - OAuth JWT token authentication with OpenShift OAuth server integration - Support for Kubernetes ServiceAccount tokens for pod-to-pod communication - Flexible authentication configuration via JSON config files **Client-Side Authentication (pkg/auth/):** - `pkg/auth/client.go`: HTTP client with mTLS and OAuth token support - `pkg/auth/config.go`: Authentication configuration management and validation - Enhanced `pkg/restclient/client.go`: Authenticated REST client with TLS support - Integration with `pkg/common/common.go` for seamless authentication flow **Consumer Examples and Templates:** - `examples/consumer/main.go`: Complete consumer implementation with authentication - `examples/auth-examples/auth-examples.go`: Comprehensive authentication examples (316 lines) - `examples/consumer/auth-config-example.json`: Example authentication configuration - `examples/consumer/README.md`: Detailed consumer authentication guide (383 lines) **OpenShift Integration and Deployment:** - `examples/manifests/auth/setup-secrets.sh`: Automated authentication setup script - `examples/manifests/auth/configmap.yaml`: Dynamic authentication configuration - `examples/manifests/auth/client-cert-service.yaml`: Service CA certificate generation - `examples/manifests/auth/rbac.yaml`: Required RBAC permissions for authentication - `examples/manifests/consumer.yaml`: Enhanced consumer deployment with authentication - `examples/manifests/README.md`: Complete deployment guide (307 lines) **Documentation and Guides:** - `AUTHENTICATION_IMPLEMENTATION.md`: Comprehensive implementation guide (337 lines) - Enhanced `README.md`: Authentication overview and integration guide - `examples/manifests/auth/README.md`: Authentication setup instructions (196 lines) - `examples/manifests/auth/certificate-example.md`: Manual certificate setup guide **Main Application:** - `cmd/main.go`: Added `--auth-config` flag and authentication initialization - `cmd/main_test.go`: Updated tests to support authentication parameter - Enhanced test coverage in `pkg/plugins/handler_test.go` and `plugins/ptp_operator/ptp_operator_plugin_test.go` **Build and Development:** - `Makefile`: Added `deploy-consumer` and `undeploy-consumer` targets - `hack/run-functests.sh`: Updated for Ginkgo v1 compatibility - `.gitignore`: Added binary exclusions - `go.mod`/`go.sum`: Added JWT authentication dependencies **Automated Certificate Management:** - Service CA annotation-based certificate generation - Automatic CA bundle injection via ConfigMaps - Dynamic secret creation and management - Zero-configuration certificate rotation **OAuth Server Integration:** - Native OpenShift OAuth server support - ServiceAccount token authentication - Dynamic cluster name configuration via environment variables - JWKS endpoint integration for token validation **Comprehensive Token Validation:** - JWT signature verification against JWKS endpoints - Token expiration and audience validation - Support for both OpenShift OAuth and ServiceAccount tokens - Secure token storage and transmission **Certificate-Based Authentication:** - Client certificate validation with configurable CA trust - Server certificate verification with hostname validation - Support for both Service CA and cert-manager certificates - Secure TLS configuration with proper cipher suites 1. **Configuration Loading**: JSON-based authentication configuration 2. **Certificate Setup**: Automatic certificate retrieval from Kubernetes secrets 3. **Token Acquisition**: ServiceAccount token or OAuth token retrieval 4. **Authenticated Requests**: mTLS and OAuth-enabled HTTP client 5. **Dynamic Reconnection**: Automatic token refresh and certificate rotation **Automated Setup:** ```bash export CLUSTER_NAME=your-cluster.example.com make deploy-consumer ``` **Manual Configuration:** - Complete OpenShift manifests for production deployment - Service CA integration for automatic certificate management - RBAC configuration for proper permissions - ConfigMap-based dynamic configuration - Authentication is optional and configurable - Existing deployments continue to work without authentication - Graceful fallback for non-authenticated scenarios - Clear error messages for configuration issues - Updated unit tests for authentication integration - Functional test compatibility with Ginkgo v1 - Example applications for testing authentication flows - Comprehensive error handling and logging - `github.com/golang-jwt/jwt/v5`: Secure JWT token validation - Updated `rest-api` integration with authentication support - Enhanced vendor dependencies for security libraries This implementation provides enterprise-grade authentication for cloud event communication while maintaining full backward compatibility and supporting flexible deployment scenarios across different OpenShift environments. The authentication system integrates seamlessly with OpenShift's native security features and provides a complete solution for secure cloud event processing in production environments. Signed-off-by: Jack Ding <jackding@gmail.com>
6a0a606 to
99f9ec1
Compare
Signed-off-by: Jack Ding <jackding@gmail.com>
|
@jzding: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Assisted by Cursor AI
This PR introduces enterprise-grade authentication support for the cloud-event-proxy, enabling secure communication for both event consumers and producers in production OpenShift environments.
🚀 Key Features
Authentication Methods
Client-Side Implementation
pkg/auth/implementation for client authentication🏗️ Architecture Overview
Core Components
pkg/auth/client.go- HTTP client with authentication capabilities (172 lines)pkg/auth/config.go- Configuration management and validation (195 lines)pkg/restclient/client.go- Authenticated REST client integrationpkg/common/common.go- Authentication flow integrationConsumer Implementation
examples/consumer/main.go- Complete authenticated consumer example (91+ lines added)examples/auth-examples/auth-examples.go- Comprehensive authentication examples (316 lines)📦 OpenShift Integration
Automated Deployment
examples/manifests/auth/setup-secrets.sh- Automated authentication setup (111 lines)Deployment Manifests
examples/manifests/consumer.yaml- Enhanced consumer deployment with authenticationexamples/manifests/auth/configmap.yaml- Dynamic authentication configurationexamples/manifests/auth/client-cert-service.yaml- Service CA certificate generation📚 Comprehensive Documentation
Implementation Guides
AUTHENTICATION_IMPLEMENTATION.md- Complete implementation guide (337 lines)examples/consumer/README.md- Consumer authentication guide (383 lines)examples/manifests/README.md- Deployment guide with authentication (307 lines)examples/manifests/auth/README.md- Authentication setup instructions (196 lines)Updated Main Documentation
README.md- Authentication overview and integration guide (140+ lines added)🔧 Build and Development
Enhanced Makefile
Development Support
.gitignore- Binary exclusions for clean development🛡️ Security Features
Comprehensive Validation
OpenShift Service CA Integration
🚀 Usage Examples
Basic Authentication Configuration
{ "enableMTLS": true, "useServiceCA": true, "clientCertPath": "/etc/cloud-event-consumer/client-certs/tls.crt", "clientKeyPath": "/etc/cloud-event-consumer/client-certs/tls.key", "caCertPath": "/etc/cloud-event-consumer/ca-bundle/service-ca.crt", "enableOAuth": true, "useOpenShiftOAuth": true, "oauthIssuer": "https://oauth-openshift.apps.cluster.example.com", "serviceAccountName": "consumer-sa" }Automated Deployment
🔄 Backward Compatibility
📊 Impact
github.com/golang-jwt/jwt/v5for secure JWT validation🎯 Use Cases
This authentication system enables:
🧪 Testing
The implementation includes: