Can I authenticate an iFrame page from the parent page?

I have a simple HTML page that rotates through several status pages that I display on several televisions around the campus. I regularly update the page and links. Many times, pages require authentication. It is a pain for the remote terminal to provide credentials. Some of them are HTTP authentication, and some are <form> based authentication baked on the site. Many times I can get around <form> authentication using HTML and JavaScript that host the correct credentials.

  • Is there a better way to get around <form> authentication from the main page? (Below)

  • Is there a way to bypass server / HTTP authentication from the main page without having to manually authenticate the mapping forever?

By <form> authentication, do I mean that the <form> action generates a session cookie?
(mikerobi, thanks for the comment)

Here is the code for the main page

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title> Important Stuff </title> <script src="/scripts/jquery.js" type="text/javascript"></script> <style type="text/css"> html, body, iframe { margin:0; height:100%; } iframe { display:block; width:100%; border:none; } </style> <script type="text/javascript"> var link = new Array(); link[0] = "http://mycompany.intranet/"; link[1] = "http://mycompany.intranet/weather.htm"; link[2] = "http://mycompany.intranet/systemstatus/"; var linkIndex = 0; setInterval("doSomething()", 10000); function doSomething() { if (linkIndex >= link.length) { // reload in case the page has been updated window.location.reload(); } $("#frame").attr("src", link[linkIndex]); linkIndex++; } </script> </head> <body> <iframe id="frame" src="http://mycompany.intranet/"></iframe> </body> </html> 
+4
source share
1 answer
  • I don’t see your code that sends POST-based login credentials, but if you use JavaScript to automatically submit the form (using its .submit() method), this is probably the best way. Keep in mind that the target attribute is HTML -forms allows you to send the form to another window (or in your case iframe) - just specify the attribute name="xyz" for the iframe and use target="xyz" for the form. The form will be placed on the main page and can be hidden using CSS display: none .

  • You can enter the HTTP Basic Auth username and password in the URL, for example: http://username: password@www.example.com /path . Please note that current web browsers may not allow this in their default configurations as protection against a specific phishing technology, and you may need to change the configuration by editing the Windows registry or in other places where the web browser settings are stored.

+8
source

All Articles