Skip to content

Latest commit

 

History

History
776 lines (421 loc) · 18.3 KB

auth_class.md

File metadata and controls

776 lines (421 loc) · 18.3 KB

ServiceAuth

Description

OAuth2.0 Access Token Authorization Using Service Account.

class ServiceAuth

Constructors

  1. 🔹 explicit ServiceAuth(TimeStatusCallback timeCb, const String &clientEmail, const String &projectId, const String &privateKey, size_t expire = FIREBASE_DEFAULT_TOKEN_TTL)

A ServiceAuth constructor.

explicit ServiceAuth(TimeStatusCallback timeCb, const String &clientEmail, const String &projectId, const String &privateKey, size_t expire = FIREBASE_DEFAULT_TOKEN_TTL)

Params:

  • timeCb - The time status callback that provides the UNIX timestamp used to set the issue time and expiration time in the JWT token payload.

  • clientEmail - The service account client Email.

  • projectId - The service account project ID.

  • privateKey - The service account private key.

  • expire - The expiry period in seconds (less than 3600), 3300 is the default value.

  1. 🔹 explicit ServiceAuth(TimeStatusCallback timeCb, const file_config_data &safile, size_t expire = FIREBASE_DEFAULT_TOKEN_TTL)

A ServiceAuth constructor.

explicit ServiceAuth(TimeStatusCallback timeCb, const file_config_data &safile, size_t expire = FIREBASE_DEFAULT_TOKEN_TTL)

Params:

  • timeCb - The time status callback that provides the UNIX timestamp used to set the issue time and expiration time in the JWT token payload.

  • safile - The filesystem data (file_config_data) obtained from FileConfig class object of service account key file.

  • expire - The expiry period in seconds (less than 3600), 3300 is the default value.

  1. 🔹 explicit ServiceAuth(uint32_t ts, const String &clientEmail, const String &projectId, const String &privateKey, size_t expire = FIREBASE_DEFAULT_TOKEN_TTL)

A ServiceAuth constructor.

explicit ServiceAuth(uint32_t ts, const String &clientEmail, const String &projectId, const String &privateKey, size_t expire = FIREBASE_DEFAULT_TOKEN_TTL)

Params:

  • ts - The current UNiX timestamp (seonds since Jan 1, 1970 midnight).

  • clientEmail - The service account client Email.

  • projectId - The service account project ID.

  • privateKey - The service account private key.

  • expire - The expiry period in seconds (less than 3600), 3300 is the default value.

  1. 🔹 explicit ServiceAuth(uint32_t ts, const file_config_data &safile, size_t expire = FIREBASE_DEFAULT_TOKEN_TTL)

A ServiceAuth constructor.

explicit ServiceAuth(uint32_t ts, const file_config_data &safile, size_t expire = FIREBASE_DEFAULT_TOKEN_TTL)

Params:

  • ts - The current UNiX timestamp (seonds since Jan 1, 1970 midnight).

  • safile - The filesystem data (file_config_data) obtained from FileConfig class object of service account key file.

  • expire - The expiry period in seconds (less than 3600), 3300 is the default value.

Functions

  1. 🔹 void clear()

Clear the internal credentials.

void clear()
  1. 🔹 user_auth_data &get()

Returns the internal user_auth_data reference.

user_auth_data &get()

Returns:

  • user_auth_data - Return internal user_auth_data reference.
  1. 🔹 bool isInitialized() const

Returns the status of this class initialization.

bool isInitialized() const

Returns:

  • bool - Return true if initialized.

CustomAuth

Description

ID Token Authorization Using Service Account with custom claims and UID.

For more details about claims, please visit https://firebase.google.com/docs/auth/admin/custom-claims.

class CustomAuth

Constructors

  1. 🔹 explicit CustomAuth(TimeStatusCallback timeCb, const String &apiKey, const String &clientEmail, const String &projectId, const String &privateKey, const String &uid, const String &claims = "", size_t expire = FIREBASE_DEFAULT_TOKEN_TTL)

A CustomAuth constructor.

explicit CustomAuth(TimeStatusCallback timeCb, const String &apiKey, const String &clientEmail, const String &projectId, const String &privateKey, const String &uid, const String &claims = "", size_t expire = FIREBASE_DEFAULT_TOKEN_TTL)

Params:

  • timeCb - The time status callback that provides the UNIX timestamp used to set the issue time and expiration time in the JWT token payload.

  • apiKey - The web API key of the project.

  • clientEmail - The service account client Email.

  • projectId - The service account project ID.

  • privateKey - The service account private key.

  • uid - The unique identifier of the signed-in user must be a string, between 1-128 characters long, inclusive. Shorter uids offer better performance.

  • claims - Optional custom claims to include in the Security Rules auth / request.auth variables.

  • expire - The expiry period in seconds (less than 3600), 3300 is the default value.

  1. 🔹 explicit CustomAuth(TimeStatusCallback timeCb, const file_config_data &safile, const String &apiKey, const String &uid, const String &claims = "", size_t expire = FIREBASE_DEFAULT_TOKEN_TTL)

A CustomAuth constructor.

explicit CustomAuth(TimeStatusCallback timeCb, const file_config_data &safile, const String &apiKey, const String &uid, const String &claims = "", size_t expire = FIREBASE_DEFAULT_TOKEN_TTL)

Params:

  • timeCb - The time status callback that provides the UNIX timestamp used to set the issue time and expiration time in the JWT token payload.

  • safile - The filesystem data (file_config_data) obtained from FileConfig class object of service account key file.

  • apiKey - The web API key of the project.

  • uid - The unique identifier of the signed-in user must be a string, between 1-128 characters long, inclusive. Shorter uids offer better performance.

  • claims - Optional custom claims to include in the Security Rules auth / request.auth variables.

  • expire - The expiry period in seconds (less than 3600), 3300 is the default value.

  1. 🔹 explicit CustomAuth(uint32_t ts, const String &apiKey, const String &clientEmail, const String &projectId, const String &privateKey, const String &uid, const String &claims = "", size_t expire = FIREBASE_DEFAULT_TOKEN_TTL)

A CustomAuth constructor.

explicit CustomAuth(uint32_t ts, const String &apiKey, const String &clientEmail, const String &projectId, const String &privateKey, const String &uid, const String &claims = "", size_t expire = FIREBASE_DEFAULT_TOKEN_TTL)

Params:

  • ts - The current UNiX timestamp (seonds since Jan 1, 1970 midnight).

  • apiKey - The web API key of the project.

  • clientEmail - The service account client Email.

  • projectId - The service account project ID.

  • privateKey - The service account private key.

  • uid - The unique identifier of the signed-in user must be a string, between 1-128 characters long, inclusive. Shorter uids offer better performance.

  • claims - Optional custom claims to include in the Security Rules auth / request.auth variables.

  • expire - The expiry period in seconds (less than 3600), 3300 is the default value.

  1. 🔹 explicit CustomAuth(uint32_t ts, const file_config_data &safile, const String &apiKey, const String &uid, const String &claims = "", size_t expire = FIREBASE_DEFAULT_TOKEN_TTL)

A CustomAuth constructor.

explicit CustomAuth(uint32_t ts, const file_config_data &safile, const String &apiKey, const String &uid, const String &claims = "", size_t expire = FIREBASE_DEFAULT_TOKEN_TTL)

Params:

  • ts - The current UNiX timestamp (seonds since Jan 1, 1970 midnight).

  • safile - The filesystem data (file_config_data) obtained from FileConfig class object of service account key file.

  • apiKey - The web API key of the project.

  • uid - The unique identifier of the signed-in user must be a string, between 1-128 characters long, inclusive. Shorter uids offer better performance.

  • claims - Optional custom claims to include in the Security Rules auth / request.auth variables.

  • expire - The expiry period in seconds (less than 3600), 3300 is the default value.

Functions

  1. 🔹 void clear()

Clear the internal credentials.

void clear()
  1. 🔹 user_auth_data &get()

Returns the internal user_auth_data reference.

user_auth_data &get()

Returns:

  • user_auth_data - Return internal user_auth_data reference.
  1. 🔹 bool isInitialized() const

Returns the status of this class initialization.

bool isInitialized() const

Returns:

  • bool - Return true if initialized.
  1. 🔹 void setClaims(const String &claims)

Set the additional claims.

Because this library does not include JSON library to parse the claims, this function will replace or set the internal claims data.

For more details about claims, please visit https://firebase.google.com/docs/auth/admin/custom-claims.

void setClaims(const String &claims)

Params:

  • claims - The custom claims to include in the Security Rules auth / request.auth variables.

UserAuth

Description

User Sign-In Authentication.

class UserAuth

Constructors

  1. 🔹 explicit UserAuth(const String &api_key, const String &email, const String &password, size_t expire = FIREBASE_DEFAULT_TOKEN_TTL)

A UserAuth constructor.

explicit UserAuth(const String &api_key, const String &email, const String &password, size_t expire = FIREBASE_DEFAULT_TOKEN_TTL)

Params:

  • api_key - The API key which can be obtained from Firebase console > Project Overview > Project settings.

  • email - The Email of user in the project.

  • password - The password of user in the project.

  • expire - The expiry period in seconds (less than 3600), 3300 is the default value.

  1. 🔹 explicit UserAuth(const file_config_data &userFile)

A UserAuth constructor.

explicit UserAuth(const file_config_data &userFile)

Params:

  • userFile - The filesystem data (file_config_data) obtained from FileConfig class object of file that the UserAuth credentials will be saved to or read from.

Functions

  1. 🔹 void clear()

Clear the internal credentials.

void clear()
  1. 🔹 user_auth_data &get()

Returns the internal user_auth_data reference.

user_auth_data &get()

Returns:

  • user_auth_data - Return internal user_auth_data reference.
  1. 🔹 bool isInitialized() const

Returns the status of this class initialization.

bool isInitialized() const

Returns:

  • bool - Return true if initialized.
  1. 🔹 bool save(file_config_data &userFile)

Save the user config data.

bool save(file_config_data &userFile)

Params:

  • userFile - The filesystem data (file_config_data) obtained from FileConfig class object of file that the UserAuth credentials will be saved to or read from.

NoAuth

Description

Non-Authentication.

class UserAuth

Constructors

  1. 🔹 NoAuth()

A NoAuth constructor.

NoAuth()

Functions

  1. 🔹 user_auth_data &get()

Returns the internal user_auth_data reference.

user_auth_data &get()

Returns:

  • user_auth_data - Return internal user_auth_data reference.

AccessToken

Description

OAuth2.0 Access Token Authorization

class AccessToken

Constructors

  1. 🔹 explicit AccessToken(const String &token, size_t expire = FIREBASE_DEFAULT_TOKEN_TTL, const String &refresh = "", const String &client_id = "", const String &client_secret = "")

A AccessToken constructor.

explicit AccessToken(const String &token, size_t expire = FIREBASE_DEFAULT_TOKEN_TTL, const String &refresh = "", const String &client_id = "", const String &client_secret = "")

Params:

  • token - The access token.

  • expire - The expiry period in seconds (less than 3600), 3300 is the default value.

  • refresh - The refresh token.

  • client_id - The Client ID.

  • client_secret - The Client secret.

  1. 🔹 explicit AccessToken(const file_config_data &tokenFile)

A AccessToken constructor.

explicit AccessToken(const file_config_data &tokenFile)

Params:

  • tokenFile - The filesystem data (file_config_data) obtained from FileConfig class object of file that the AccessToken credentials will be saved to or read from.

Functions

  1. 🔹 void clear()

Clear the internal credentials.

void clear()
  1. 🔹 user_auth_data &get()

Returns the internal user_auth_data reference.

user_auth_data &get()

Returns:

  • user_auth_data - Return internal user_auth_data reference.
  1. 🔹 bool isInitialized() const

Returns the status of this class initialization.

bool isInitialized() const

Returns:

  • bool - Return true if initialized.
  1. 🔹 bool save(file_config_data &userFile)

Save the user config data.

bool save(file_config_data &userFile)

Params:

  • userFile - The filesystem data (file_config_data) obtained from FileConfig class object of file that the UserAuth credentials will be saved to or read from.

CustomToken

Description

ID Token Authorization Using Custom Token

class CustomToken

Constructors

  1. 🔹 explicit CustomToken(const String &api_key, const String &token, size_t expire = FIREBASE_DEFAULT_TOKEN_TTL)

A CustomToken constructor.

explicit CustomToken(const String &api_key, const String &token, size_t expire = FIREBASE_DEFAULT_TOKEN_TTL)

Params:

  • api_key - API key can be obtained from Firebase console > Project Overview > Project settings.

  • token - The custom token (jwt signed token).

  • expire - Expiry period in seconds (less than 3600), 3300 is the default value.

  1. 🔹 explicit CustomToken(const file_config_data &tokenFile)

A CustomToken constructor.

 explicit CustomToken(const file_config_data &tokenFile)

Params:

  • tokenFile - The filesystem data (file_config_data) obtained from FileConfig class object of file that the CustomToken credentials will be saved to or read from.

Functions

  1. 🔹 void clear()

Clear the internal credentials.

void clear()
  1. 🔹 user_auth_data &get()

Returns the internal user_auth_data reference.

user_auth_data &get()

Returns:

  • user_auth_data - Return internal user_auth_data reference.
  1. 🔹 bool isInitialized() const

Returns the status of this class initialization.

bool isInitialized() const

Returns:

  • bool - Return true if initialized.
  1. 🔹 bool save(file_config_data &userFile)

Save the user config data.

bool save(file_config_data &userFile)

Params:

  • userFile - The filesystem data (file_config_data) obtained from FileConfig class object of file that the UserAuth credentials will be saved to or read from.

IDToken

Description

ID token Authorization.

class IDToken

Constructors

  1. 🔹 explicit IDToken(const String &api_key, const String &token, size_t expire = FIREBASE_DEFAULT_TOKEN_TTL, const String &refresh = "")

A IDToken constructor.

explicit IDToken(const String &api_key, const String &token, size_t expire = FIREBASE_DEFAULT_TOKEN_TTL, const String &refresh = "")

Params:

  • api_key - API key can be obtained from Firebase console > Project Overview > Project settings.

  • token - The ID token.

  • expire - Expire period in seconds.

  • refresh - The refresh token.

  1. 🔹 explicit IDToken(const file_config_data &tokenFile)

A IDToken constructor.

 explicit IDToken(const file_config_data &tokenFile)

Params:

  • tokenFile - The filesystem data (file_config_data) obtained from FileConfig class object of file that the CustomToken credentials will be saved to or read from.

Functions

  1. 🔹 void clear()

Clear the internal credentials.

void clear()
  1. 🔹 user_auth_data &get()

Returns the internal user_auth_data reference.

user_auth_data &get()

Returns:

  • user_auth_data - Return internal user_auth_data reference.
  1. 🔹 bool isInitialized() const

Returns the status of this class initialization.

bool isInitialized() const

Returns:

  • bool - Return true if initialized.
  1. 🔹 bool save(file_config_data &userFile)

Save the user config data.

bool save(file_config_data &userFile)

Params:

  • userFile - The filesystem data (file_config_data) obtained from FileConfig class object of file that the UserAuth credentials will be saved to or read from.

LegacyToken

Description

The Realtime Database access with the database Secret.

class LegacyToken

Constructors

  1. 🔹 explicit LegacyToken(const String &token)

A LegacyToken constructor.

explicit LegacyToken(const String &token)

Params:

  • token - The Realtime Database secret key.
  1. 🔹 explicit LegacyToken(const file_config_data &tokenFile)

A LegacyToken constructor.

 explicit LegacyToken(const file_config_data &tokenFile)

Params:

  • tokenFile - The filesystem data (file_config_data) obtained from FileConfig class object of file that the CustomToken credentials will be saved to or read from.

Functions

  1. 🔹 void clear()

Clear the internal credentials.

void clear()
  1. 🔹 user_auth_data &get()

Returns the internal user_auth_data reference.

user_auth_data &get()

Returns:

  • user_auth_data - Return internal user_auth_data reference.
  1. 🔹 bool save(file_config_data &userFile)

Save the user config data.

bool save(file_config_data &userFile)

Params:

  • userFile - The filesystem data (file_config_data) obtained from FileConfig class object of file that the UserAuth credentials will be saved to or read from.