@@ -21,9 +21,7 @@ class Client:
2121 """
2222 Client bindings for RAG server REST API - handles ingestor lifecycle and data ingestion
2323
24- Supports two authentication modes:
25- 1. OAuth2 Client Credentials (production) - via INGESTOR_OIDC_* env vars
26- 2. Trusted Network (development) - no authentication required
24+ Uses OAuth2 Client Credentials via INGESTOR_OIDC_* env vars.
2725 """
2826
2927 def __init__ (self , ingestor_name : str , ingestor_type : str , ingestor_description : str = "" , ingestor_metadata : Optional [Dict [str , Any ]] = {}):
@@ -83,7 +81,7 @@ def __init__(self, ingestor_name: str, ingestor_type: str, ingestor_description:
8381 logger .info (f" - INGESTOR_OIDC_DISCOVERY_URL: { 'SET' if has_discovery_url else 'NOT SET' } " )
8482 logger .info (f" - INGESTOR_OIDC_CLIENT_ID: { 'SET' if has_client_id else 'NOT SET' } " )
8583 logger .info (f" - INGESTOR_OIDC_CLIENT_SECRET: { 'SET' if has_client_secret else 'NOT SET' } " )
86- logger .info (" - Authentication mode: TRUSTED NETWORK ( will send unauthenticated requests )" )
84+ logger .info (" - Authentication mode: NOT CONFIGURED (requests will fail before send )" )
8785
8886 # Note: Health check will be done during initialize() with aiohttp
8987
@@ -212,20 +210,22 @@ async def _fetch_discovery(self, discovery_url: str) -> str:
212210 logger .info (f"Ingestor '{ self .ingestor_name } ': ✓ Discovered token endpoint: { self ._token_endpoint } " )
213211 return self ._token_endpoint
214212
215- async def _get_access_token (self ) -> Optional [ str ] :
213+ async def _get_access_token (self ) -> str :
216214 """
217215 Get valid OAuth2 access token using client credentials flow.
218216
219217 Token is cached and automatically refreshed before expiry.
220- Returns None if OAuth2 is not configured (trusted network mode).
221218
222219 Returns:
223- Access token string or None
220+ Access token string
224221 """
225222 # Check if OAuth2 is configured (need either issuer or discovery URL, plus client credentials)
226223 if not (self .oidc_issuer or self .oidc_discovery_url ) or not self .oidc_client_id or not self .oidc_client_secret :
227- # Trusted network mode - no token needed
228- return None
224+ raise RuntimeError (
225+ "Ingestor OAuth2 client credentials are required: configure "
226+ "INGESTOR_OIDC_ISSUER or INGESTOR_OIDC_DISCOVERY_URL, "
227+ "INGESTOR_OIDC_CLIENT_ID, and INGESTOR_OIDC_CLIENT_SECRET"
228+ )
229229
230230 # Check if cached token is still valid (with 60s buffer)
231231 if self ._access_token and self ._token_expiry :
@@ -275,8 +275,7 @@ async def _get_auth_headers(self) -> Dict[str, str]:
275275 """
276276 Get authentication headers for RAG server requests.
277277
278- Returns headers with Authorization Bearer token if OAuth2 is configured,
279- otherwise returns basic headers for trusted network mode.
278+ Returns headers with an Authorization Bearer token.
280279
281280 Also includes X-Ingestor-Type and X-Ingestor-Name headers for identification.
282281
@@ -289,13 +288,9 @@ async def _get_auth_headers(self) -> Dict[str, str]:
289288 headers ["X-Ingestor-Type" ] = self .ingestor_type
290289 headers ["X-Ingestor-Name" ] = self .ingestor_name
291290
292- # Get access token (None if trusted network mode)
293291 token = await self ._get_access_token ()
294- if token :
295- headers ["Authorization" ] = f"Bearer { token } "
296- logger .debug (f"Ingestor '{ self .ingestor_name } ': Sending AUTHENTICATED request (OAuth2 Bearer token)" )
297- else :
298- logger .debug (f"Ingestor '{ self .ingestor_name } ': Sending UNAUTHENTICATED request (trusted network mode)" )
292+ headers ["Authorization" ] = f"Bearer { token } "
293+ logger .debug (f"Ingestor '{ self .ingestor_name } ': Sending AUTHENTICATED request (OAuth2 Bearer token)" )
299294
300295 return headers
301296
0 commit comments