How to pass authentication details to application inside iframe?

Viewed 15477

I've a web page and want to show Jenkins' webpage in it hence used iframe like -

<html>
<head>
    <title>Dashboard</title>
</head>
<body>
    <iframe src="http://xxx.xxx.xx.xx:8080/view/Nightly%20Builds%20/" width="100%" height="100%"></iframe>
</body>
</html>

But http://xxx.xxx.xx.xx:8080/view/Nightly%20Builds%20/ opens with login page and hence content could not be shown directly. Actually I want to show content of the page without login.

Is there any way we can pass authentication details/token to website inside frame?

1 Answers

I think you need to handle the page.

  1. I assume you have javascript function for handling the username and password or authToken validation

    function authTokenValidate(token) { api for validating the token and then redirection to http://xxx.xxx.xx.xx:8080/view/Nightly%20Builds%20/ }

    or Assume you have http://xxx.xxx.xx.xx:8080/view/Nightly%20Builds%20/ page which validate the authToken and let you stay on the page or redirect you to login.

  2. Pass the authToken in the url as query params in the Iframe http://xxx.xxx.xx.xx:8080/view/Nightly%20Builds%20/?auth=AUTH_TOKEN

  1. So When page load http://xxx.xxx.xx.xx:8080/view/Nightly%20Builds%20/ get auth query params from url and call the function that validates the auth token if valid then let user stay on the page else redirect to the login page.
Related