@@ -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,29 +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- 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 > ,
320299
321300 // Kafka configuration (conditionally compiled)
322301 #[ cfg( any(
@@ -385,6 +364,31 @@ pub struct Options {
385364 pub ms_clarity_tag : Option < String > ,
386365}
387366
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+
388392impl Options {
389393 pub fn local_stream_data_path ( & self , stream_name : & str ) -> PathBuf {
390394 self . local_staging_path . join ( stream_name)
@@ -399,28 +403,24 @@ impl Options {
399403 }
400404
401405 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 ( ) ,
422417 }
423- _ => None ,
424- }
418+ } ;
419+ Some ( OpenidConfig {
420+ id : client_id. clone ( ) ,
421+ secret : secret. clone ( ) ,
422+ issuer : issuer. clone ( ) ,
423+ origin,
424+ } )
425425 }
426426}
0 commit comments