【问题标题】:SAML Authentication - Cordova Hybrid Mobile application using in app browserSAML 身份验证 - 在应用浏览器中使用的 Cordova 混合移动应用程序
【发布时间】:2021-10-25 17:11:03
【问题描述】:

我们正在尝试将 SAML 身份验证集成到移动应用程序中(HybridCordova+angular JS)

我尝试了以下方法, 方法 : 第 1 步:移动应用程序打开 InAppBrowser -> 加载 SP url -> 自动 SP URL 重定向到 IDP(any)。显示登录页面。(window.open("url")) 第 2 步:在 IDP 中登录成功后,Inappbrowser 应关闭并返回移动应用程序。

为了实现第 2 步,我尝试使用“LoadStart”、“LoadStop”侦听器。但它会在登录成功之前关闭浏览器。

有什么想法吗?如何做到这一点?

$scope.opensaml = function(){
        appBrowser =  window.open("https://example.com/login”, '_blank', 'location=no,closebuttoncaption=Back to App');
        appBrowser.addEventListener('loadstart', function (event) {
            console.log("Load Start",event.url)
        });
        appBrowser.addEventListener('loadstop', function (event) {
           console.log("Load Stop",event.url);
           appBrowser.close();
        });
        appBrowser.addEventListener('loaderror', function (event) {
            console.log("Load Error",event.url)

        });
    }

【问题讨论】:

    标签: cordova cordova-plugins saml saml-2.0 hybrid-mobile-app


    【解决方案1】:

    loadstop:当 InAppBrowser 完成 URL 加载时触发事件。

    您将在 InAppBrowser 加载完页面后立即关闭它。 你应该改用

    message:当 InAppBrowser 收到从 InAppBrowser Webview 中加载的页面发布的消息时触发事件。

    这当然取决于您可以在登录页面上触发消息事件。

    【讨论】:

    • 消息事件未在移动应用程序(iOS、Android 和 Windows)中触发。我们正在使用cordova-plugin-inappbrowser - 4.1.0 版本 "appBrowser.addEventListener('message', function (event) { console.log("LOAD message",event.url) alert("LOAD message"); } );"
    • 你是从窗户开火吗?
    • 嗨,Eric,它适用于 android 和 iOS。但它不会在 windows 平台上触发。 Windows的任何替代方法?同样要在 iOS 和 Android 中触发此事件,我们需要运行一个脚本。(postMessage)
    • 好吧,也许至少支持我的答案,或者更好的是,验证它并为 Windows 方面创建一个新问题。
    猜你喜欢
    • 1970-01-01
    • 2014-09-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-23
    • 2014-04-05
    • 2022-10-07
    • 2015-09-17
    相关资源
    最近更新 更多