<#1805 feat: Add token caching for ClientCredentia...
# flyte-github
a
#1805 feat: Add token caching for ClientCredentials + DeviceFlow + Auth0 Functionality Pull request opened by PudgyPigeon TL;DR Adds token caching for ClientCredentials/DeviceFlow and also adds support for Auth0. Type • [x ] Bug Fix • [x ] Feature ☐ Plugin Are all requirements met? • [x ] Code completed ☐ Smoke tested ☐ Unit tests added ☐ Code documentation added ☐ Any pending items have an associated Issue Complete description How did you fix the bug, make the feature etc. Link to any design docs etc One change to note is that this PR adds the ability to manually specify the scopes requested during the FlyteClient authentication process. These scopes (if provided manually), are sourced from the
config.yaml
file and will override the default behaviour for finding scopes. This is in support of Auth0 which manually requires requesting OIDC scopes in the request body - but also the idiosyncrasy wherein Auth0 does not allow custom user APIs to be assigned the OIDC scopes explicitly (This leads to an error during Flytepropeller). Our workaround prevents this behaviour and also keeps the default behaviour intact for other IDPs. The way the
scopes
parameter was parsed in the
token_client
module was incompatible with Auth0. It is also our opinion that it was parsed incorrectly for other IDPs as well. We have changed it to match the PKCE flow's scopes parameter and things are working. Now, the
refresh_token
is able to be retrieved properly. (No refresh token in response in Device/CC flow before. Also refactored the ClientCredentials + DeviceFlow to use a
Credentials
dataclass object and to store and retrieve this object by calling
Keyring
. This enables caching for Auth in both flows. Tested over remote SSH and localhost and can confirm all three flows are working with the suggested changes. Though we have had to make sure that Keyring was present in our environments. Absence of Keyring may lead to errors using ClientCredentials + DeviceFlow. Feedback is welcome. Tracking Issue https://github.com/flyteorg/flyte/issues/ Follow-up issue NA OR https://github.com/flyteorg/flyte/issues/ flyteorg/flytekit GitHub Actions: build-plugins GitHub Actions: build (macos-latest, 3.11) GitHub Actions: build (macos-latest, 3.10) GitHub Actions: build (macos-latest, 3.9) GitHub Actions: build (macos-latest, 3.8) GitHub Actions: build (windows-latest, 3.11) GitHub Actions: build (windows-latest, 3.9) GitHub Actions: build (windows-latest, 3.8) GitHub Actions: build (ubuntu-latest, 3.11) GitHub Actions: build (ubuntu-latest, 3.10) GitHub Actions: build (ubuntu-latest, 3.9) GitHub Actions: build (ubuntu-latest, 3.8) GitHub Actions: lint ✅ 4 other checks have passed 4/17 successful checks