Forums

Single signon with JSON Web Token

tmarcom 03 Oct, 2016
Hi,

I want to have a third-party cloud-based helpdesk service to redirect a login request to a login form on our Joomla website, in order to implement a single signon for both our website and the helpdesk service (specifically: Happyfox). Our login form is created with Chronoforms. Upon submission, the form should redirect to a URL (presumably using cURL?) which contains a web token which has been created using the credentials (i.e. username + password) entered in the login form.

How to I do that? Where should I store in Joomla the required libraries for JSON Web Token, how do I create the necessary URL in ChronoForms? Does anyone have experience with integration of JSON web tokens in Joomla & ChronoForms?

Looking forward to any replies, as I haven't seen much on that subject so far on the Web.
GreyHead 03 Oct, 2016
Hi sbinar,

I've not done this but it should be possible,

I found this StackOverflow answer which has the code for creating a token using this JWT class

Down load the class file and add it to your site in e.g. /components/com_chronoforms5/extras/jwt/jwt_helper.php

Then use the code from the example like this
<?php
include(JSITE_PATH.'/components/com_chronoforms5/extras/jwt/jwt_helper.php');
$token = array();
$token['id'] = $id;
$form->data['token'] = JWT::encode($token, 'secret_server_key');
?>
!!! not tested and probably needs debugging !!! Note that $id isn't defined here!

You can then use a cURL action to send the token with whatever other data you need.

Bob
tmarcom 03 Oct, 2016
Thanks for the super-fast response. That should definitely help me move forward with this feature.
This topic is locked and no more replies can be posted.