How to disable soft login in Hybris?

How to disable remember-me login in SAP Hybris?


Requirement: Every time request timeout, the user should ask for login. There shouldn't be soft login or remember me option.
Hybris OOTB behavior: In the B2B site, by default soft login is enabled. Means, users will be always auto login even session expired.
Changes Required:
  1. Remove default remember me (soft login) behaviour
  2. Remove remember me references


1. Remove default remember me (soft login) behaviour

Find filespring-security-config.xml located in your storefront extension. Look for beandefaultRememberMeServices definition, in which attributealwaysRemember has valuetrue, that needs to be changed to false.
<alias name="defaultRememberMeServices" alias="rememberMeServices"/>
<bean id="defaultRememberMeServices" class="com.mysite.storefront.security.AcceleratorRememberMeServices" >
    <property name="userDetailsService" ref="originalUidUserDetailsService" />
    <property name="key" value="mysitestorefront" />
    <property name="cookieName" value="mysitestorefrontRememberMe" />
    <property name="alwaysRemember" value="false" />
    <property name="userService" ref="userService"/>
    <property name="useSecureCookie" value="true"/>
    <property name="customerFacade" ref="customerFacade"/>
    <property name="checkoutCustomerStrategy" ref="checkoutCustomerStrategy"/>
    <property name="urlEncoderService" ref="urlEncoderService"/>
    <property name="storeSessionFacade" ref="storeSessionFacade"/>
    <property name="commonI18NService" ref="commonI18NService"/>
    <property name="secureTokenService" ref="secureTokenService"/>
</bean>

2. Remove remember me references

Remove or comment out the below-mentioned code from the spring-security-config.xml of your storefront extension.

<security:remember-me key="mysitestorefront" services-ref="rememberMeServices"/>

Remove checkbox having name _spring_security_remember_me, from your login page if it present (say login.tag)
<label><input type="checkbox" name="_spring_security_remember_me" class="checkbox" id="_spring_security_remember_me"  /> Remember Login</label>

Author Image

Ankitkumar Patel

Sr. SAP Hybris consultant, having 15+ years experience in SAP Commerce Cloud (Hybris), SAP Spartacus. Extensive experience in SAP Hybris development, third-party integrations, project architecture and design... Read more

Comments

Popular posts from this blog

Hybris flexible search query examples

How to Install temporary Hybris license?

How to remove or update all data records in Hybris?