Class: Mumukit::Auth::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/mumukit/auth/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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(options={})
  with_config options do |config|
    @id = config[:id]
    @secret = config[:secret]
  end
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/mumukit/auth/client.rb', line 3

def id
  @id
end

#secretObject (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_secretObject



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