Highlighted

Single Sign on using JWT

Advisor ,
Oct 01, 2019

Copy link to clipboard

Copied

Hi All,

Trying to do a single sign on from my site to another site using JWT.

Found this library:

https://github.com/bennadel/JSONWebTokens.cfc

My code from my cfm page:

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "<a href="<a href="http://www.w3.org/TR/html4/loose.dtd" target="_blank">http://www.w3.org/TR/html4/loose.dtd</a>" target="_blank"><a href="http://www.w3.org/TR/html4/loose.dtd</a" target="_blank">http://www.w3.org/TR/html4/loose.dtd</a</a>>">
<html>
<head>
<title>Login</title>
<cfscript>
  payload = {
        userId: "myUser",
        userDir: "LDIR"
    };
  jwt = new cfcDir.JsonWebTokens().createClient("HS256","./cfcDir/server.pem", "./cfcDir/server_key.pem");
  token = jwt.encode( payload );
</cfscript>

<cfheader name="X-Qlik-Session-jwt" value="#token#">
<cflocation url="<a href="<a href="https://myDomain.net/jwt/hub/" target="_blank">https://myDomain.net/jwt/hub/</a>" target="_blank"><a href="https://myDomain.net/jwt/hub/</a" target="_blank">https://myDomain.net/jwt/hub/</a</a>>" addtoken="false" />
</head>
</html>

 

I'm confused, it is opening the new location but it is not taking the encoded token.

Any ideas?

Thanks

Views

100

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Single Sign on using JWT

Advisor ,
Oct 01, 2019

Copy link to clipboard

Copied

Hi All,

Trying to do a single sign on from my site to another site using JWT.

Found this library:

https://github.com/bennadel/JSONWebTokens.cfc

My code from my cfm page:

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "<a href="<a href="http://www.w3.org/TR/html4/loose.dtd" target="_blank">http://www.w3.org/TR/html4/loose.dtd</a>" target="_blank"><a href="http://www.w3.org/TR/html4/loose.dtd</a" target="_blank">http://www.w3.org/TR/html4/loose.dtd</a</a>>">
<html>
<head>
<title>Login</title>
<cfscript>
  payload = {
        userId: "myUser",
        userDir: "LDIR"
    };
  jwt = new cfcDir.JsonWebTokens().createClient("HS256","./cfcDir/server.pem", "./cfcDir/server_key.pem");
  token = jwt.encode( payload );
</cfscript>

<cfheader name="X-Qlik-Session-jwt" value="#token#">
<cflocation url="<a href="<a href="https://myDomain.net/jwt/hub/" target="_blank">https://myDomain.net/jwt/hub/</a>" target="_blank"><a href="https://myDomain.net/jwt/hub/</a" target="_blank">https://myDomain.net/jwt/hub/</a</a>>" addtoken="false" />
</head>
</html>

 

I'm confused, it is opening the new location but it is not taking the encoded token.

Any ideas?

Thanks

Views

101

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Oct 01, 2019 0
Advisor ,
Oct 01, 2019

Copy link to clipboard

Copied

I got it to work:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "<a href="http://www.w3.org/TR/html4/loose.dtd" target="_blank">http://www.w3.org/TR/html4/loose.dtd</a>">
<html>
<head>
<title>Login</title>
<cfscript>
  payload = {
        userId: "myUser",
        userDir: "LDIR"
    };
  jwt = new cfcDir.JsonWebTokens().createClient("HS256","./cfcDir/JsonWebToken/server.pem", "./cfcDir/JsonWebToken/server_key.pem");
  token = jwt.encode( payload );
  cfheader(name="Authorization", value="Bearer #token#" );
  location("<a href="https://myDomain.net/jwt/hub/" target="_blank">https://myDomain.net/jwt/hub/</a>", "false", "301");
</cfscript>
</head>
</html>

 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 01, 2019 0
Advisor ,
Oct 01, 2019

Copy link to clipboard

Copied

i didn't work, my session var was cache.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 01, 2019 0
Advisor ,
Oct 02, 2019

Copy link to clipboard

Copied

Is anyone familiar with this project https://github.com/bennadel/JSONWebTokens.cfc

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 02, 2019 0
LEGEND ,
Oct 02, 2019

Copy link to clipboard

Copied

I am not at all familiar with JWT, but I know Ben does a real good job of coming up with projects like this.

 

One thought:  Use an HTML5 doctype.  I don't know if this will help fix your issue, but it will bring your page(s) into the 21st century.

 

<!DOCTYPE HTML>

 

V/r,

 

^ _ ^

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 02, 2019 0