Skip to content

OAuth2 support for flyte-cli and SDK engine

Compare
Choose a tag to compare
@katrogan katrogan released this 06 Dec 20:47
· 1932 commits to master since this release
OAuth2 support for flyte-cli and SDK engine (#23)

This change adds authentication support for flyte-cli and the pyflyte CLIs.

# New authorization code
Specifically this change introduces an **AuthorizationClient** which implements the [PKCE authorization flow](https://www.oauth.com/oauth2-servers/pkce/authorization-code-exchange/) for untrusted clients. This client handles requesting an initial access token, spinning up a callback server to receive the access token and using that to retrieve an authorization code. The client also handles refreshing expired authorization tokens.

This change also includes a lightweight **DiscoveryClient** for retrieving authorization endpoint metadata defined in the [OAuth 2.0 Authorization Server Metadata](https://tools.ietf.org/id/draft-ietf-oauth-discovery-08.html) draft document.

An authorization client singleton is lazily initialized for use by flyte-cli.

# Pyflyte changes (basic auth)
Requests an authorization token using a username and password.

# Flyte-cli changes (standard auth)
Requests an authorization token using the PKCE flow.

# Raw client changes
Wraps RPC calls to flyteadmin in a retry handler that initiates the appropriate authentication flow defined in the flytekit config in response to `HTTP 401 unauthorized` response codes.