Skip to content

Commit 8a8ee8e

Browse files
committed
cleanup multi provider
1 parent 2f00ca9 commit 8a8ee8e

11 files changed

Lines changed: 215 additions & 1155 deletions

File tree

.env.example

Lines changed: 52 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,52 @@
1-
### OBP-API Configuration ###
2-
VITE_OBP_API_PORTAL_HOST=http://127.0.0.1:8080 # OBP API Portal URL (for "Portal Home" navigation link)
3-
VITE_OBP_API_HOST=http://127.0.0.1:8080 # OBP API server base URL (for all backend API requests)
4-
# VITE_OBP_API_VERSION is NO LONGER USED - hardcoded to v5.1.0 in shared-constants.ts for stability
5-
VITE_OBP_API_MANAGER_HOST=https://apimanagersandbox.openbankproject.com # OBP API Manager URL (optional - for navigation link)
6-
VITE_OBP_API_EXPLORER_HOST=http://localhost:5173 # API Explorer application URL (used for OAuth2 redirects and internal routing)
7-
VITE_OPB_SERVER_SESSION_PASSWORD=your-secret-session-password-here # Secret key for session encryption (keep this secure!)
8-
VITE_SHOW_API_MANAGER_BUTTON=false # Show/hide API Manager button in navigation (true/false)
9-
10-
### Redis Configuration ###
11-
VITE_OBP_REDIS_URL=redis://127.0.0.1:6379 # Redis connection string for session storage (format: redis://host:port)
12-
13-
### Opey Configuration ###
14-
VITE_CHATBOT_ENABLED=false # Enable/disable Opey chatbot widget (true/false)
15-
VITE_CHATBOT_URL=http://localhost:5000 # Opey chatbot service URL (only needed if chatbot is enabled)
16-
17-
### OAuth2/OIDC Configuration ###
18-
VITE_OBP_OAUTH2_CLIENT_ID=48ac28e9-9ee3-47fd-8448-69a62764b779 # OAuth2 client ID (UUID - must match OIDC server registration)
19-
VITE_OBP_OAUTH2_CLIENT_SECRET=fOTQF7jfg8C74u7ZhSjVQpoBYvD0KpWfM5UsEZBSFFM # OAuth2 client secret (keep this secure!)
20-
VITE_OBP_OAUTH2_REDIRECT_URL=http://localhost:5173/api/oauth2/callback # OAuth2 callback URL (must exactly match OIDC client registration)
21-
VITE_OBP_OAUTH2_WELL_KNOWN_URL=http://localhost:9000/obp-oidc/.well-known/openid-configuration # OIDC discovery endpoint URL
22-
VITE_OBP_OAUTH2_TOKEN_REFRESH_THRESHOLD=300 # Seconds before token expiry to trigger refresh (default: 300)
23-
24-
### Resource Documentation Version (Optional) ###
25-
# VITE_OBP_API_DEFAULT_RESOURCE_DOC_VERSION=OBPv5.1.0 # Default resource docs version for frontend URLs (format: OBPv5.1.0 - with OBP prefix, auto-constructed if not set)
26-
27-
### Session Configuration (Optional) ###
28-
# VITE_SESSION_MAX_AGE=3600 # Session timeout in seconds (default: 3600 = 1 hour)
29-
30-
### Styling Configuration (Optional) ###
31-
# VITE_OBP_LOGO_URL=https://example.com/logo.png # Custom logo image URL (uses default OBP logo if not set)
32-
# VITE_OBP_LINKS_COLOR=#3c8dbc # Primary link color (CSS color value)
33-
# VITE_OBP_HEADER_LINKS_COLOR=#39455f # Header navigation link color
34-
# VITE_OBP_HEADER_LINKS_HOVER_COLOR=#39455f # Header navigation link hover color
35-
# VITE_OBP_HEADER_LINKS_BACKGROUND_COLOR=#eef0f4 # Header navigation active link background color
1+
### OBP API Configuration ###
2+
VITE_OBP_API_HOST=http://127.0.0.1:8080
3+
VITE_OBP_API_VERSION=v5.1.0
4+
5+
### API Explorer Host ###
6+
VITE_OBP_API_EXPLORER_HOST=http://localhost:5173
7+
8+
### Session Configuration ###
9+
VITE_OPB_SERVER_SESSION_PASSWORD=change-me-to-a-secure-random-string
10+
11+
### OAuth2 Redirect URL (shared by all providers) ###
12+
VITE_OAUTH2_REDIRECT_URL=http://localhost:5173/api/oauth2/callback
13+
14+
### Redis Configuration (Optional - uses localhost:6379 if not set) ###
15+
# VITE_OBP_REDIS_URL=redis://127.0.0.1:6379
16+
# VITE_OBP_REDIS_PASSWORD=
17+
# VITE_OBP_REDIS_USERNAME=
18+
19+
### Multi-Provider OAuth2/OIDC Configuration ###
20+
### The system fetches available providers from: http://localhost:8080/obp/v5.1.0/well-known
21+
### Configure credentials below for each provider you want to support
22+
23+
### OBP-OIDC Provider ###
24+
VITE_OBP_OIDC_CLIENT_ID=your-obp-oidc-client-id
25+
VITE_OBP_OIDC_CLIENT_SECRET=your-obp-oidc-client-secret
26+
27+
### OBP Consumer Key (for API calls) ###
28+
VITE_OBP_CONSUMER_KEY=your-obp-oidc-client-id
29+
30+
### Keycloak Provider (Optional) ###
31+
# VITE_KEYCLOAK_CLIENT_ID=your-keycloak-client-id
32+
# VITE_KEYCLOAK_CLIENT_SECRET=your-keycloak-client-secret
33+
34+
### Google Provider (Optional) ###
35+
# VITE_GOOGLE_CLIENT_ID=your-google-client-id.apps.googleusercontent.com
36+
# VITE_GOOGLE_CLIENT_SECRET=your-google-client-secret
37+
38+
### GitHub Provider (Optional) ###
39+
# VITE_GITHUB_CLIENT_ID=your-github-client-id
40+
# VITE_GITHUB_CLIENT_SECRET=your-github-client-secret
41+
42+
### Custom OIDC Provider (Optional) ###
43+
# VITE_CUSTOM_OIDC_PROVIDER_NAME=my-custom-provider
44+
# VITE_CUSTOM_OIDC_CLIENT_ID=your-custom-client-id
45+
# VITE_CUSTOM_OIDC_CLIENT_SECRET=your-custom-client-secret
46+
47+
### Chatbot Configuration (Optional) ###
48+
VITE_CHATBOT_ENABLED=false
49+
# VITE_CHATBOT_URL=http://localhost:5000
50+
51+
### Resource Docs Version ###
52+
VITE_OBP_API_DEFAULT_RESOURCE_DOC_VERSION=OBPv6.0.0

env_ai

Lines changed: 52 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,63 @@
1-
### OBP-API Configuration ###
2-
VITE_OBP_API_PORTAL_HOST=http://127.0.0.1:8080
1+
### OBP API Configuration ###
32
VITE_OBP_API_HOST=http://127.0.0.1:8080
4-
VITE_OBP_API_VERSION=v5.1.0
5-
VITE_OBP_API_MANAGER_HOST=https://apimanagersandbox.openbankproject.com
6-
VITE_OBP_API_EXPLORER_HOST=http://localhost:5174
3+
VITE_OBP_API_VERSION=v6.0.0
4+
VITE_OBP_API_EXPLORER_HOST=http://localhost:5173
5+
6+
### Session Configuration ###
77
VITE_OPB_SERVER_SESSION_PASSWORD=asidudhiuh33875
88

9+
### OAuth2 Redirect URL (shared by all providers) ###
10+
VITE_OAUTH2_REDIRECT_URL=http://localhost:5173/api/oauth2/callback
11+
912
### Redis Configuration ###
1013
VITE_OBP_REDIS_URL=redis://127.0.0.1:6379
1114

12-
### Opey Configuration ###
15+
### Chatbot Configuration ###
1316
VITE_CHATBOT_ENABLED=false
1417
VITE_CHATBOT_URL=http://localhost:5000
1518

16-
### OAuth2/OIDC Configuration ###
17-
# OAuth2 Client Credentials (from OBP-OIDC)
18-
VITE_OBP_OAUTH2_CLIENT_ID=48ac28e9-9ee3-47fd-8448-69a62764b779
19-
VITE_OBP_OAUTH2_CLIENT_SECRET=fOTQF7jfg8C74u7ZhSjVQpoBYvD0KpWfM5UsEZBSFFM
20-
VITE_OBP_OAUTH2_REDIRECT_URL=http://localhost:5173/api/oauth2/callback
19+
### Multi-Provider OAuth2/OIDC Configuration ###
20+
### The system fetches available providers from: http://localhost:8080/obp/v5.1.0/well-known
21+
### Configure credentials below for each provider you want to support
22+
23+
### OBP-OIDC Provider ###
24+
VITE_OBP_OIDC_CLIENT_ID=c2ea173e-8c1a-43c4-ba62-19738f27c43e
25+
VITE_OBP_OIDC_CLIENT_SECRET=1E7zsN47Xp4VTb28xEv5ZK4vcX8XMsYIH3IsnjQTYk8
26+
27+
### OBP Consumer Key (for API calls) ###
28+
VITE_OBP_CONSUMER_KEY=c2ea173e-8c1a-43c4-ba62-19738f27c43e
29+
30+
### Keycloak Provider (Optional) ###
31+
# VITE_KEYCLOAK_CLIENT_ID=obp-api-explorer
32+
# VITE_KEYCLOAK_CLIENT_SECRET=your-keycloak-secret-here
33+
34+
### Google Provider (Optional) ###
35+
# VITE_GOOGLE_CLIENT_ID=your-google-client-id.apps.googleusercontent.com
36+
# VITE_GOOGLE_CLIENT_SECRET=your-google-client-secret
37+
38+
### GitHub Provider (Optional) ###
39+
# VITE_GITHUB_CLIENT_ID=your-github-client-id
40+
# VITE_GITHUB_CLIENT_SECRET=your-github-client-secret
41+
42+
### Custom OIDC Provider (Optional) ###
43+
# VITE_CUSTOM_OIDC_PROVIDER_NAME=my-custom-provider
44+
# VITE_CUSTOM_OIDC_CLIENT_ID=your-custom-client-id
45+
# VITE_CUSTOM_OIDC_CLIENT_SECRET=your-custom-client-secret
46+
47+
### Opey Configuration ###
48+
VITE_OPEY_CONSUMER_ID=74545fb7-9a1f-4ee0-beb4-6e5b7ee50076
49+
50+
### Resource Docs Version ###
51+
VITE_OBP_API_DEFAULT_RESOURCE_DOC_VERSION=OBPv6.0.0
2152

22-
# OIDC Well-Known Configuration URL
23-
VITE_OBP_OAUTH2_WELL_KNOWN_URL=http://127.0.0.1:9000/obp-oidc/.well-known/openid-configuration
53+
### HOW IT WORKS ###
54+
# 1. Backend fetches provider list from OBP API: GET /obp/v5.1.0/well-known
55+
# 2. OBP API returns available providers with their .well-known URLs
56+
# 3. Backend matches providers with credentials configured above
57+
# 4. Only providers with both (API registration + credentials) will be available
58+
# 5. Users see provider selection if 2+ providers configured (or auto-login if only 1)
2459

25-
# Optional: Token refresh threshold (seconds before expiry)
26-
VITE_OBP_OAUTH2_TOKEN_REFRESH_THRESHOLD=300
60+
### VERIFY YOUR SETUP ###
61+
# curl http://localhost:8080/obp/v5.1.0/well-known
62+
# curl http://localhost:8085/api/oauth2/providers
63+
# Visit: http://localhost:5173/debug/providers-status

server/app.ts

Lines changed: 7 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import type { Application } from 'express'
3535
import { Container } from 'typedi'
3636
import path from 'path'
3737
import { execSync } from 'child_process'
38-
import { OAuth2Service } from './services/OAuth2Service.js'
3938
import { OAuth2ProviderManager } from './services/OAuth2ProviderManager.js'
4039
import { fileURLToPath } from 'url'
4140
import { dirname } from 'path'
@@ -137,9 +136,7 @@ if (app.get('env') === 'production') {
137136
}
138137
app.use(session(sessionObject))
139138

140-
// Initialize OAuth2 Service
141-
console.log(`--- OAuth2/OIDC setup -------------------------------------------`)
142-
const wellKnownUrl = process.env.VITE_OBP_OAUTH2_WELL_KNOWN_URL
139+
// OAuth2 Multi-Provider Setup only - no legacy fallback
143140

144141
// Async IIFE to initialize OAuth2 and start server
145142
let instance: any
@@ -160,61 +157,15 @@ let instance: any
160157
providerManager.startHealthCheck(60000) // Check every 60 seconds
161158
console.log('OK Provider health monitoring started (every 60s)')
162159
} else {
163-
console.warn('WARNING No OAuth2 providers initialized from OBP API')
164-
console.warn('WARNING Falling back to legacy single-provider mode...')
160+
console.error('ERROR: No OAuth2 providers initialized from OBP API')
161+
console.error(
162+
'ERROR: Check that OBP API is running and returns providers from /obp/v5.1.0/well-known'
163+
)
164+
console.error('ERROR: Server will start but login will not work')
165165
}
166166
} catch (error) {
167167
console.error('ERROR Failed to initialize OAuth2 multi-provider:', error)
168-
console.warn('WARNING Falling back to legacy single-provider mode...')
169-
}
170-
console.log(`-----------------------------------------------------------------`)
171-
172-
// Initialize Legacy OAuth2 Service (for backward compatibility)
173-
console.log(`--- OAuth2/OIDC Legacy Setup (Backward Compatibility) -----------`)
174-
if (!wellKnownUrl) {
175-
console.warn('VITE_OBP_OAUTH2_WELL_KNOWN_URL not set. Legacy OAuth2 will not function.')
176-
console.warn('Server will rely on multi-provider mode from OBP API.')
177-
} else {
178-
console.log(`OIDC Well-Known URL (legacy): ${wellKnownUrl}`)
179-
180-
// Get OAuth2Service from container
181-
const oauth2Service = Container.get(OAuth2Service)
182-
183-
// Initialize OAuth2 service with retry logic
184-
const isProduction = process.env.NODE_ENV === 'production'
185-
const maxRetries = Infinity // Retry indefinitely
186-
const initialDelay = 1000 // 1 second, then exponential backoff
187-
188-
console.log(
189-
'Attempting legacy OAuth2 initialization (will retry indefinitely with exponential backoff)...'
190-
)
191-
const success = await oauth2Service.initializeWithRetry(wellKnownUrl, maxRetries, initialDelay)
192-
193-
if (success) {
194-
console.log('OAuth2Service (legacy): Initialization successful')
195-
console.log(' Client ID:', process.env.VITE_OBP_OAUTH2_CLIENT_ID || 'NOT SET')
196-
console.log(' Redirect URI:', process.env.VITE_OBP_OAUTH2_REDIRECT_URL || 'NOT SET')
197-
console.log('Legacy OAuth2/OIDC ready for authentication')
198-
199-
// Start continuous monitoring even when initially connected
200-
oauth2Service.startHealthCheck(1000, 240000) // Monitor every 4 minutes
201-
console.log('OAuth2Service (legacy): Starting continuous monitoring (every 4 minutes)')
202-
} else {
203-
console.error('OAuth2Service (legacy): Initialization failed after all retries')
204-
205-
// Use graceful degradation for both development and production
206-
const envMode = isProduction ? 'Production' : 'Development'
207-
console.warn(`WARNING: ${envMode} mode: Server will start without legacy OAuth2`)
208-
console.warn('WARNING: Legacy login will be unavailable until OIDC server is reachable')
209-
console.warn('WARNING: Multi-provider mode will be used if available')
210-
console.warn('Please check:')
211-
console.warn(' 1. OBP-OIDC server is running')
212-
console.warn(' 2. VITE_OBP_OAUTH2_WELL_KNOWN_URL is correct')
213-
console.warn(' 3. Network connectivity to OIDC provider')
214-
215-
// Start periodic health check to reconnect when OIDC becomes available
216-
oauth2Service.startHealthCheck(1000, 240000) // Start with 1 second, monitor every 4 minutes when connected
217-
}
168+
console.error('ERROR: Server will start but login will not work')
218169
}
219170
console.log(`-----------------------------------------------------------------`)
220171

0 commit comments

Comments
 (0)