Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

auto login remote site inner in iframe

Tags:

I have an existing remote site which has Authentication to access, now I want to combine this site in my own site using iframe. Is there any solution which can help to auto login remote site when load the iframe?

<iframe src="http://remote.com/list"></iframe>

If want to access http://remote.com/list, login require and only post username/password works. How to auto login when iframe loaded?

Here are some restriction

  • login only works with post method
  • iframe / javascript has cross domain issue
  • no login API provide
  • no other modification can do in remote site
like image 859
linbo Avatar asked Aug 09 '12 07:08

linbo


People also ask

Does SSO work in iframe?

To allow Remedy Single Sign-On to launch applications in iframes and in nested iframes, you must configure Remedy SSO server to allow launching applications from other domains.

How do I use iframe tags?

Definition and UsageThe <iframe> tag specifies an inline frame. An inline frame is used to embed another document within the current HTML document. Tip: Use CSS to style the <iframe> (see example below). Tip: It is a good practice to always include a title attribute for the <iframe> .


2 Answers

Everything's possible. However the solution below is very insecure due to disclosure of access details to the remote page.

<form id="login" target="frame" method="post" action="http://remote.com/login">     <input type="hidden" name="username" value="login" />     <input type="hidden" name="password" value="pass" /> </form>  <iframe id="frame" name="frame"></iframe>  <script type="text/javascript">     // submit the form into iframe for login into remote site     document.getElementById('login').submit();      // once you're logged in, change the source url (if needed)     var iframe = document.getElementById('frame');     iframe.onload = function() {         if (iframe.src != "http://remote.com/list") {             iframe.src = "http://remote.com/list";         }     } </script> 

The values of username and password inputs are readable on the client side.

like image 195
Jakub Hubner Avatar answered Sep 18 '22 15:09

Jakub Hubner


If you own the other site then you can try authentication through some token.

Pass an authorized token to url in the iframe.

like image 24
Subir Kumar Sao Avatar answered Sep 19 '22 15:09

Subir Kumar Sao