反馈已提交
网络繁忙
Enterprises often have multiple BI platforms or multiple related platforms. Users want to log in to other systems only once. For example, they log in to the BI system at the same time as logging in to the OA system. The user name and password they enter will also be sent to the BI system for authentication, so that they do not need to log in again when accessing the BI system.
In the previous section, Ajax cross domain asynchronous single sign on was introduced. How to realize cross domain single sign on of OA system and BI system through iframe?
In the OA system login interface, BI first embeds the permission verification address in iframe to solve the cross domain problem, and then triggers the form login event in iframe to realize the jump of the login page.
Start two projects with port numbers of 37799 and 8080, and create a new HTML file iframe HTML to the project with port number 37799 and access http://localhost:37799/webroot/iframe.html , enter the user name and password of the 8080 project, and successfully access the 8080 project.
Open a new tab on the successfully logged in browser to access http://localhost:37799/webroot/decision/logout/cross/domain , switch to the 8080 project page that was successfully logged in before, refresh the page, and the user will be kicked out of the login.
1) The two projects prepared in this article are:
Note: the two projects need to have the same user name and password.
Local project, port number 37799
Project deployed to Tomcat with port number of 8080
Tomcat server deployment: Tomcat server deployment
2) Start two projects.
Create a new HTML file named "iframe.html". The code is as follows:
Note: modify the access path or port number in the code according to the actual situation.
<!DOCTYPE html><html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=10" /> <script type="text/javascript"> function doSubmit() { var username = document.getElementById("username").value; //Get the entered user name var password = document.getElementById("password").value; //Get input parameters var scr = document.createElement("iframe"); //Create iframe scr.src = "http://localhost:8080/webroot/decision/login/cross/domain?fine_username=" + encodeURIComponent(username) + "&fine_password=" + encodeURIComponent(password) + "&validity=" + -1 + "&callback=callback"; //将报表验证用户名密码的地址指向此iframe if (scr.attachEvent) { //Determine whether it is an IE browser scr.attachEvent("onload", function(){ //If it is an IE browser, immediately after the page is loaded window.location="http://localhost:8080/webroot/decision"; //Jump directly to data decision system }); } else { scr.onload = function(){ //Other browsers reload the onload event /*Jump to the specified login success page,index.jsp var f = document.getElementById("login"); f.submit(); */ window.location="http://localhost:8080/webroot/decision"; //Jump directly to data decision system }; } document.getElementsByTagName("head")[0].appendChild(scr); //Embed the iframe tag into the head } </script> </head> <body> <p>Please login</p> <form id="login" name="login" method="POST" action="" > <p>user name:<input id="username" type="text" name="username" /></p> <p>password:<input id="password" type="password" name="password"/></p> <input type="button" value="Sign in" onClick="doSubmit()" /> </form> </body> </html>
Code Description:
When the user enters the user name and password and clicks the submit or login button, the function doSubmit() is executed. The function first creates an iframe, then points the authentication address of the BI authentication user name and password to the src of the iframe, and judges the browser used (because each browser registers differently), and then adds the iframe tag to the head tag.
Note: button is used in the user name and password form to trigger doSubmit(). You only need to add doSubmit() to the login page of your OA. In order to simplify the operation, the complete code does not jump to the specified page, and directly jumps to the platform page.
Name the HTML file iframe.html, put it into the %BI_HOME%/webapps/webroot folder, as shown in the following figure:
1) Visit http://localhost:37799/webroot/iframe.html , enter the account number and password of the 8080 project, and successfully access the 8080 project. As shown in the following figure:
Note: in case of inaccessibility, please try to turn off the "click hijacking attack protection" button and the "content sniffing attack protection" button in the security protection in the two projects.
2) Open a new tab on the successfully logged in browser to access http://localhost:37799/webroot/decision/logout/cross/domain, switch to the 8080 project page that was successfully logged in before, refresh the page, and the user will be kicked out of the login. As shown in the following figure:
Problem Description:
Iframe cross domain single sign on fails on IE11 browser, and single sign on on Google browser is normal.
Solution:
1) Since IE11 does not have the attachEvent attribute, you need to add a meta tag to set the default compatibility mode of the browser. Add the following code to the head tag of html:
<meta http-equiv="X-UA-Compatible" content="IE=10" />
The meta tag is used to set the default compatibility mode of the browser to IE10, so that the attachEvent attribute can still be used.
2) In addition, the IE11 browser needs to add the address of the report server to the trusted site, as shown in the following figure:
售前咨询电话
400-811-8890转1
在线技术支持
在线QQ:800049425
热线电话:400-811-8890转2
总裁办24H投诉
热线电话:173-1278-1526
文 档反 馈
鼠标选中内容,快速反馈问题
鼠标选中存在疑惑的内容,即可快速反馈问题,我们将会跟进处理。
不再提示
10s后关闭