Skip to content

Commit 63dd2ac

Browse files
committed
update docs
Signed-off-by: Jack Ding <jackding@gmail.com>
1 parent bd55f10 commit 63dd2ac

File tree

3 files changed

+103
-4
lines changed

3 files changed

+103
-4
lines changed

AUTHENTICATION.md

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,17 @@ This document describes how to configure mTLS (mutual TLS) and OAuth authenticat
77
The REST API supports two authentication mechanisms that can be applied to specific endpoints:
88

99
1. **mTLS (Mutual TLS)**: Client certificate-based authentication using OpenShift Service CA
10-
2. **OAuth**: Bearer token-based authentication using OpenShift's built-in OAuth server and JWT tokens
10+
2. **OAuth**: Bearer token-based authentication using OpenShift's built-in OAuth server and JWT tokens with **strict validation**
1111

1212
Both mechanisms can be enabled independently or together for enhanced security. This unified approach works seamlessly for both single node and multi-node OpenShift clusters, providing enterprise-grade security with minimal complexity.
1313

14+
### Security Guarantees
15+
16+
- **No Authentication Bypass**: When OAuth is enabled, all requests must include valid JWT tokens
17+
- **Strict Issuer Validation**: Token issuer must exactly match the configured OAuth issuer
18+
- **Comprehensive Token Validation**: Expiration, audience, and signature verification
19+
- **Clear Error Messages**: Authentication failures return specific error codes without exposing sensitive information
20+
1421
## Protected vs Public Endpoints
1522

1623
### Protected Endpoints (Require Authentication)
@@ -326,6 +333,47 @@ curl -X GET https://localhost:9043/api/ocloudNotifications/v2/health \
326333
--cacert /etc/cloud-event-proxy/ca-bundle/service-ca.crt
327334
```
328335

336+
## OAuth Security Implementation
337+
338+
### Strict Validation Features
339+
340+
The OAuth implementation includes comprehensive security measures:
341+
342+
1. **Issuer Validation**:
343+
```
344+
Token issuer mismatch: expected https://oauth-openshift.apps.cluster.com, got https://dummy.com
345+
```
346+
- Tokens from unauthorized issuers are immediately rejected
347+
- No bypass mechanisms or fallbacks
348+
349+
2. **Expiration Checking**:
350+
```
351+
Token expired
352+
```
353+
- Expired tokens are rejected with clear error messages
354+
- Time-based validation prevents replay attacks
355+
356+
3. **Audience Validation**:
357+
```
358+
Token audience validation failed
359+
```
360+
- Tokens must contain the required audience claim
361+
- Prevents token misuse across different services
362+
363+
4. **Missing Token Handling**:
364+
```
365+
Authorization header required
366+
Bearer token required
367+
```
368+
- Clear error messages for missing or malformed tokens
369+
- Proper HTTP status codes (401 Unauthorized)
370+
371+
### Security Libraries
372+
373+
- **JWT Library**: Uses `golang-jwt/jwt/v5` for secure token parsing and validation
374+
- **Cryptographic Verification**: Full signature validation against JWKS endpoints
375+
- **Memory Safety**: Secure token handling without exposing sensitive data in logs
376+
329377
## Security Considerations
330378

331379
1. **Certificate Management**
@@ -334,7 +382,8 @@ curl -X GET https://localhost:9043/api/ocloudNotifications/v2/health \
334382
- Consider using a certificate manager in production
335383

336384
2. **OAuth Security**
337-
- Use a proper JWT validation library in production
385+
- **Strict Validation**: All tokens are validated against the exact configured issuer
386+
- **No Bypass Mechanisms**: Authentication cannot be bypassed with mismatched issuers
338387
- Implement token caching and JWKS key rotation
339388
- Validate all claims (issuer, audience, scopes, expiration)
340389

OPENSHIFT_AUTHENTICATION.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,43 @@ The same configuration works for both single node and multi-node clusters:
100100
}
101101
```
102102

103+
### Dynamic Cluster Configuration
104+
105+
For environments with multiple clusters or dynamic cluster names, use the `CLUSTER_NAME` environment variable:
106+
107+
#### Environment Variable Configuration
108+
```bash
109+
# Default cluster name (used by ptp-operator)
110+
export CLUSTER_NAME="openshift.local"
111+
112+
# Custom cluster name
113+
export CLUSTER_NAME="cnfdg4.sno.ptp.eng.rdu2.dc.redhat.com"
114+
115+
# OAuth URLs are automatically generated as:
116+
# https://oauth-openshift.apps.${CLUSTER_NAME}
117+
```
118+
119+
#### Template Configuration
120+
```json
121+
{
122+
"enableMTLS": true,
123+
"useServiceCA": true,
124+
"caCertPath": "/etc/cloud-event-proxy/ca-bundle/service-ca.crt",
125+
"serverCertPath": "/etc/cloud-event-proxy/server-certs/tls.crt",
126+
"serverKeyPath": "/etc/cloud-event-proxy/server-certs/tls.key",
127+
"enableOAuth": true,
128+
"useOpenShiftOAuth": true,
129+
"oauthIssuer": "https://oauth-openshift.apps.{{.ClusterName}}",
130+
"oauthJWKSURL": "https://oauth-openshift.apps.{{.ClusterName}}/oauth/jwks",
131+
"requiredScopes": ["user:info"],
132+
"requiredAudience": "openshift",
133+
"serviceAccountName": "cloud-event-proxy-sa",
134+
"serviceAccountToken": "/var/run/secrets/kubernetes.io/serviceaccount/token"
135+
}
136+
```
137+
138+
This ensures OAuth issuer URLs match your actual OpenShift cluster configuration and prevents authentication bypass due to issuer mismatches.
139+
103140
### Key Configuration Fields
104141

105142
#### mTLS Configuration:
@@ -350,4 +387,3 @@ The Service CA + OpenShift OAuth approach provides:
350387
-**Cost Effective**: No additional licensing or resource costs
351388

352389
This approach scales from single node to large multi-node clusters without any configuration changes, making it the ideal solution for OpenShift deployments of any size.
353-

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,25 @@ The REST-API specification below is generated by Swagger tools. Please refer to
99

1010
## Authentication
1111

12-
This REST API supports enterprise-grade authentication using mTLS and OAuth. For detailed configuration instructions, see:
12+
This REST API supports enterprise-grade authentication using mTLS and OAuth with **strict security validation**. For detailed configuration instructions, see:
1313

1414
- **[Authentication Configuration](AUTHENTICATION.md)** - Complete guide for configuring mTLS and OAuth authentication
1515
- **[OpenShift Authentication](OPENSHIFT_AUTHENTICATION.md)** - OpenShift-specific deployment guide with native Service CA and OAuth server integration
1616

17+
### Security Features
18+
19+
- **Strict OAuth Validation**: JWT tokens are validated against the configured issuer with no bypass mechanisms
20+
- **Issuer Verification**: Token issuer must exactly match the configured OAuth issuer
21+
- **Expiration Checking**: Expired tokens are rejected with clear error messages
22+
- **Audience Validation**: Tokens must contain the required audience claim
23+
- **mTLS Certificate Validation**: Client certificates are verified against the configured CA
24+
25+
### Recent Security Improvements
26+
27+
- **Fixed OAuth Security Vulnerability** (v2.1.0): Implemented proper OAuth token validation to prevent unauthorized access
28+
- **Added JWT Library Support**: Uses `golang-jwt/jwt/v5` for secure token parsing and validation
29+
- **Enhanced Error Handling**: Clear error messages for authentication failures without exposing sensitive information
30+
1731
## O-RAN Compliant REST API Specification
1832

1933
Starting from release [v1.21.0](https://github.com/redhat-cne/rest-api/releases/tag/v1.21.0), the REST API implemented in this repo is compliant with [O-RAN O-Cloud Notification API Specification for Event Consumers 4.0](https://orandownloadsweb.azurewebsites.net/specifications).

0 commit comments

Comments
 (0)