Class: Mumukit::Auth::Client
- Inherits:
-
Object
- Object
- Mumukit::Auth::Client
- Defined in:
- lib/mumukit/auth/client.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#secret ⇒ Object
readonly
Returns the value of attribute secret.
Instance Method Summary collapse
- #decode(encoded_jwt) ⇒ Object
- #decoded_secret ⇒ Object
- #encode(jwt_hash) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
5 6 7 8 9 10 |
# File 'lib/mumukit/auth/client.rb', line 5 def initialize(={}) with_config do |config| @id = config[:id] @secret = config[:secret] end end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/mumukit/auth/client.rb', line 3 def id @id end |
#secret ⇒ Object (readonly)
Returns the value of attribute secret.
3 4 5 |
# File 'lib/mumukit/auth/client.rb', line 3 def secret @secret end |
Instance Method Details
#decode(encoded_jwt) ⇒ Object
20 21 22 |
# File 'lib/mumukit/auth/client.rb', line 20 def decode(encoded_jwt) JWT.decode(encoded_jwt, decoded_secret)[0] end |
#decoded_secret ⇒ Object
12 13 14 |
# File 'lib/mumukit/auth/client.rb', line 12 def decoded_secret JWT.base64url_decode(secret) end |
#encode(jwt_hash) ⇒ Object
16 17 18 |
# File 'lib/mumukit/auth/client.rb', line 16 def encode(jwt_hash) JWT.encode(jwt_hash, decoded_secret) end |