-
Notifications
You must be signed in to change notification settings - Fork 273
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
Conversation
162b46e
to
0cafefe
Compare
if (!tokenIsValid) { | ||
await this.refreshToken() | ||
// If the token is an Access Token and it's invalid we return. | ||
if (gardenEnv.GARDEN_AUTH_TOKEN) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
core/src/enterprise/api.ts
Outdated
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.", |
There was a problem hiding this comment.
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> { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
0cafefe
to
352159b
Compare
Thanks @eysi09, I addressed all your comments. |
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 inEnterpriseApi
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer: