apache / cordova-ios

Apache Cordova iOS
https://cordova.apache.org/
Apache License 2.0
2.15k stars 987 forks source link

After SSO login using InAppBrowser plugin, it doesnot persist cookies while returning to app so unable to reload ios app #1110

Open priyankabakkar opened 3 years ago

priyankabakkar commented 3 years ago

Bug Report

Problem

We have hybrid app developed using cordova. Our app is “SwiftEnterprise” available on apple store. We have functionality of SSO login which we are achieving using InAppBrowser plugin. Earlier it was working fine but from Aug 2020 it stopped working for ios.

We are able to login to SSO url, using InAppBrowser plugin but after login we were redirecting to our main app. Issue is, now we are not able to reload our app as jsession cookies are missing. Application not able to load. I guess it is cookies issue, I tried setting manual cookies as well but nothing works out.

What is expected to happen?

After successful SSO login we redirect back to main application by closing inappbrowser. Here we expect to get jsession Id so that our session timeout will not happen and app can able to reload

What does actually happen?

Currently on login we are getting session timeout because of missing cookies

Information

Using InAppBrowser plugin's target "_blank" to load sso url and then after successful login we redirect it to our own app

Command or Code

/* This api for SSO/Netscalar login */
MobileApp.Directlogin = function(a_event) {
    var w_appData = JSON.parse(localStorage.getItem('appData') ? localStorage.getItem('appData') : '{}');
    var w_url= w_appData.appUrl;
    var w_target = '_blank';
    var w_options = 'location=yes,clearsessioncache=no,clearcache=no,closebuttoncaption=Close,closebuttoncolor=red,hideurlbar=yes';
    var w_authPage = cordova.InAppBrowser.open(w_url, w_target, w_options);

    w_authPage.addEventListener("loadstop", function () {
        w_authPage.executeScript (
            { code: "document.body.innerText" },
            function( values ) {

                if (values[0].indexOf("cobrandPath") > -1) {
                    var w_loginResponse = JSON.parse(values[0]);

                    if (w_loginResponse.loginStatus) {
                        w_authPage.close();
                        var w_LandingURL = 'maxema/index_mobile.html?';

                        for (var w_dataVal in w_loginResponse) {
                            if (w_dataVal != 'loginStatus') {
                                w_LandingURL += w_dataVal + '=' + w_loginResponse[w_dataVal] + '&';
                            }
                        }
                        w_LandingURL = w_LandingURL.substr(0, w_LandingURL.length - 1);
                        window.location = w_LandingURL;
                    }
                }
            }
        );

   });
  w_authPage.addEventListener("exit", function () {
     MobileApp.changeServer();
 })
};

Environment, Platform, Device

Our app is hybrid app and we are facing this issue on IOS platform since aug 2020

Version information

cordova version -10.0.0 cordova Installed platforms: android 7.0.0 ios 6.2.0 InAppBrowser - cordova-plugin-inappbrowser 5.0.0 Xcode - Version 12.4 (12D4e)

Checklist

timbru31 commented 3 years ago

Thanks a lot for your issue, however the issue template exists for a reason. 😊
It helps us to debug the issue further and to provide a solution much faster. With important information missing, we unfortunately can't help you.

Therefore, please edit this issue accordingly or close and create a new one and make sure to provide all the required information.

priyankabakkar commented 3 years ago

Yes I have added remaining details as well.. please go throught them

oVerde commented 2 years ago

Having the same issue, has anything being done in this case?