1

I have an html page containing an href link to another page. Clicking this link will open up a new tab that asks for login credentials. I would like to replace the href with a javascript function that will authenticate the link with a hard-coded username-password and then open it in a new tab so that the user doesn't have to enter the credentials (not even once). The requirement here is that the user is not expected to know/remember the credentials for the new link.

<!DOCTYPE html>
<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function Login() {
var link = "https://serverB";
-- Authenticate serverB and save cookie in broswer / save auth info
window.open(link);
-- window.open() should open the link without requiring another login
}
//  End -->
</script>
</head>
<body>
<form name=login>
<input type=button onClick="Login()" name="button" value="Redirect to serverB">
</form>
</body>
</html>
  • What is the authentication procedure on the link? Post,get, What are you using php? – GaAd Jun 27 '17 at 08:09
  • You do understand that view-source or inspect element instantly will reveal the userID and password? Also many browsers no longer allow "http://userid:password@someserver.com" - or perhaps you mean this: https://stackoverflow.com/questions/5507234/how-to-use-basic-auth-with-jquery-and-ajax – mplungjan Jun 27 '17 at 08:09
  • @GaAd I am using Javascript and doing a GET. – anil gopalakrishna Jun 28 '17 at 05:44
  • @mplungjan Yes i understand that it is insecure. I want to do an authentication before redirection to a link. The links are all internal(not on the internet). Window.Open() doesn't seem to have a way of passing auth information. Is there any other method that can open up an authenticated link in a new tab? – anil gopalakrishna Jun 28 '17 at 05:46
  • So when the new window opens there is something like a form that requires values username and password to be submited? I am trying to understand the functionality here. – GaAd Jun 28 '17 at 10:13
  • @GaAd That's correct. The new page has a login form. – anil gopalakrishna Jun 29 '17 at 09:28

0 Answers0