Class: RrxApi::Auth::Firebase

Inherits:
Base
  • Object
show all
Defined in:
lib/rrx_api/auth/firebase.rb

Overview

Firebase authentication provider.

Requires the firebase-admin-sdk gem. It is intentionally not listed as a dependency of rrx_api — add it to your application's Gemfile when you want Firebase auth:

gem 'firebase-admin-sdk'

Configuration is read from RrxConfig.firebase (project_id, client_email, private_key, etc.).

Instance Method Summary collapse

Instance Method Details

#id_from_token(id_token) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rrx_api/auth/firebase.rb', line 18

def id_from_token(id_token)
  require_firebase!
  verified = auth.verify_id_token(id_token)
  verified['sub']
rescue LoadError
  raise
rescue => e
  # Lazily match the expired-token error so this file can be parsed before
  # the firebase-admin-sdk gem is loaded.
  raise TokenExpiredError if e.class.name == 'Firebase::Admin::Auth::ExpiredTokenError'

  raise
end

#user_info(uid) ⇒ Object



32
33
34
35
# File 'lib/rrx_api/auth/firebase.rb', line 32

def (uid)
  require_firebase!
  auth.get_user(uid)
end