简体   繁体   English

Javascript-在新标签页中打开一个第三方网页并登录

[英]Javascript - Open a 3rd party web page in new tab and login

In my web application, I want to open a 3rd party web server page in a new tab. 在我的Web应用程序中,我想在新选项卡中打开一个第三方Web服务器页面。 I achieved this by using below source. 我通过使用下面的源实现了这一点。

            var a = document.createElement("a");
            a.target = "_blank";
            a.href = 'http://<ipAddress:port>/#/signin';
            a.click();

Now I want to log the user to this 3rd party web by providing username and password. 现在,我想通过提供用户名和密码将用户登录到该第三方网络。 Single sign on concept is not possible here as the 3rd party web got different authentication and token strategy. 单点登录概念在这里是不可能的,因为第三方网络具有不同的身份验证和令牌策略。 So outcome of this is to log a user into a 3rd party web server without letting user to enter login credentials to the application. 因此,这样做的结果是使用户登录到第三方Web服务器,而无需允许用户输入应用程序的登录凭据。

Appreciate any help on this, thank you. 感谢任何帮助,谢谢。

There is no way to achieve what you want to do using javascript, unless the 3rd party lets you access some kind of API to log on to their system. 除非第三方允许您访问某种API来登录其系统,否则无法使用javascript实现您想做的事情。

You cannot inject JavaScript code into a 3rd party site and that's a crucial security feature. 您无法将JavaScript代码注入第三方网站,这是至关重要的安全功能。 As soon as you redirect to the 3rd party site, your JavaScript code will just be terminated by the browser no matter what you try. 只要您重定向到第3方网站,无论您尝试什么,浏览器都会终止您的JavaScript代码。

So either let your users log in manually, or get the 3rd party to cooperate with you in implementing some kind of single-sign-on mechanism. 因此,要么让您的用户手动登录,要么让第三者与您合作实施某种单点登录机制。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM