Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(enterprise): fix start interval when using access tokens #2211

Merged
merged 2 commits into from
Jan 19, 2021

Conversation

10ko
Copy link
Member

@10ko 10ko commented Jan 19, 2021

What this PR does / why we need it:
This PR fixes a problem we introduced recently where we would start the auth token refresh interval when using an Access Token.
Additionally, I refactored the logout function, replacing old unused code with the actual implementation that was in EnterpriseApi

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

@10ko 10ko force-pushed the fix-access-token-refresh branch from 162b46e to 0cafefe Compare January 19, 2021 16:41
if (!tokenIsValid) {
await this.refreshToken()
// If the token is an Access Token and it's invalid we return.
if (gardenEnv.GARDEN_AUTH_TOKEN) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this throw? If you're explicitly setting an access token that doesn't work you probably want an error.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly. I wanted to try a more conservative approach since it fails later, but I agree we can throw here.
I'll add it.

if (gardenEnv.GARDEN_AUTH_TOKEN) {
this.log.error({
msg:
"The provided access token is expired or revoked, please create a new one from the Garden Enterprise UI.",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is expired or revoked, > is expired or has been revoked,

@@ -55,13 +57,22 @@ export async function login(enterpriseApi: EnterpriseApi, log: LogEntry): Promis
}

export async function logout(enterpriseApi: EnterpriseApi, log: LogEntry): Promise<void> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function isn't used anywhere.

Copy link
Member Author

@10ko 10ko Jan 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the PR, I left out the LogOutCommand

@@ -207,26 +229,6 @@ export class EnterpriseApi {
return token
}

async logout() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we removing this? Note that the "other" logout function isn't used.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved the logic to be out of the EnterpriseApi class to maintain consistency with the login function

@10ko 10ko force-pushed the fix-access-token-refresh branch from 0cafefe to 352159b Compare January 19, 2021 16:48
@10ko
Copy link
Member Author

10ko commented Jan 19, 2021

Thanks @eysi09, I addressed all your comments.

@10ko 10ko merged commit 3953c5a into master Jan 19, 2021
@10ko 10ko deleted the fix-access-token-refresh branch January 19, 2021 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants