Class: Rack::Firebase::TokenDecoder

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/firebase/token_decoder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTokenDecoder

Returns a new instance of TokenDecoder.



10
11
12
13
# File 'lib/rack/firebase/token_decoder.rb', line 10

def initialize
  @jwt_loader = FIREBASE_KEY_LOADER
  @config = Rack::Firebase.configuration
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



8
9
10
# File 'lib/rack/firebase/token_decoder.rb', line 8

def config
  @config
end

#jwt_loaderObject

Returns the value of attribute jwt_loader.



8
9
10
# File 'lib/rack/firebase/token_decoder.rb', line 8

def jwt_loader
  @jwt_loader
end

Instance Method Details

#call(token) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rack/firebase/token_decoder.rb', line 15

def call(token)
  JWT.decode(
    token, nil, true,
    {
      jwks: jwt_loader,
      algorithm: ALG,
      verify_iat: true,
      verify_aud: true, aud: config.project_ids,
      verify_iss: true, iss: firebase_issuers
    }
  )[0]
end

#firebase_issuersObject



28
29
30
31
32
# File 'lib/rack/firebase/token_decoder.rb', line 28

def firebase_issuers
  config.project_ids.map { |project_id|
    "https://securetoken.google.com/#{project_id}"
  }
end