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

Auth: Only call rotate token if we have a session expiry cookie #84169

Merged
merged 1 commit into from Mar 11, 2024

Conversation

kalleep
Copy link
Contributor

@kalleep kalleep commented Mar 11, 2024

What is this feature?
When getting a 401 response we always tried to rotate token. This works correctly as long as a user has a sessions cookie. But there are cases when a user don't have one (anonymous and auth proxy). When the server respond with a 401 this is causing a infinite reload loop for that page.

To solve this we only call rotate token if we have a session expiry cookie and in all other cases we call GET /api/login/ping to determine if user is authenticated.

For 10.3.x and below this can be mitigated by disabling the feature toggle. But in 10.4.x the toggle is removed and this is the default behaviour.

Why do we need this feature?
To solve issue with infinite page reload loop for users without a sessions.

Which issue(s) does this PR fix?:

Fixes #

Special notes for your reviewer:

Please check that:

  • It works as expected from a user's perspective.
  • If this is a pre-GA feature, it is behind a feature toggle.
  • The docs are updated, and if this is a notable improvement, it's added to our What's New doc.

@kalleep kalleep added this to the 10.4.x milestone Mar 11, 2024
@kalleep kalleep requested a review from a team March 11, 2024 11:27
@kalleep kalleep requested a review from a team as a code owner March 11, 2024 11:27
@kalleep kalleep requested review from Clarity-89 and ashharrison90 and removed request for a team March 11, 2024 11:27
Copy link
Contributor

This PR must be merged before a backport PR will be created.

@grafana-delivery-bot grafana-delivery-bot bot modified the milestones: 10.4.x, 11.0.x Mar 11, 2024
Copy link
Contributor

This PR must be merged before a backport PR will be created.

1 similar comment
Copy link
Contributor

This PR must be merged before a backport PR will be created.

@kalleep kalleep merged commit 4272483 into main Mar 11, 2024
29 checks passed
@kalleep kalleep deleted the auth/token-rotation-skip branch March 11, 2024 13:10
Copy link
Contributor

The backport to v10.3.x failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new branch
git switch --create backport-84169-to-v10.3.x origin/v10.3.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x 4272483c54a55d807788c163963b70071343eba4

When the conflicts are resolved, stage and commit the changes:

git add . && git cherry-pick --continue

If you have the GitHub CLI installed:

# Push the branch to GitHub:
git push --set-upstream origin backport-84169-to-v10.3.x
# Create the PR body template
PR_BODY=$(gh pr view 84169 --json body --template 'Backport 4272483c54a55d807788c163963b70071343eba4 from #84169{{ "\n\n---\n\n" }}{{ index . "body" }}')
# Create the PR on GitHub
echo "${PR_BODY}" | gh pr create --title "[v10.3.x] Auth: Only call rotate token if we have a session expiry cookie" --body-file - --label "type/bug" --label "area/frontend" --label "add to changelog" --label "backport" --base v10.3.x --milestone 10.3.x --web

Or, if you don't have the GitHub CLI installed (we recommend you install it!):

# Push the branch to GitHub:
git push --set-upstream origin backport-84169-to-v10.3.x

# Create a pull request where the `base` branch is `v10.3.x` and the `compare`/`head` branch is `backport-84169-to-v10.3.x`.

# Remove the local backport branch
git switch main
git branch -D backport-84169-to-v10.3.x

@grafana-delivery-bot grafana-delivery-bot bot added the backport-failed Failed to generate backport PR. Please resolve conflicts and create one manually. label Mar 11, 2024
grafana-delivery-bot bot pushed a commit that referenced this pull request Mar 11, 2024
Only call rotate token if we have a session expiry cookie

(cherry picked from commit 4272483)
kalleep added a commit that referenced this pull request Mar 13, 2024
…okie (#84181)

Auth: Only call rotate token if we have a session expiry cookie (#84169)

Only call rotate token if we have a session expiry cookie

(cherry picked from commit 4272483)

Co-authored-by: Karl Persson <kalle.persson@grafana.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
add to changelog area/frontend backport v10.3.x Mark PR for automatic backport to v10.3.x backport v10.4.x backport-failed Failed to generate backport PR. Please resolve conflicts and create one manually. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants