Class: FirebaseRubyAuth
- Inherits:
-
Object
- Object
- FirebaseRubyAuth
- Defined in:
- lib/firebase_ruby_auth.rb
Overview
Interacts with data from Firebase
Instance Method Summary collapse
-
#decode_token(token) ⇒ Object
token would be a user’s ID token firebase.google.com/docs/auth/admin/verify-id-tokens This will either return a hash with user data, or an empty hash.
-
#initialize(firebase_project_id) ⇒ FirebaseRubyAuth
constructor
A new instance of FirebaseRubyAuth.
Constructor Details
#initialize(firebase_project_id) ⇒ FirebaseRubyAuth
Returns a new instance of FirebaseRubyAuth.
10 11 12 13 |
# File 'lib/firebase_ruby_auth.rb', line 10 def initialize(firebase_project_id) @firebase_project_id = firebase_project_id @public_cert = GooglePublicCert.new end |
Instance Method Details
#decode_token(token) ⇒ Object
token would be a user’s ID token firebase.google.com/docs/auth/admin/verify-id-tokens This will either return a hash with user data, or an empty hash
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/firebase_ruby_auth.rb', line 18 def decode_token(token) return {} if @public_cert.keys.empty? token_values = begin JWT.decode(token, nil, true, ).first rescue JWT::JWKError {} rescue JWT::DecodeError {} end valid?(token_values) ? token_values : {} end |