@@ -494,87 +494,99 @@ static OidcTenantConfig mergeTenantConfig(OidcTenantConfig tenant, OidcTenantCon
494
494
// OidcRecorder sets it before the merge operation
495
495
throw new IllegalStateException ();
496
496
}
497
+ var tenantBuilder = OidcTenantConfig .builder (tenant );
497
498
// root properties
498
- if (tenant .authServerUrl ().isEmpty ()) {
499
- tenant .authServerUrl = provider .authServerUrl ();
499
+ if (tenant .authServerUrl ().isEmpty () && provider . authServerUrl (). isPresent () ) {
500
+ tenantBuilder .authServerUrl ( provider .authServerUrl (). get () );
500
501
}
501
- if (tenant .applicationType ().isEmpty ()) {
502
- tenant .applicationType = provider .applicationType ;
502
+ if (tenant .applicationType ().isEmpty () && provider . applicationType (). isPresent () ) {
503
+ tenantBuilder .applicationType ( provider .applicationType (). get ()) ;
503
504
}
504
- if (tenant .discoveryEnabled ().isEmpty ()) {
505
- tenant .discoveryEnabled = provider .discoveryEnabled ();
505
+ if (tenant .discoveryEnabled ().isEmpty () && provider . discoveryEnabled (). isPresent () ) {
506
+ tenantBuilder .discoveryEnabled ( provider .discoveryEnabled (). get () );
506
507
}
507
- if (tenant .authorizationPath ().isEmpty ()) {
508
- tenant .authorizationPath = provider .authorizationPath ();
508
+ if (tenant .authorizationPath ().isEmpty () && provider . authorizationPath (). isPresent () ) {
509
+ tenantBuilder .authorizationPath ( provider .authorizationPath (). get () );
509
510
}
510
- if (tenant .jwksPath ().isEmpty ()) {
511
- tenant .jwksPath = provider .jwksPath ();
511
+ if (tenant .jwksPath ().isEmpty () && provider . jwksPath (). isPresent () ) {
512
+ tenantBuilder .jwksPath ( provider .jwksPath (). get () );
512
513
}
513
- if (tenant .tokenPath ().isEmpty ()) {
514
- tenant .tokenPath = provider .tokenPath ();
514
+ if (tenant .tokenPath ().isEmpty () && provider . tokenPath (). isPresent () ) {
515
+ tenantBuilder .tokenPath ( provider .tokenPath (). get () );
515
516
}
516
- if (tenant .userInfoPath ().isEmpty ()) {
517
- tenant .userInfoPath = provider .userInfoPath ();
517
+ if (tenant .userInfoPath ().isEmpty () && provider . userInfoPath (). isPresent () ) {
518
+ tenantBuilder .userInfoPath ( provider .userInfoPath (). get () );
518
519
}
519
520
520
521
// authentication
521
- if (tenant .authentication ().idTokenRequired ().isEmpty ()) {
522
- tenant .authentication .idTokenRequired = provider .authentication ().idTokenRequired ();
522
+ var tenantAuth = tenant .authentication ();
523
+ var providerAuth = provider .authentication ();
524
+ var authBuilder = tenantBuilder .authentication ();
525
+ if (tenantAuth .idTokenRequired ().isEmpty () && providerAuth .idTokenRequired ().isPresent ()) {
526
+ authBuilder .idTokenRequired (providerAuth .idTokenRequired ().get ());
523
527
}
524
- if (tenant . authentication ().userInfoRequired ().isEmpty ()) {
525
- tenant . authentication . userInfoRequired = provider . authentication ().userInfoRequired ( );
528
+ if (tenantAuth . userInfoRequired ().isEmpty () && providerAuth . userInfoRequired ().isPresent ()) {
529
+ authBuilder . userInfoRequired ( providerAuth . userInfoRequired ().get () );
526
530
}
527
- if (tenant . authentication ().pkceRequired ().isEmpty ()) {
528
- tenant . authentication . pkceRequired = provider . authentication ().pkceRequired ( );
531
+ if (tenantAuth . pkceRequired ().isEmpty () && providerAuth . pkceRequired ().isPresent ()) {
532
+ authBuilder . pkceRequired ( providerAuth . pkceRequired ().get () );
529
533
}
530
- if (tenant . authentication ().scopes ().isEmpty ()) {
531
- tenant . authentication . scopes = provider . authentication ().scopes ( );
534
+ if (tenantAuth . scopes ().isEmpty () && providerAuth . scopes ().isPresent ()) {
535
+ authBuilder . scopes ( providerAuth . scopes ().get () );
532
536
}
533
- if (tenant . authentication ().scopeSeparator ().isEmpty ()) {
534
- tenant . authentication . scopeSeparator = provider . authentication ().scopeSeparator ( );
537
+ if (tenantAuth . scopeSeparator ().isEmpty () && providerAuth . scopeSeparator ().isPresent ()) {
538
+ authBuilder . scopeSeparator ( providerAuth . scopeSeparator ().get () );
535
539
}
536
- if (tenant . authentication ().addOpenidScope ().isEmpty ()) {
537
- tenant . authentication . addOpenidScope = provider . authentication ().addOpenidScope ( );
540
+ if (tenantAuth . addOpenidScope ().isEmpty () && providerAuth . addOpenidScope ().isPresent ()) {
541
+ authBuilder . addOpenidScope ( providerAuth . addOpenidScope ().get () );
538
542
}
539
- if (tenant . authentication ().forceRedirectHttpsScheme ().isEmpty ()) {
540
- tenant . authentication . forceRedirectHttpsScheme = provider . authentication ().forceRedirectHttpsScheme ( );
543
+ if (tenantAuth . forceRedirectHttpsScheme ().isEmpty () && providerAuth . forceRedirectHttpsScheme ().isPresent ()) {
544
+ authBuilder . forceRedirectHttpsScheme ( providerAuth . forceRedirectHttpsScheme ().get () );
541
545
}
542
- if (tenant . authentication ().responseMode ().isEmpty ()) {
543
- tenant . authentication . responseMode = provider . authentication . responseMode ;
546
+ if (tenantAuth . responseMode ().isEmpty () && providerAuth . responseMode ().isPresent ()) {
547
+ authBuilder . responseMode ( providerAuth . responseMode (). get ()) ;
544
548
}
545
- if (tenant . authentication ().redirectPath ().isEmpty ()) {
546
- tenant . authentication . redirectPath = provider . authentication ().redirectPath ( );
549
+ if (tenantAuth . redirectPath ().isEmpty () && providerAuth . redirectPath ().isPresent ()) {
550
+ authBuilder . redirectPath ( providerAuth . redirectPath ().get () );
547
551
}
552
+ authBuilder .end ();
548
553
549
554
// credentials
550
- if (tenant .credentials ().clientSecret ().method ().isEmpty ()) {
551
- tenant .credentials .clientSecret .method = provider .credentials .clientSecret .method ;
555
+ var credentialsBuilder = tenantBuilder .credentials ();
556
+ if (tenant .credentials ().clientSecret ().method ().isEmpty ()
557
+ && provider .credentials ().clientSecret ().method ().isPresent ()) {
558
+ credentialsBuilder .clientSecret ().method (provider .credentials ().clientSecret ().method ().get ()).end ();
552
559
}
553
- if (tenant .credentials ().jwt ().audience ().isEmpty ()) {
554
- tenant . credentials . jwt .audience = provider .credentials ().jwt ().audience ();
560
+ if (tenant .credentials ().jwt ().audience ().isEmpty () && provider . credentials (). jwt (). audience (). isPresent () ) {
561
+ credentialsBuilder . jwt () .audience ( provider .credentials ().jwt ().audience (). get ()). end ();
555
562
}
556
- if (tenant .credentials ().jwt ().signatureAlgorithm ().isEmpty ()) {
557
- tenant .credentials .jwt .signatureAlgorithm = provider .credentials ().jwt ().signatureAlgorithm ();
563
+ if (tenant .credentials ().jwt ().signatureAlgorithm ().isEmpty ()
564
+ && provider .credentials ().jwt ().signatureAlgorithm ().isPresent ()) {
565
+ credentialsBuilder .jwt ().signatureAlgorithm (provider .credentials ().jwt ().signatureAlgorithm ().get ()).end ();
558
566
}
567
+ credentialsBuilder .end ();
559
568
560
569
// token
561
- if (tenant .token ().issuer ().isEmpty ()) {
562
- tenant .token .issuer = provider .token ().issuer ();
570
+ var tokenBuilder = tenantBuilder .token ();
571
+ if (tenant .token ().issuer ().isEmpty () && provider .token ().issuer ().isPresent ()) {
572
+ tokenBuilder .issuer (provider .token ().issuer ().get ());
563
573
}
564
- if (tenant .token ().principalClaim ().isEmpty ()) {
565
- tenant . token . principalClaim = provider .token ().principalClaim ();
574
+ if (tenant .token ().principalClaim ().isEmpty () && provider . token (). principalClaim (). isPresent () ) {
575
+ tokenBuilder . principalClaim ( provider .token ().principalClaim (). get () );
566
576
}
567
- if (tenant .token ().verifyAccessTokenWithUserInfo ().isEmpty ()) {
568
- tenant .token .verifyAccessTokenWithUserInfo = provider .token ().verifyAccessTokenWithUserInfo ();
577
+ if (tenant .token ().verifyAccessTokenWithUserInfo ().isEmpty ()
578
+ && provider .token ().verifyAccessTokenWithUserInfo ().isPresent ()) {
579
+ tokenBuilder .verifyAccessTokenWithUserInfo (provider .token ().verifyAccessTokenWithUserInfo ().get ());
569
580
}
581
+ tokenBuilder .end ();
570
582
571
- return tenant ;
583
+ return tenantBuilder . build () ;
572
584
}
573
585
574
586
static OidcTenantConfig resolveProviderConfig (OidcTenantConfig oidcTenantConfig ) {
575
587
if (oidcTenantConfig != null && oidcTenantConfig .provider ().isPresent ()) {
576
588
return OidcUtils .mergeTenantConfig (oidcTenantConfig ,
577
- KnownOidcProviders .provider (oidcTenantConfig .provider .get ()));
589
+ KnownOidcProviders .provider (oidcTenantConfig .provider () .get ()));
578
590
} else {
579
591
return oidcTenantConfig ;
580
592
}
0 commit comments