Handle missing connection db records for verified auth0 sessions and improve cache handling#950
Open
roborourke wants to merge 3 commits intoauth0:5.xfrom
Open
Handle missing connection db records for verified auth0 sessions and improve cache handling#950roborourke wants to merge 3 commits intoauth0:5.xfrom
roborourke wants to merge 3 commits intoauth0:5.xfrom
Conversation
I think there are some errors in the caching here that this aims to fix, like putting the expiry in the group parameter. Mainly I'm seeking to fix an edge case where auth0 can "resume" a session but no account record has been created in the db so it keeps logging users out on every page request.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
By submitting a PR to this repository, you agree to the terms within the Auth0 Code of Conduct. Please see the contributing guidelines for how to create and submit a high-quality PR for this repo.
Description
This aims to fix an edge case where auth0 "resumes" a session but no account record has been created in the db so it keeps logging users out on every page request. This can happen when registering a new auth0 account for an existing WP user with a matching email address.
There are some errors in the caching here too that I needed to fix, like putting the expiry in the group parameter.
Flushing the entire cache when deleting a user is unnecessary and can be very damaging to performance on a busy site so I updated that as well, including deleting the transient.
It would be good to look into only using transients, or only
wp_cache_*functions rather than combining them as it's not necessary and adding double the number of requests needed for sites with a separate cache server, which can degrade performance rather than improve it.Testing
This change adds test coverage for new/changed/fixed functionality
Before the fix...
Create a site with an existing WP user, administrator role
Configure and Enable auth0
Login again with the user and see that no
wp_auth0_accountsrecord is createdBrowsing to the front end results in being logged out, after several redirects including to auth0's
resumeendpointWith the fix...
On the next page request to the front end, see that the redirects stop, and authentication is preserved, and the
wp_auth0_accountsrecord is createdChecklist