Description
Description
I customized the routes for login flow because I have a SAML SSO extension,
I'm experiencing issues the first time I try to log the user in using the SSO flow. Customer data is not loaded.
Preconditions
- Magento 2.3.4 or 2.3.5
- Custom Login controller
My login controller is similar than the PostLogin code
$customerSession->setCustomerDataAsLoggedIn($customer);
if ($this->getCookieManager()->getCookie('mage-cache-sessid')) {
$metadata = $this->getCookieMetadataFactory()->createCookieMetadata();
$metadata->setPath('/');
$this->getCookieManager()->deleteCookie('mage-cache-sessid', $metadata);
}
$resultRedirect = $this->resultRedirectFactory->create();
return $resultRedirect->setUrl($targetURL);
The extension also forces sections to be invalidated after my custom login, by adding a etc/frontend/sections.xml as documented on page-caching
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Customer:etc/sections.xsd">
<action name="sso/saml2/acs">
<section name="*"/>
</action>
</config>
Steps to reproduce
I implemented this simple custom login controller that will allow reproduce the issue:
https://github.com/pitbulk/magento-custom-login
If in a private browser I log in, the call to retrieve sections info does not contain the customer section.
http://example.com/customer/section/load/?sections=recently_viewed_product%2Crecently_compared_product
%2Cpersistent&force_new_section_timestamp=false&_=1590761846169
If I later log in using the normal login process and then logout and try to log again using the SSO module, the customer data is properly retrieved.
If I analyze the call done to retrieve the customer-data, it contains the customer section:
http://example.com/customer/section/load/?sections=recently_viewed_product%2Crecently_compared_product
%2Cpersistent%2Ccustomer%2Ccompare-products%2Clast-ordered-items
%2Ccart%2Cdirectory-data%2Ccaptcha%2Cinstant-purchase%2Creview%2Cwishlist%2Cproduct_data_storage
%2Cpaypal-billing-agreement&force_new_section_timestamp=false&_=1590761971410
It seems that the normal login flow set something the first time the user tries to log that is not set by my extension.
The issue I experience is similar than the one described at:
#21548
The issue exists on Magento 2.3.4, 2.3.4-p2 and 2.3.5-p1
Expected result
customer section listed on section_data_ids.
Customer data available.
Actual result
After enabling a private browser, login and logout using the SAML SSO flow, my sessions looks like:
- Cookies:
mage-cache-sessid true
mage-cache-storage %7B%7D
mage-cache-storage-section-invalidation %7B%7D
private_content_version b1051bef9438849ebe3f156423360282
store default
section_data_ids %7B%22recently_viewed_product%22%3A1590766823%2C%22recently_compared_product%22%3A1590766823%2C%22persistent%22%3A1590766823%7D
- Session Storage:
mage-cache-storage {}
mage-cache-storage-section-invalidation {}
- Local Storage:
mage-cache-timeout "2020-05-29T16:37:08.438Z"
mage-cache-storage-section-invalidation {}
mage-cache-storage {"recently_viewed_product":{"count":0,"items":[],
"data_id":1590766823},"recently_compared_product":
{"count":0,"items":[],"data_id":1590766823},
"persistent":{"data_id":1590766823}}
After enabling a private browser, login and logout using the normal flow, that allows me later to login with no issue via SAML, the sessions look like:
- Cookies:
mage-cache-sessid true
mage-cache-storage %7B%7D
mage-cache-storage-section-invalidation %7B%7D
private_content_version 4366e273973e6fe629402ced87a74171
store default
section_data_ids %7B%22customer%22%3A1590767746%2C%22compare-products%22%3A1590767746%2C%22last-ordered-items%22%3A1590767746%2C%22cart%22%3A1590767746%2C%22directory-data%22%3A1590767746%2C%22captcha%22%3A1590767746%2C%22instant-purchase%22%3A1590767746%2C%22persistent%22%3A1590767746%2C%22review%22%3A1590767746%2C%22wishlist%22%3A1590767746%2C%22recently_viewed_product%22%3A1590767746%2C%22recently_compared_product%22%3A1590767746%2C%22product_data_storage%22%3A1590767746%2C%22paypal-billing-agreement%22%3A1590767746%7D
- Session Storage:
mage-cache-storage {}
mage-cache-storage-section-invalidation {}
- Local Storage:
mage-cache-timeout "2020-05-29T16:54:53.287Z"
mage-cache-storage-section-invalidation {}
mage-cache-storage {"customer":{"data_id":1590767746},"compare-products":{"count":0,"countCaption":"0 items", ............ "persistent":{"data_id":1590767746},"review":{"nickname":"","title":"","detail":"","data_id":1590767746},"wishlist":{"counter":null,"items":[],"data_id":1590767746},"recently_viewed_product":{"count":0,"items":[],"data_id":1590767746},"recently_compared_product":{"count":0,"items":[],"data_id":1590767746},"product_data_storage":{"data_id":1590767746},"paypal-billing-agreement":{"data_id":1590767746}}
I removed the mage-cache-storage and tried to login with SAML, and it worked, so it seems that
all that is required is to include the so it seems that once customer section customer on section_data_ids. I executed again the SAML SSO process and added the customer string manually inside the section_data_ids, so logged in, logged out, edited the Cookie and the process worked.
What may I do to include "customer" inside the section_data_ids?
Metadata
Metadata
Assignees
Labels
Type
Projects
Status