@@ -52,7 +52,7 @@ pub const DEFAULT_PASSWORD: &str = "admin";
5252 long_about = r#"
5353Cloud Native, log analytics platform for modern applications.
5454
55- Usage:
55+ Usage:
5656parseable [command] [options..]
5757
5858
@@ -126,7 +126,7 @@ pub struct Options {
126126 // Server configuration
127127 #[ arg(
128128 long,
129- env = "P_ADDR" ,
129+ env = "P_ADDR" ,
130130 default_value = "0.0.0.0:8000" ,
131131 value_parser = validation:: socket_addr,
132132 help = "Address and port for Parseable HTTP(s) server"
@@ -294,35 +294,8 @@ pub struct Options {
294294 ) ]
295295 pub ingestor_endpoint : String ,
296296
297- // OIDC Configuration
298- #[ arg(
299- long,
300- long = "oidc-client" ,
301- env = "P_OIDC_CLIENT_ID" ,
302- requires = "oidc" ,
303- group = "oidc" ,
304- help = "Client id for OIDC provider"
305- ) ]
306- oidc_client_id : Option < String > ,
307-
308- #[ arg(
309- long,
310- env = "P_OIDC_CLIENT_SECRET" ,
311- requires = "oidc" ,
312- group = "oidc" ,
313- help = "Client secret for OIDC provider"
314- ) ]
315- oidc_client_secret : Option < String > ,
316-
317- #[ arg(
318- long,
319- env = "P_OIDC_ISSUER" ,
320- value_parser = validation:: url,
321- requires = "oidc" ,
322- group = "oidc" ,
323- help = "OIDC provider's host address"
324- ) ]
325- oidc_issuer : Option < Url > ,
297+ #[ command( flatten) ]
298+ oidc : Option < OidcConfig > ,
326299
327300 // Kafka configuration (conditionally compiled)
328301 #[ cfg( any(
@@ -391,6 +364,37 @@ pub struct Options {
391364 pub ms_clarity_tag : Option < String > ,
392365}
393366
367+ #[ derive( Parser , Debug ) ]
368+ pub struct OidcConfig {
369+ #[ arg(
370+ long = "oidc-client" ,
371+ name = "oidc-client" ,
372+ env = "P_OIDC_CLIENT_ID" ,
373+ required = false ,
374+ help = "Client id for OIDC provider"
375+ ) ]
376+ pub client_id : String ,
377+
378+ #[ arg(
379+ long = "oidc-client-secret" ,
380+ name = "oidc-client-secret" ,
381+ env = "P_OIDC_CLIENT_SECRET" ,
382+ required = false ,
383+ help = "Client secret for OIDC provider"
384+ ) ]
385+ pub secret : String ,
386+
387+ #[ arg(
388+ long = "oidc-issuer" ,
389+ name = "oidc-issuer" ,
390+ env = "P_OIDC_ISSUER" ,
391+ required = false ,
392+ value_parser = validation:: url,
393+ help = "OIDC provider's host address"
394+ ) ]
395+ pub issuer : Url ,
396+ }
397+
394398impl Options {
395399 pub fn local_stream_data_path ( & self , stream_name : & str ) -> PathBuf {
396400 self . local_staging_path . join ( stream_name)
@@ -405,28 +409,24 @@ impl Options {
405409 }
406410
407411 pub fn openid ( & self ) -> Option < OpenidConfig > {
408- match (
409- & self . oidc_client_id ,
410- & self . oidc_client_secret ,
411- & self . oidc_issuer ,
412- ) {
413- ( Some ( id) , Some ( secret) , Some ( issuer) ) => {
414- let origin = if let Some ( url) = self . domain_address . clone ( ) {
415- oidc:: Origin :: Production ( url)
416- } else {
417- oidc:: Origin :: Local {
418- socket_addr : self . address . clone ( ) ,
419- https : self . tls_cert_path . is_some ( ) && self . tls_key_path . is_some ( ) ,
420- }
421- } ;
422- Some ( OpenidConfig {
423- id : id. clone ( ) ,
424- secret : secret. clone ( ) ,
425- issuer : issuer. clone ( ) ,
426- origin,
427- } )
412+ let OidcConfig {
413+ secret,
414+ client_id,
415+ issuer,
416+ } = self . oidc . as_ref ( ) ?;
417+ let origin = if let Some ( url) = self . domain_address . clone ( ) {
418+ oidc:: Origin :: Production ( url)
419+ } else {
420+ oidc:: Origin :: Local {
421+ socket_addr : self . address . clone ( ) ,
422+ https : self . tls_cert_path . is_some ( ) && self . tls_key_path . is_some ( ) ,
428423 }
429- _ => None ,
430- }
424+ } ;
425+ Some ( OpenidConfig {
426+ id : client_id. clone ( ) ,
427+ secret : secret. clone ( ) ,
428+ issuer : issuer. clone ( ) ,
429+ origin,
430+ } )
431431 }
432432}
0 commit comments