FORGEBOX Enterprise 🚀 - Take your ColdFusion (CFML) Development to Modern Times! Learn More...

CFWheels JWT

CFWheels JWT

Description

CFWheels Plugin ported from existing CFML Component by Jason Steinshouer for encoding and decoding JSON Web Tokens (JWT), which in turn is a port of the node.js project node-jwt-simple to cfml.

It currently supports HS256, HS384, and HS512 signing algorithms.

Usage

<cfscript>
	// Initialize the component with the secret signing key
	jwtObj = jwt(secretkey);

	// Encode the data structure as a json web token
	// NB, using "token" as a variable name seems to cause issues
	thetoken = jwtObj.encode(payload);

	// Decode the thetoken and get the data structure back. This is will throw an error if the thetoken is invalid
	result = jwtObj.decode(thetoken);
</cfscript>

Support for registered claims

Supports the nbf and exp registered claims that can be part of the payload. Verification of the token will fail if the token is not yet active or if the token is expired according to the nbf and exp claims. They should be numeric dates in Unix epoch time according to the JWT spec.

To ignore the exp claim during verification, pass ignoreExpiration=true when instantiating the JWT instance. For example:

jwtObj = jwt(key=secretkey, ignoreExpiration=true);

Also supports the aud and iss registered claims during verification. If you don't pass audience or issuer during instantiation, the claims will be ignored during verification. If you do pass them, they'll be included during the verification process. Here's an example:

jwtObj = jwt(key=secretkey, audience="myaudiencevalue", issuer="myissuervalue");

Here are all the versions for this package. Please note that you can leverage CommandBox package versioning to install any package you like. Please refer to our managing package version guide for more information.

Version Created Last Update Published By Stable Download
1.0.1 Mar 16 2018 05:09 AM Mar 16 2018 05:09 AM Tom King (neokoenig)
1.0.0 Mar 15 2018 04:33 AM Mar 15 2018 04:33 AM Tom King (neokoenig)

 

  •   Tom King
  • Published
  • 1.0.1 is the latest of 2 release(s)
    Published
  • Published on Mar 16 2018 05:09 AM
No collaborators yet.
 
  • Mar 15 2018 04:33 AM
  • Mar 16 2018 05:09 AM
  • 397
  • 0
  • 39