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
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.
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> .
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.
If you own the other site then you can try authentication through some token.
Pass an authorized token to url in the iframe.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With