jwt_obj
jwt_obj
jwt_obj
adds a high level mixin for your classes for easily encoding your objects with JWT claims.
Implements crystal-community/jwt. See their README.md
for more details on what JWT is and how it works.
Installation
Add this to your application's shard.yml
:
dependencies:
jwt_obj:
github: y32/jwt_obj
Usage
See JWT's supported reserved claims for details on what each claim is for.
require "jwt_obj"
struct Session
include JWT::Token
JSON.mapping(foo: String)
def initialize(@foo)
end
end
session = Session.new("bar")
encoded = session.encode("secret", "none") do
issued_at Time.now
issuer "z64"
audience ["GitHub", "snapcase"]
end
JWT.decode(encoded, "secret", "none")
#=> {{"foo" => "bar", "iat" => 1507264921, "iss" => "z64", "aud" => ["GitHub", "snapcase"]}, {"typ" => "JWT", "alg" => "none"}}
Contributors
- z64 Zac Nowicki - creator, maintainer
Repository
jwt_obj
Owner
Statistic
- 2
- 0
- 0
- 0
- 1
- about 7 years ago
- October 6, 2017
License
MIT License
Links
Synced at
Thu, 07 Nov 2024 09:42:13 GMT
Languages