Skip to content
Snippets Groups Projects
Commit 22e028d1 authored by Armin Felder's avatar Armin Felder
Browse files

moved from popup to iframe

parent 2575519a
No related branches found
No related tags found
No related merge requests found
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
var token = ""; var token = "";
var secret = ""; var secret = "";
var redirectUrl = "";
var client = new Asteroid(host, secure); var client = new Asteroid(host, secure);
var redirectToRC = function () { var redirectToRC = function () {
...@@ -75,6 +77,23 @@ ...@@ -75,6 +77,23 @@
}, 100); }, 100);
}; };
var initOpenIdIframe = function(url){
var iframe = document.getElementById("idpIframe");
iframe.src = url;
var checkIframeState = setInterval(function(){
var src = iframe.contentDocument.location.href;
if(src.startsWith(redirectUrl)){
clearInterval(checkIframeState);
var secret = localStorage.getItem('Meteor.oauth.credentialSecret-'+token);
if(token != "" && secret != "") {
LoginWithOpenId(url, token, secret);
}
}
}, 100);
};
var trySessionRestore = function(){ var trySessionRestore = function(){
var cookieObj = getCookieObj(); var cookieObj = getCookieObj();
if (cookieObj && cookieObj["rc_uid"] && cookieObj["rc_token"]){ if (cookieObj && cookieObj["rc_uid"] && cookieObj["rc_token"]){
...@@ -145,7 +164,7 @@ ...@@ -145,7 +164,7 @@
var generateOIDUrl = function(serverUrl,authorizePath,clientId ){ var generateOIDUrl = function(serverUrl,authorizePath,clientId ){
var hostname = window.location.protocol; var hostname = window.location.protocol;
var redirectUrl = window.location.protocol+"//"+window.location.hostname+"/_oauth/fairlogin"; redirectUrl = window.location.protocol+"//"+window.location.hostname+"/_oauth/fairlogin";
var chars = "abcdefghijklmnopqrstuvwxyz0123456789"; var chars = "abcdefghijklmnopqrstuvwxyz0123456789";
token = ""; token = "";
for(var i=0; i<32; i++){ for(var i=0; i<32; i++){
...@@ -160,6 +179,7 @@ ...@@ -160,6 +179,7 @@
var b64 = btoa(objStr); var b64 = btoa(objStr);
var oidUrl = serverUrl+authorizePath+"?client_id="+clientId+"&redirect_uri=" var oidUrl = serverUrl+authorizePath+"?client_id="+clientId+"&redirect_uri="
+redirectUrl+"&response_type=code&state="+b64+"&scope=openid"; +redirectUrl+"&response_type=code&state="+b64+"&scope=openid";
return oidUrl; return oidUrl;
}; };
...@@ -181,7 +201,8 @@ ...@@ -181,7 +201,8 @@
serverURL = fields["serverURL"]; serverURL = fields["serverURL"];
tokenPath = fields["tokenPath"]; tokenPath = fields["tokenPath"];
var url =generateOIDUrl(serverURL, authorizePath, clientId ); var url =generateOIDUrl(serverURL, authorizePath, clientId );
initOpenIdLogin(url); //initOpenIdLogin(url);
initOpenIdIframe(url);
} }
} }
} }
...@@ -192,7 +213,7 @@ ...@@ -192,7 +213,7 @@
</script> </script>
</head> </head>
<body> <body>
<iframe id="idpIframe" src=""></iframe>
</body> </body>
</html> </html>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment