@@ -52,7 +52,7 @@ pub const DEFAULT_PASSWORD: &str = "admin";
52
52
long_about = r#"
53
53
Cloud Native, log analytics platform for modern applications.
54
54
55
- Usage:
55
+ Usage:
56
56
parseable [command] [options..]
57
57
58
58
@@ -126,7 +126,7 @@ pub struct Options {
126
126
// Server configuration
127
127
#[ arg(
128
128
long,
129
- env = "P_ADDR" ,
129
+ env = "P_ADDR" ,
130
130
default_value = "0.0.0.0:8000" ,
131
131
value_parser = validation:: socket_addr,
132
132
help = "Address and port for Parseable HTTP(s) server"
@@ -294,29 +294,8 @@ pub struct Options {
294
294
) ]
295
295
pub ingestor_endpoint : String ,
296
296
297
- // OIDC Configuration
298
- #[ arg(
299
- long,
300
- long = "oidc-client" ,
301
- env = "P_OIDC_CLIENT_ID" ,
302
- help = "Client id for OIDC provider"
303
- ) ]
304
- oidc_client_id : Option < String > ,
305
-
306
- #[ arg(
307
- long,
308
- env = "P_OIDC_CLIENT_SECRET" ,
309
- help = "Client secret for OIDC provider"
310
- ) ]
311
- oidc_client_secret : Option < String > ,
312
-
313
- #[ arg(
314
- long,
315
- env = "P_OIDC_ISSUER" ,
316
- value_parser = validation:: url,
317
- help = "OIDC provider's host address"
318
- ) ]
319
- oidc_issuer : Option < Url > ,
297
+ #[ command( flatten) ]
298
+ oidc : Option < OidcConfig > ,
320
299
321
300
// Kafka configuration (conditionally compiled)
322
301
#[ cfg( any(
@@ -385,6 +364,31 @@ pub struct Options {
385
364
pub ms_clarity_tag : Option < String > ,
386
365
}
387
366
367
+ #[ derive( Parser , Debug ) ]
368
+ pub struct OidcConfig {
369
+ #[ arg(
370
+ long = "oidc-client-id" ,
371
+ env = "P_OIDC_CLIENT_ID" ,
372
+ help = "Client id for OIDC provider"
373
+ ) ]
374
+ pub client_id : String ,
375
+
376
+ #[ arg(
377
+ long = "oidc-client-secret" ,
378
+ env = "P_OIDC_CLIENT_SECRET" ,
379
+ help = "Client secret for OIDC provider"
380
+ ) ]
381
+ pub secret : String ,
382
+
383
+ #[ arg(
384
+ long = "oidc-issuer" ,
385
+ env = "P_OIDC_ISSUER" ,
386
+ value_parser = validation:: url,
387
+ help = "OIDC provider's host address"
388
+ ) ]
389
+ pub issuer : Url ,
390
+ }
391
+
388
392
impl Options {
389
393
pub fn local_stream_data_path ( & self , stream_name : & str ) -> PathBuf {
390
394
self . local_staging_path . join ( stream_name)
@@ -399,28 +403,24 @@ impl Options {
399
403
}
400
404
401
405
pub fn openid ( & self ) -> Option < OpenidConfig > {
402
- match (
403
- & self . oidc_client_id ,
404
- & self . oidc_client_secret ,
405
- & self . oidc_issuer ,
406
- ) {
407
- ( Some ( id) , Some ( secret) , Some ( issuer) ) => {
408
- let origin = if let Some ( url) = self . domain_address . clone ( ) {
409
- oidc:: Origin :: Production ( url)
410
- } else {
411
- oidc:: Origin :: Local {
412
- socket_addr : self . address . clone ( ) ,
413
- https : self . tls_cert_path . is_some ( ) && self . tls_key_path . is_some ( ) ,
414
- }
415
- } ;
416
- Some ( OpenidConfig {
417
- id : id. clone ( ) ,
418
- secret : secret. clone ( ) ,
419
- issuer : issuer. clone ( ) ,
420
- origin,
421
- } )
406
+ let OidcConfig {
407
+ secret,
408
+ client_id,
409
+ issuer,
410
+ } = self . oidc . as_ref ( ) ?;
411
+ let origin = if let Some ( url) = self . domain_address . clone ( ) {
412
+ oidc:: Origin :: Production ( url)
413
+ } else {
414
+ oidc:: Origin :: Local {
415
+ socket_addr : self . address . clone ( ) ,
416
+ https : self . tls_cert_path . is_some ( ) && self . tls_key_path . is_some ( ) ,
422
417
}
423
- _ => None ,
424
- }
418
+ } ;
419
+ Some ( OpenidConfig {
420
+ id : client_id. clone ( ) ,
421
+ secret : secret. clone ( ) ,
422
+ issuer : issuer. clone ( ) ,
423
+ origin,
424
+ } )
425
425
}
426
426
}
0 commit comments