Category Archives: MVC

Sisense SSO implementation in MVC .net core

We can find a documentation regarding what needs to be done in Sisense BI Elastic cube manager in relation to SSO using JWT.  They also have C# code to use for SSO but one may be scratching his head if he/she wants to use that sample code in MVC .net Core application.

So for that purpose I’ld suggest to make one controller with one action in it, Use that URL of that controller action to configure in Sisense SSO configuration page. The sample code would be


public IActionResult Index([FromQuery]string return_to)
   TimeSpan t = (DateTime.UtcNow - new DateTime(1970, 1, 1));
   int timestamp = (int)t.TotalSeconds;
   var payload = new System.Collections.Generic.Dictionary<string, object>() {
     { "iat", timestamp},
     { "sub", CurrentUser() },
     { "jti", Guid.NewGuid() }
     // Optional properties
     // { "exp", (int)t.Add(TimeSpan.FromMinutes(30)).TotalSeconds } // Expiration time

   string token = Jwt.JsonWebToken.Encode(payload, "secret key from sisense sso                 configuration", Jwt.JwtHashAlgorithm.HS256);
   string redirectUrl = "http://URL_of_your_sisense_web_app_with_port/jwt?jwt=" + token;
   if (return_to != null)
    redirectUrl += "&return_to=" + UrlEncoder.Default.Encode(return_to);
  return Redirect(redirectUrl)