Skip to content

[JENKINS-60200] Clear user team and organization caches on fresh OAuth logins #171

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

Merged

Conversation

carsongee
Copy link
Contributor

@carsongee carsongee commented Mar 31, 2022

Per: https://issues.jenkins.io/browse/JENKINS-60200

Sometimes the 1-hour cache of teams and organizations can cause issues. In particular, it causes problems when you have SSO turned on for an organization and the person logging in needs to remember to authorize SSO for a given organization and forgets.

The user story is this:
I log into a Jenkins with team-level permissions in my SSO enabled organization. I see this screen:
image

and I forget to click the Authorize button. I then get permission denied. I then click logout to try and fix that, but when I come back in after authorizing my organization; I still get permission denied because of the cache.

This PR invalidate the cache on fresh logins. This both solves the reported issue, and allows a user to have an active way to refresh their personal cache of teams and organizations by logging out and logging in while leaving caching in place for token flows and session accesses for performance and to minimize GitHub API calls.

Notes: I didn't see a logout hook in the Security Realm or I'd prefer to clear the caches there instead of during the fresh OAuth flow. If someone with more expertise knows how to hook there, I'm happy to move the user cache clearing to that hook.

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

@carsongee carsongee force-pushed the carsongee/invalidate_cache_on_failure branch from fd37155 to 836ca2f Compare March 31, 2022 23:05
@sun-mir
Copy link

sun-mir commented Apr 8, 2022

@samrocketman, @basil
Please, review 🙏

@basil basil requested a review from samrocketman April 8, 2022 14:55
Copy link
Member

@basil basil left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

@basil basil merged commit 0c67386 into jenkinsci:master Apr 25, 2022
@basil
Copy link
Member

basil commented Apr 28, 2022

Released in 0.38.

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.

4 participants