Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fix] Decouple OAuth functionality from
Config
(#784)
## Changes ### OAuth Refactoring Currently, OAuthClient uses Config internally to resolve the OIDC endpoints by passing the client ID and host to an internal Config instance and calling its `oidc_endpoints` method. This has a few drawbacks: 1. There is nearly a cyclical dependency: `Config` depends on methods in `oauth.py`, and `OAuthClient` depends on `Config`. This currently doesn't break because the `Config` import is done at runtime in the `OAuthClient` constructor. 2. Databricks supports both in-house OAuth and Azure Entra ID OAuth. Currently, the choice between these options depends on whether a user specifies the azure_client_id or client_id parameter in the Config. Because Config is used within OAuthClient, this means that OAuthClient needs to expose a parameter to configure either client_id or azure_client_id. Rather than having these classes deeply coupled to one another, we can allow users to fetch the OIDC endpoints for a given account/workspace as a top-level functionality and provide this to `OAuthClient`. This breaks the cyclic dependency and doesn't require `OAuthClient` to expose any unnecessary parameters. Further, I've also tried to remove the coupling of the other classes in `oauth.py` to `OAuthClient`. Currently, `OAuthClient` serves both as the mechanism to initialize OAuth and as a kind of configuration object, capturing OAuth endpoint URLs, client ID/secret, redirect URL, and scopes. Now, the parameters for each of these classes are explicit, removing all unnecessarily coupling between them. One nice advantage is that the Consent can be serialized/deserialized without any reference to the `OAuthClient` anymore. There is definitely more work to be done to simplify and clean up the OAuth implementation, but this should at least unblock users who need to use Azure Entra ID U2M OAuth in the SDK. ## Tests The new OIDC endpoint methods are tested, and those tests also verify that those endpoints are retried in case of rate limiting. I ran the flask app example against an AWS workspace, and I ran the external-browser demo example against AWS, Azure and GCP workspaces with the default client ID and with a newly created OAuth app with and without credentials. - [ ] `make test` run locally - [ ] `make fmt` applied - [ ] relevant integration tests applied
- Loading branch information