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

feat: add auth support via command #129

Merged
merged 10 commits into from
Sep 22, 2024
Merged

Conversation

radulucut
Copy link
Collaborator

@radulucut radulucut commented Sep 7, 2024

Implementation for #108

@radulucut radulucut changed the title feat: add auth support via command (#108) feat: add auth support via command Sep 9, 2024
@radulucut radulucut marked this pull request as ready for review September 9, 2024 14:00
Copy link
Member

@MartinKolarik MartinKolarik left a comment

Choose a reason for hiding this comment

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

I think this part is missing?

when the access token seems valid, but you got a 401 or 403 error from the API, and the refresh token is still valid, try refreshing the tokens
if this fails as well, delete the stored tokens
if this works, print a message for the user like "Access token successfully refreshed. Try repeating the measurement."

globalping/auth.go Outdated Show resolved Hide resolved
cmd/auth.go Show resolved Hide resolved
cmd/auth.go Show resolved Hide resolved
cmd/auth.go Show resolved Hide resolved
@radulucut
Copy link
Collaborator Author

I think this part is missing?

when the access token seems valid, but you got a 401 or 403 error from the API, and the refresh token is still valid, try refreshing the tokens
if this fails as well, delete the stored tokens
if this works, print a message for the user like "Access token successfully refreshed. Try repeating the measurement."

The access token is silently refreshed if there's a refresh token. I didn't add any message because it might broke the live view, but I can add it if you think is worth it?

@MartinKolarik
Copy link
Member

The access token is silently refreshed if there's a refresh token. I didn't add any message because it might broke the live view, but I can add it if you think is worth it?

Is it actually refreshed after the measurement fails with an error? I might have missed it, but I haven't seen that logic in the code. I understand the token is refreshed correctly when it expires, but this is about a case when it stops working before the original expiration date.

@radulucut
Copy link
Collaborator Author

The access token is silently refreshed if there's a refresh token. I didn't add any message because it might broke the live view, but I can add it if you think is worth it?

Is it actually refreshed after the measurement fails with an error? I might have missed it, but I haven't seen that logic in the code. I understand the token is refreshed correctly when it expires, but this is about a case when it stops working before the original expiration date.

yeah, you're right, I've missed that. Thanks

utils/utils.go Outdated Show resolved Hide resolved
@MartinKolarik MartinKolarik merged commit abf3b23 into jsdelivr:master Sep 22, 2024
3 checks passed
@MartinKolarik MartinKolarik linked an issue Sep 22, 2024 that may be closed by this pull request
@radulucut radulucut deleted the auth branch September 22, 2024 21:02
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.

Add auth support via command
2 participants