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
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>
Copy link to clipboard
Copied
Copy link to clipboard
Copied
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,
^ _ ^