Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass authentication details to application inside iframe?

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?

like image 893
Alpha Avatar asked Mar 13 '20 05:03

Alpha


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.

Can iframe set cookies?

In this guide, you can learn how to set cookies from a site embedded into an iframe using postMessage handlers. Our app is written in React so your use case may differ syntactically, but the idea is the same. First up, let's assume you have an existing and working Cookie popup ready.

What is iframe token?

Iframe Tokenization allows applications to receive authorization to send money to any account that they (the applications) have set up for the users. We can accomplish this by using app-level preapprovals instead of account-level preapprovals.

How do I share an iframe session?

you can use window. postMessage to communicate with an Iframe. in your case Iframe should listen for your message and responds with a copy of session storage.


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.
like image 156
sourav satyam Avatar answered Sep 20 '22 06:09

sourav satyam