GoldenTicket
Simple JSON Web Token tools
Presentation
This library provides utilities for manipulating JSON Web Tokens (JWT).
Installation
Gemfile
gem 'golden_ticket'
Terminal
gem install -V golden_ticket
Usage
Any payload can be encoded as a JWT using the encode method:
key = 'supersecret'
payload = { user_id: 0, foo: :bar }
GoldenTicket.encode key, payload
# => 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjowLCJmb28iOiJiYXIifQ.4Tn4B_uV-FJ_xh2Vcg4LB24DP2faPoEll4Cttjblkhs'
Any JWT can be decoded using the decode method:
key = 'supersecret'
token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjowLCJmb28iOiJiYXIifQ.4Tn4B_uV-FJ_xh2Vcg4LB24DP2faPoEll4Cttjblkhs'
GoldenTicket.decode key, token
# => { user_id: 0, foo: 'bar' }
License
The gem is available as open source under the terms of the MIT License.