Skip to content

Commit

Permalink
Honor discovery URL for other flows too
Browse files Browse the repository at this point in the history
  • Loading branch information
samikshya-db committed Dec 4, 2024
1 parent eed5737 commit c5a174e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ public OpenIDConnectEndpoints getOidcEndpoints() throws IOException {
return oidcEndpoints;
}
} catch (Exception e) {
LOG.debug(
LOG.warn(
"Failed to fetch OIDC Endpoints using discovery URL: {}. Error: {}. \nDefaulting to fetch OIDC using default endpoint.",
discoveryUrl,
e.getMessage(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class OAuthClient {
public static class Builder {
private String host;
private String clientId;
private String discoveryUrl;
private String redirectUrl;
private List<String> scopes;
private String clientSecret;
Expand All @@ -53,6 +54,11 @@ public Builder withClientId(String clientId) {
return this;
}

public Builder withDiscoveryUrl(String discoveryUrl) {
this.discoveryUrl = discoveryUrl;
return this;
}

public Builder withClientSecret(String clientSecret) {
this.clientSecret = clientSecret;
return this;
Expand Down Expand Up @@ -91,6 +97,7 @@ public OAuthClient(DatabricksConfig config) throws IOException {
.withHttpClient(config.getHttpClient())
.withClientId(config.getClientId())
.withClientSecret(config.getClientSecret())
.withDiscoveryUrl(config.getDiscoveryUrl())
.withHost(config.getHost())
.withRedirectUrl(
config.getOAuthRedirectUrl() != null
Expand All @@ -106,7 +113,7 @@ private OAuthClient(Builder b) throws IOException {
this.host = b.host;
this.hc = b.hc;

DatabricksConfig config = new DatabricksConfig().setHost(b.host).resolve();
DatabricksConfig config = new DatabricksConfig().setHost(b.host).setDiscoveryUrl(b.discoveryUrl).resolve();
OpenIDConnectEndpoints oidc = config.getOidcEndpoints();
if (oidc == null) {
throw new DatabricksException(b.host + " does not support OAuth");
Expand Down

0 comments on commit c5a174e

Please sign in to comment.