Skip to content

Commit

Permalink
for oidc redirect uri check both configured endpoint and auto-generat…
Browse files Browse the repository at this point in the history
…ed value (#2167)

Signed-off-by: Henry Avetisyan <[email protected]>
Co-authored-by: Henry Avetisyan <[email protected]>
  • Loading branch information
havetisyan and havetisyan authored May 9, 2023
1 parent e2eaf34 commit 04f3509
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions servers/zts/src/main/java/com/yahoo/athenz/zts/ZTSImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -2202,8 +2202,8 @@ boolean validateOidcRedirectUri(DomainData domainData, final String clientId, fi
return false;
}
final String serviceEndpoint = service.getProviderEndpoint();
if (!StringUtil.isEmpty(serviceEndpoint)) {
return serviceEndpoint.equalsIgnoreCase(redirectUri);
if (!StringUtil.isEmpty(serviceEndpoint) && serviceEndpoint.equalsIgnoreCase(redirectUri)) {
return true;
}

// make sure we have a redirect uri suffix configured
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13289,10 +13289,11 @@ public void testExtractServiceEndpoint() {

domainData.setServices(services);

// service endpoint exists - both valid and invalid cases
// service endpoint exists - both valid and invalid cases (no redirect suffix)

assertTrue(zts.validateOidcRedirectUri(domainData, "coretech.backend", "https://localhost:4443/endpoint"));
assertFalse(zts.validateOidcRedirectUri(domainData, "coretech.backend", "https://api.coretech.athenz.io"));
assertFalse(zts.validateOidcRedirectUri(domainData, "coretech.backend", "https://backend.coretech.athenz.io"));

// valid service but no redirect uri suffix

Expand All @@ -13302,6 +13303,10 @@ public void testExtractServiceEndpoint() {

zts.redirectUriSuffix = ".athenz.io";

// the service with the endpoint set now should pass with redirect suffix

assertTrue(zts.validateOidcRedirectUri(domainData, "coretech.backend", "https://backend.coretech.athenz.io"));

// invalid client id

assertFalse(zts.validateOidcRedirectUri(domainData, "coretech", "https://api.coretech.athenz.io"));
Expand Down

0 comments on commit 04f3509

Please sign in to comment.