cancel
Showing results for 
Search instead for 
Did you mean: 

JWT Token with Iframe

ramansingh89
10 - ETL
10 - ETL

Hi Team

I am trying to find out a doc that can explain how JWT token works with iframe?

If there is any code snippet to generate JWT token exists somewhere, please let me know as well

7 REPLIES 7

rudyfranco
8 - Cloud Apps
8 - Cloud Apps

I haven't come across any documentation specific to what you're asking for here.  But it would have been nice when I went this route, so there's definitely a need for it. 

When I embedded a Sisense dashboard into an iFrame, I first set the iFrames SRC to the instance URL with the JWT token as part of the query string: i.e. https://path.toSisenseInstance.com/jwt?jwt=YOUR_TOKEN_HERE

In the iFrames OnLoad handler, I navigate the frame to the dashboard to be displayed.  So essentially what happens is you hit the page, the iFrame makes its first call to the server with your token which authenticates it.  Once that page loads, OnLoad is fired, which loads up the dashboard in the iFrame now that you're authenticated.

There's lots of examples for creating a JWT token online but here's a quick one.  You'd just take this string value and place it in the query string that you first navigate to.

private string GenerateSisenseAuthToken()
{
string sharedKey = GetSharedSecret(); // This is the shared key configured in Sisense
var securityKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(sharedKey));
var credentials = new SigningCredentials(securityKey, "HS256");
var header = new JwtHeader(credentials);
var user = GetUserName(); // [email protected]

TimeSpan timeSinceEpoch = (_dateTimeProvider.UtcNow - new DateTime(1970, 1, 1));
int secondsSinceEpoch = (int)timeSinceEpoch.TotalSeconds;

var payload = new JwtPayload
{
{ "iat", secondsSinceEpoch},
{ "sub", user },
{ "jti", Guid.NewGuid().ToString() }
};

var secToken = new JwtSecurityToken(header, payload);
var handler = new JwtSecurityTokenHandler();

return handler.WriteToken(secToken);
}

DRay
Community Team Leader
Community Team Leader

Hello @ramansingh89,

Thank you for reaching out. Can you look at this document and let us know if addresses your need?

https://sisense.dev/guides/accessSecurity/jwt/

Thank you.

 

David Raynor (DRay)

Hi @DRay does setting up JWT process requires an active sisense user? example JWT can update or create users in Sisense, but does JWT uses a 'user profile' to make those actions or its all done through the shared secret?

DRay
Community Team Leader
Community Team Leader

Hello @ramansingh89,

JWT uses a Sisense user profile to perform its actions. You can use the account of one of your Admins, but we recommend setting up a user specifically for the integration. This documentation has additional information that may help. https://docs.sisense.com/main/SisenseLinux/single-sign-on-using-json-web-token.htm

Please let me know if you have any more questions I can help you with.

David Raynor (DRay)

DRay
Community Team Leader
Community Team Leader

Hello @ramansingh89 ,

I wanted to follow up to see if any of the solutions offered worked for you.

If so, please click the 'Accept as Solution' button on the appropriate post so other users with the same questions can find the answer. If not, please let us know so that we can continue to help.

Thank you.

David Raynor (DRay)

DRay
Community Team Leader
Community Team Leader

Hello @ramansingh89,

I wanted to follow up to see if any of the solutions offered worked for you.

If so, please click the 'Accept as Solution' button on the appropriate post so other users with the same questions can find the answer. If not, please let us know so that we can continue to help.

Thank you.

David Raynor (DRay)

DRay
Community Team Leader
Community Team Leader

Hello @ramansingh89,

I wanted to follow up to see if any of the solutions offered worked for you.

If so, please click the 'Accept as Solution' button on the appropriate post so other users with the same questions can find the answer. If not, please let us know so that we can continue to help.

Thank you.

David Raynor (DRay)