Class: JSONWebToken::RSAToken

Inherits:
Token
  • Object
show all
Defined in:
lib/json_web_token/rsa_token.rb

Constant Summary

Constants inherited from Token

Token::DEFAULT_EXPIRE_TIME, Token::DEFAULT_NOT_BEFORE_TIME

Instance Attribute Summary collapse

Attributes inherited from Token

#audience, #expire_time, #id, #issued_at, #issuer, #not_before, #subject

Instance Method Summary collapse

Methods inherited from Token

#[], #[]=, #payload

Constructor Details

#initialize(key_file) ⇒ RSAToken

Returns a new instance of RSAToken.



7
8
9
10
# File 'lib/json_web_token/rsa_token.rb', line 7

def initialize(key_file)
  super()
  @key_file = key_file
end

Instance Attribute Details

#key_fileObject (readonly)

Returns the value of attribute key_file.



5
6
7
# File 'lib/json_web_token/rsa_token.rb', line 5

def key_file
  @key_file
end

Instance Method Details

#encodedObject



12
13
14
15
16
17
18
# File 'lib/json_web_token/rsa_token.rb', line 12

def encoded
  headers = {
    kid: kid,
    typ: 'JWT'
  }
  JWT.encode(payload, key, 'RS256', headers)
end