Class: FirebaseTokenAuthentication::AccessToken

Inherits:
Object
  • Object
show all
Defined in:
lib/firebase_token_authentication/access_token.rb

Constant Summary collapse

DECODE_OPTIONS =
{
  algorithm: "RS256",
  verify_iat: true,
  verify_aud: true,
  verify_iss: true
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(firebase_token, certificate = GoogleX509Certificate.new) ⇒ AccessToken

Returns a new instance of AccessToken.



16
17
18
19
20
# File 'lib/firebase_token_authentication/access_token.rb', line 16

def initialize(firebase_token, certificate = GoogleX509Certificate.new)
  @firebase_token = firebase_token
  @certificate = certificate
  @key_id = decode(key: nil, verify_key: false)[1]["kid"]
end

Instance Attribute Details

#certificateObject (readonly)

Returns the value of attribute certificate.



7
8
9
# File 'lib/firebase_token_authentication/access_token.rb', line 7

def certificate
  @certificate
end

#firebase_tokenObject (readonly)

Returns the value of attribute firebase_token.



7
8
9
# File 'lib/firebase_token_authentication/access_token.rb', line 7

def firebase_token
  @firebase_token
end

#key_idObject (readonly)

Returns the value of attribute key_id.



7
8
9
# File 'lib/firebase_token_authentication/access_token.rb', line 7

def key_id
  @key_id
end

Instance Method Details

#verifyObject



22
23
24
# File 'lib/firebase_token_authentication/access_token.rb', line 22

def verify
  decode(key: certificate.find(key_id))
end