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: avoid redirect loops when axios calls an unauthorized API #6450

Merged
merged 4 commits into from
Dec 13, 2024

Conversation

elevatebart
Copy link
Contributor

when axios calls an API that it is not supposed to have access to, it's immediately supposing that the JWT is expired.

It requests a refresh of the token and retries the request, which in its turn returns 401 unauthorized.

And request a new token refresh.

This loop goes on until browser crashes.

@elevatebart elevatebart added the kind/do-not-merge Don't merge label Dec 13, 2024
@elevatebart
Copy link
Contributor Author

elevatebart commented Dec 13, 2024

I still have not been able to test it out.

[EDIT] tested and approved

Copy link
Member

@MilosPaunovic MilosPaunovic left a comment

Choose a reason for hiding this comment

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

I've tested it by inviting new user with email only (no groups or access added), then accepted invite in different (private) window and it logged me in properly as user with no permission (which is expected) and showed me Blueprints, Plugins and Setttings pages in the left menu, which is also expected.

When I changed the URL manually to ui/dashboard it redirected me to 403 page, so also expected.

@elevatebart elevatebart merged commit ed264a5 into develop Dec 13, 2024
2 checks passed
@elevatebart elevatebart deleted the fix/redirect-loop branch December 13, 2024 11:33
elevatebart added a commit that referenced this pull request Dec 13, 2024
* fix: avoid redirect loops when axios calls an unauthorized API

* use the proper structure for axios

* protect against empty request data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants