-
-
Notifications
You must be signed in to change notification settings - Fork 821
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
(dev/core#4462) Afform - Fixes for page-token handling #31357
Conversation
I'm not entirely certain why we haven't noticed a problem with REST calls. Maybe because most people don't care. Or maybe because REST calls use the 'print+exit' workflow (which might bypass this auto-save mechanism).
…licy The code-style of this event (`checkPolicy()` and `CheckPolicyEvent`) matches it closest sibling (`checkCredential()` and `CheckCredentialEvent`).
…ity. When authenticating to Civi, you can set the active principal as "Contact" and/or "User". If you set the user, then the web UI of the CMS is liable to render lots of widgets and nav-items that are appropriate to logged-in users (like "My Account" or "Logout"). Fixing this requires site-builder to take extra steps in their CMS. OTOH, if you don't set the user, then -- in some configurations/use-cases/add-ons -- you could find some events/listeners don't run as expected. This commi makes the default policy to be to -not- set the CMS user (since that's more likely to work out-of-the-box and matches the approach of older Profile/Checksum pattern). But you really need to switch, there is a way - tweak the token. * If the auth-token has a signed claim `userMode=>ignore', then we'll ignore CMS user. * If the auth-token has a signed claim `userMode=>optional', then we'll load CMS user (if available). * If the auth-token doesn't explicitly say, then we use a default (`ignore`).
🤖 Thank you for contributing to CiviCRM! ❤️ We will need to test and review this PR. 👷 Introduction for new contributors...
Quick links for reviewers...
|
This was discussed on call, and it sounded like we could merge. Would like to get this out of the way so we can work on other subparts of 4462. I'm just gonna throw some more aggressive test-suites at it to make sure they aren't regressive. (Here's an example baseline for 5.79-rc.) |
Should that be "Contact-only" ? |
Doh! Thanks, fixed. |
The new tests are revealing a couple failures on other environments. Investigating... |
4937b0f
to
5110f94
Compare
Woot. Compared to baseline test results, the PR fixes several pre-existing failures. |
Overview
This is a follow-up to #30585 (5.79.alpha) to address some of remaining issues (for 5.79.beta). It is part of https://lab.civicrm.org/dev/core/-/issues/4462. There is still more to do for 5.79 after this. (But I just wanted to keep the patchset from getting too big in one PR.)
ping @ufundo @eileenmcnaughton @aydun
Steps to Reproduce
User
account.Before (circa 5.79.alpha)
The general idea is that the baseline HTML page is shown anonymously -- and then any AJAX subrequests will be authenticated (setting the active Civi
Contact
and active CMSUser
based on the token).However, this runs into some snags:
That defeats the whole point of 30585. The goal is to have a limited-use token that does not create a session.
After
This is an intermediate step/improvement.
The general idea is that you show the baseline HTML page (and its AJAX requests) as the target
Contact
and/orUser
.Addressing those snags:
Contact
and/orUser
.Contact
and/orUser
.Technical Details
Recall the basic mechanism of the page-level auth-token. You can take any afform and generate a signed token to view that one page.
For email hyperlinks (in the current work), message-tokens are used to generate these kinds of links. The policy is to set the active
Contact
but leave the anonymousUser
.For new/bespoke integrations (eg remote sites which embed IFRAMEs with auth-token links), it also defaults to "Contact-only". But:
If you enable "User" accounts for this case, it should work fine. (Navbars are already suppressed -- so no conflict there.
The integrator can decide whether to enable User account integration. They do this by putting a signed claim in the
XXXXXXXX
token:userMode=>ignore
to disable user-loading.userMode=>optional
oruserMode=>require
to enable user-loading.