2
  • We are using the "Social Login" Component on a custom Experience Builder Page (EBP);
  • With a very standard SSO setup;
  • The tick box for the specific SSO is ticked in the Community(Site) workspace;
  • The SSO login button is there and mostly works (it does authenticate the user);
  • Custom Username and Password (incl controller apex) is available to our external salesforce identity users (community);
  • We append a StartUrl parameter to the login page (EBP), and the value is the URLencode link to the page where they selected login;
  • e.g. https://our.domain.com/community/s/login/?startURL=%2Fcommunity%2Fs%2Fmydeeplink%3Ft%3D1618915055217

With custom UN&PW login: After Authentication Success the startUrl successfully redirects the user to the deeplink without a problem. (deeplink is where they started the login process)

Problem: With SSO login: After Authentication Success the user is redirected to the Community Home page, and not the the deep link they were on, this is not a normal/expected behaviour in anyones world.

How do we use settings or URL parameters to ensure the user redirects to the deeplink we provide (the page they are on)?

community/login?so=00Dourorgid is the first redirect link that the SSO Login flow redirects to, following that the user is redirected to a much more complicated link that uses Network references, it only renders very briefly and then the user is redirected to the Community Home Page.

UPDATE (nearly there, but still looking for help) We have noted that the standard feature I have mentioned (deep link redirect) does work on another community and so the issue relates to something we have configured incorrectly in the SSO setup. We are still investigating, it takes a while when we do not have access to the IDP. I have a suspicion that we need separate IDP Auth setups per community not 1 to cover them all. potentially the security model is preventing the redirect due to incorrect domain referencing, and so the default is home.

7
  • Does this may help? help.salesforce.com/… Commented Apr 20, 2021 at 11:18
  • not really, not sure how it is implemented for a community, with a social login. referring to a SSO url is not really relevant with the social login button as standard on the page. That help page is very unclear what problem it is solving. Commented Apr 20, 2021 at 12:03
  • By "the user is redirected to the Community Home page", you mean after successful negotiation for authentication in the login process (e.g. after "logging in" with Facebook or Google etc.)?
    – Phil W
    Commented Apr 20, 2021 at 12:25
  • Yes, That is correct. Question Updated, Thank you. Commented Apr 21, 2021 at 20:17
  • You could place a wee redirect lwc app on the homepage - it could just check from the presence of the deeplink param and if it's there, parse it and redirect. A bit ugly, but SSO rewrites your URL after login to a static value, as far as I know. Commented Apr 22, 2021 at 2:35

1 Answer 1

0

OK, so finally Salesforce came back and said. their Single Sign On Social button (OOTB), has a bug.

That said our code was the cause for us. we already had this working using JS in an Aura component. and so when it stopped working in 1 community (or looked like it never worked - we were unsure), we assume it was because of the OOTB feature was not receiving the StartUrl, we were partially right.

Salesforce sid it is broken and gave us a work around, well we already had that wrok around in place, problem was we had the work around in place twice for the same community and the JS was obviously conflicting with itself, not sure how it was conflicting but I will publish the code here. Maybe Social button does not deeplick redirect OOTB and our Aura hack is required. Someone might find this useful. I cannot publish eveything here but some may find this helpful.

This is the hack provided by salesforce:

Use LWC (we already had used Aura): We need to make sure the "startURL" is correctly propagated in the auth LWC navigation flows, Use window.location in the custom login form File: loginFormController.js

This code from SF is not tested...

setStartUrl: function (component, event, helpler) {
    var qs = window.location.search.substring(1); // remove leading ?
    var startUrl = null;
    qs.split("&").some(x => {
        if(x.indexOf("startURL")==0) {
            return startUrl = x.split("=")[1];
        } 
     })
if(startUrl){
    component.set("v.startUrl", startUrl); } 
},

Our specifc issue was purely bad JS most likely cause by this same solution added to the custom login page twice. the moment I removed the second Aura Component from the page deeplinking worked

Here is some of our code different approach to above but it works now, which is similar to the above, someone better with JS maybe able to improve either of these...

({
initialize: function(component, event, helper) {
    var urlTemp = window.location.search;
    var params = urlTemp.split('=');
    component.set("v.startUrl",params[1]); //specific to the number of params so not great
    window.console.log('url:-'+window.location.search);
    window.console.log('urlParams:-'+params);         
},

Here is the top of the Aura Component, this component is added to the Experience builder custom page which has the social login button on it.

<aura:component controller="controllerx" implements="forceCommunity:availableForAllPageTypes,lightning:isUrlAddressable" access="global">
    <aura:attribute name="startUrl" type="String" required="false" description="The url you go to after a successful login"/>
    ...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .