Class: Cent::Notary
- Inherits:
-
Object
- Object
- Cent::Notary
- Defined in:
- lib/cent/notary.rb
Overview
Cent::Notary
Handle token generation
Instance Method Summary collapse
-
#initialize(secret:, algorithm: 'HS256') ⇒ Notary
constructor
A new instance of Notary.
-
#issue_channel_token(client:, channel:, info: nil, exp: nil) ⇒ String
Generate JWT for private channels.
-
#issue_connection_token(sub:, info: nil, exp: nil) ⇒ String
Generate connection JWT for the given user.
Constructor Details
Instance Method Details
#issue_channel_token(client:, channel:, info: nil, exp: nil) ⇒ String
Generate JWT for private channels
81 82 83 84 85 86 87 88 89 90 |
# File 'lib/cent/notary.rb', line 81 def issue_channel_token(client:, channel:, info: nil, exp: nil) payload = { 'client' => client, 'channel' => channel, 'info' => info, 'exp' => exp }.compact JWT.encode(payload, secret, algorithm) end |
#issue_connection_token(sub:, info: nil, exp: nil) ⇒ String
Generate connection JWT for the given user
48 49 50 51 52 53 54 55 56 |
# File 'lib/cent/notary.rb', line 48 def issue_connection_token(sub:, info: nil, exp: nil) payload = { 'sub' => sub, 'info' => info, 'exp' => exp }.compact JWT.encode(payload, secret, algorithm) end |