Skip to content

Commit

Permalink
Merge pull request #32825 from sberyozkin/google_principal_name
Browse files Browse the repository at this point in the history
Set correct OIDC Google principal claim
  • Loading branch information
geoand committed Apr 24, 2023
2 parents a26e071 + 16a4f91 commit fad7114
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,9 @@ static OidcTenantConfig mergeTenantConfig(OidcTenantConfig tenant, OidcTenantCon
if (tenant.token.issuer.isEmpty()) {
tenant.token.issuer = provider.token.issuer;
}
if (tenant.token.principalClaim.isEmpty()) {
tenant.token.principalClaim = provider.token.principalClaim;
}

return tenant;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ private static OidcTenantConfig google() {
ret.setAuthServerUrl("https://accounts.google.com");
ret.setApplicationType(OidcTenantConfig.ApplicationType.WEB_APP);
ret.getAuthentication().setScopes(List.of("openid", "email", "profile"));
ret.getToken().setPrincipalClaim("name");
return ret;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ public void testAcceptGoogleProperties() throws Exception {
assertEquals(OidcUtils.DEFAULT_TENANT_ID, config.getTenantId().get());
assertEquals(ApplicationType.WEB_APP, config.getApplicationType().get());
assertEquals("https://accounts.google.com", config.getAuthServerUrl().get());
assertEquals("name", config.getToken().getPrincipalClaim().get());
assertEquals(List.of("openid", "email", "profile"), config.authentication.scopes.get());
}

Expand All @@ -206,12 +207,14 @@ public void testOverrideGoogleProperties() throws Exception {
tenant.setApplicationType(ApplicationType.HYBRID);
tenant.setAuthServerUrl("http://localhost/wiremock");
tenant.authentication.setScopes(List.of("write"));
tenant.token.setPrincipalClaim("firstname");

OidcTenantConfig config = OidcUtils.mergeTenantConfig(tenant, KnownOidcProviders.provider(Provider.GOOGLE));

assertEquals(OidcUtils.DEFAULT_TENANT_ID, config.getTenantId().get());
assertEquals(ApplicationType.HYBRID, config.getApplicationType().get());
assertEquals("http://localhost/wiremock", config.getAuthServerUrl().get());
assertEquals("firstname", config.getToken().getPrincipalClaim().get());
assertEquals(List.of("write"), config.authentication.scopes.get());
}

Expand Down

0 comments on commit fad7114

Please sign in to comment.