Skip to content

noha/JSONWebToken

Repository files navigation

JSONWebToken for Pharo

Build Status

Overview

Implementation of a JSON web token following RFC 7519 for Pharo.

Installation

For pharo9 and above use

Metacello new
      baseline:'JSONWebToken';
      repository: 'github://noha/JSONWebToken:pharo9-openssl1.1/source';
      load

For pharo8 and below use

Metacello new
      baseline:'JSONWebToken';
      repository: 'github://noha/JSONWebToken:master/source';
      load

Usage

The class JSONWebTokenTest demonstrates how to encode/serialize a web signature to a token string using compact base 64 notation as well as deserialization:

testRoundtrip
	| jws tokenString materialized |
	
	jws := JsonWebSignature new
		algorithmName: 'HS256';
		payload: (JWTClaimsSet new
			at: 'bar' put: 'foo').
	jws key: 'foobar'.
	
	tokenString := jws compactSerialized.
	materialized := JsonWebSignature materializeCompact: tokenString key: 'foobar'.
	self assert: jws equals: materialized

Further Infos