Class: Firebase::Admin::Auth::Client
- Inherits:
-
Object
- Object
- Firebase::Admin::Auth::Client
- Defined in:
- lib/firebase/admin/auth/client.rb
Overview
A client for communicating with the Firebase Auth service.
Instance Method Summary collapse
-
#create_user(uid: nil, display_name: nil, email: nil, email_verified: nil, phone_number: nil, photo_url: nil, password: nil, disabled: nil) ⇒ UserRecord
Creates a new user account with the specified properties.
-
#delete_user(uid) ⇒ Object
Deletes the user corresponding to the specified user id.
-
#emulated? ⇒ Boolean
Checks if the auth client is configured to use the Firebase Auth Emulator.
-
#get_user(uid) ⇒ UserRecord
Gets the user corresponding to the specified user id.
-
#get_user_by_email(email) ⇒ UserRecord
Gets the user corresponding to the specified email address.
-
#get_user_by_phone_number(phone_number) ⇒ Object
Gets the user corresponding to the specified phone number.
-
#initialize(app) ⇒ Client
constructor
Constructs a new client.
-
#verify_id_token(token, check_revoked = false) ⇒ Hash
Verifies the signature and data for the provided JWT.
Constructor Details
#initialize(app) ⇒ Client
Constructs a new client
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/firebase/admin/auth/client.rb', line 9 def initialize(app) @project_id = app.project_id @service_account_id = app.service_account_id @credentials = app.credentials @emulated = Utils.is_emulated? v1_url_override = Utils.get_emulator_v1_url @credentials = EmulatorCredentials.new if @emulated @id_token_verifier = IDTokenVerifier.new(app) @user_manager = UserManager.new(@project_id, @credentials, v1_url_override) end |
Instance Method Details
#create_user(uid: nil, display_name: nil, email: nil, email_verified: nil, phone_number: nil, photo_url: nil, password: nil, disabled: nil) ⇒ UserRecord
Creates a new user account with the specified properties.
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/firebase/admin/auth/client.rb', line 42 def create_user(uid: nil, display_name: nil, email: nil, email_verified: nil, phone_number: nil, photo_url: nil, password: nil, disabled: nil) @user_manager.create_user( uid: uid, display_name: display_name, email: email, email_verified: email_verified, phone_number: phone_number, photo_url: photo_url, password: password, disabled: disabled ) end |
#delete_user(uid) ⇒ Object
Deletes the user corresponding to the specified user id.
86 87 88 |
# File 'lib/firebase/admin/auth/client.rb', line 86 def delete_user(uid) @user_manager.delete_user(uid) end |
#emulated? ⇒ Boolean
Checks if the auth client is configured to use the Firebase Auth Emulator. @ return [Boolean] true if configured for the auth emulator, false otherwise.
24 25 26 |
# File 'lib/firebase/admin/auth/client.rb', line 24 def emulated? @emulated end |
#get_user(uid) ⇒ UserRecord
Gets the user corresponding to the specified user id.
61 62 63 |
# File 'lib/firebase/admin/auth/client.rb', line 61 def get_user(uid) @user_manager.get_user_by(uid: uid) end |
#get_user_by_email(email) ⇒ UserRecord
Gets the user corresponding to the specified email address.
71 72 73 |
# File 'lib/firebase/admin/auth/client.rb', line 71 def get_user_by_email(email) @user_manager.get_user_by(email: email) end |
#get_user_by_phone_number(phone_number) ⇒ Object
Gets the user corresponding to the specified phone number.
78 79 80 |
# File 'lib/firebase/admin/auth/client.rb', line 78 def get_user_by_phone_number(phone_number) @user_manager.get_user_by(phone_number: phone_number) end |
#verify_id_token(token, check_revoked = false) ⇒ Hash
Verifies the signature and data for the provided JWT.
Accepts a signed token string, verifies that it is current, was issued to this project, and that it was correctly signed by Google.
98 99 100 101 102 |
# File 'lib/firebase/admin/auth/client.rb', line 98 def verify_id_token(token, check_revoked = false) verified_claims = @id_token_verifier.verify(token, is_emulator: emulated?) revoked = check_revoked && !id_token_revoked?(verified_claims) verified_claims unless revoked end |