Skip to content

Commit 83c1ec0

Browse files
committed
Use Mbed TLS as default engine for ESP32 JWT
1 parent 8d39be8 commit 83c1ec0

File tree

145 files changed

+459
-2793
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

145 files changed

+459
-2793
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/mobizt/FirebaseClient/.github%2Fworkflows%2Fcompile_library.yml?logo=github&label=compile) [![Github Stars](https://img.shields.io/github/stars/mobizt/FirebaseClient?logo=github)](https://github.com/mobizt/FirebaseClient/stargazers) ![Github Issues](https://img.shields.io/github/issues/mobizt/FirebaseClient?logo=github)
44

5-
![GitHub Release](https://img.shields.io/github/v/release/mobizt/FirebaseClient) ![Arduino](https://img.shields.io/badge/Arduino-v2.1.0-57C207?logo=arduino) ![PlatformIO](https://badges.registry.platformio.org/packages/mobizt/library/FirebaseClient.svg) ![GitHub Release Date](https://img.shields.io/github/release-date/mobizt/FirebaseClient)
5+
![GitHub Release](https://img.shields.io/github/v/release/mobizt/FirebaseClient) ![Arduino](https://img.shields.io/badge/Arduino-v2.1.1-57C207?logo=arduino) ![PlatformIO](https://badges.registry.platformio.org/packages/mobizt/library/FirebaseClient.svg) ![GitHub Release Date](https://img.shields.io/github/release-date/mobizt/FirebaseClient)
66

7-
Revision `2025-05-24`
7+
Revision `2025-05-25`
88

99
## Introduction
1010

examples/App/AppInitialization/CustomAuth/CustomAuth.ino

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,11 @@
11
/**
2-
* ABOUT:
3-
*
42
* The bare minimum example for using user authentication with custom UID and claims.
53
*
64
* This example requires the service account credentials that obtains from the JSON key file.
75
*
86
* The complete usage guidelines, please read README.md or visit https://github.com/mobizt/FirebaseClient
9-
*
10-
* SYNTAX:
11-
*
12-
* 1.------------------------
13-
*
14-
* CustomAuth::CustomAuth(<api_key>, <client_email>, <project_id>, <private_key>, <user_id>, <scope>, <claims>, <expire>);
15-
*
16-
* <api_key> - The web API key of project.
17-
* <client_email> - The service account client Email.
18-
* <project_id> - The service account project ID.
19-
* <private_key> - The service account private key.
20-
* <user_id> - The unique identifier of the signed-in user must be a string, between 1-128 characters long, inclusive. Shorter uids offer better performance.
21-
* <claims> - Optional custom claims to include in the Security Rules auth / request.auth variables.
22-
* <expire> - The expiry period in seconds (less than 3600), 3300 is the default value.
23-
*
24-
* 2.------------------------
25-
*
26-
* CustomAuth::CustomAuth(<TimeStatusCallback>, <api_key>, <client_email>, <project_id>, <private_key>, <user_id>, <scope>, <claims>, <expire>);
27-
*
28-
* <TimeStatusCallback> - The time status callback that provide the UNIX timestamp value used for JWT token signing.
29-
* <api_key> - The web API key of project.
30-
* <client_email> - The service account client Email.
31-
* <project_id> - The service account project ID.
32-
* <private_key> - The service account private key.
33-
* <user_id> - The user ID.
34-
* <scope> - The OAuth scopes.
35-
* <claims> - The OAuth claims. For more details about claims, please visit https://firebase.google.com/docs/auth/admin/custom-claims.
36-
* <expire> - The expiry period in seconds (less than 3600), 3300 is the default value.
37-
*
38-
* See examples/RealtimeDatabase/AccessControl/AccessControl.ino for how it can work with security rules for database access control.
39-
*
40-
* 3.------------------------
41-
*
42-
* initializeApp(<AsyncClient>, <FirebaseApp>, <user_auth_data>, <AsyncResultCallback>, <uid>);
43-
*
44-
* <AsyncClient> - The async client.
45-
* <FirebaseApp> - The authentication and access token handler.
46-
* <user_auth_data> - The user auth data (user_auth_data struct) that holds the user input sign-in credentials and token.
47-
*
48-
* The <user_auth_data> can be obtained from the following sign-in credentials, access key, auth token providers classs via getAuth function i.e.
49-
* CustomAuth, ServiceAuth, UserAuth, NoAuth, CustomToken, AccessToken, IDToken, LegacyToken.
50-
*
51-
* <AsyncResultCallback> - The AsyncResultCallback function for debugging.
52-
* <uid> - Optional The user defined task UID for debugging.
53-
*
54-
* 4.------------------------
55-
*
56-
* initializeApp(<AsyncClient>, <FirebaseApp>, <user_auth_data>, <timeoutMs>, <AsyncResultCallback>);
57-
*
58-
* <AsyncClient> - The async client.
59-
* <FirebaseApp> - The authentication and access token handler.
60-
* <user_auth_data> - The user auth data (user_auth_data struct) that holds the user input sign-in credentials and token.
61-
*
62-
* The <user_auth_data> can be obtained from the following sign-in credentials, access key, auth token providers classs via getAuth function i.e.
63-
* CustomAuth, ServiceAuth, UserAuth, NoAuth, CustomToken, AccessToken, IDToken, LegacyToken.
64-
*
65-
* <timeoutMs> - Optional. The await timeout in milliseconds.
66-
* <AsyncResultCallback> - Optional. The async result callback (AsyncResultCallback) for debugging.
67-
*
68-
* NOTE:
69-
*
70-
* The valid time is required for private key signing process in JWT token generation.
71-
* In case TimeStatusCallback was not assigned in the CustomAuth class constructor,
72-
* use FirebaseApp::setTime before calling initializeApp.
73-
*
74-
* The timeoutMs is the timeout for waiting the authentication process to be done.
75-
*
76-
* By providing AsyncResultCallback in the initializeApp function, the debug information will be collected and send to AsyncResultCallback
77-
* function immediately.
787
*/
798

80-
81-
// To define build options in your sketch,
82-
// adding the following macros before FirebaseClient.h
839
#define ENABLE_CUSTOM_AUTH
8410

8511
#include <FirebaseClient.h>

examples/App/AppInitialization/CustomAuthFile/CustomAuthFile.ino

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,11 @@
11
/**
2-
* ABOUT:
3-
*
42
* The bare minimum example for using user authentication with custom UID and claims.
53
*
64
* The service account JSON key file will be used in this example.
75
*
86
* The complete usage guidelines, please read README.md or visit https://github.com/mobizt/FirebaseClient
9-
*
10-
* SYNTAX:
11-
*
12-
* 1.------------------------
13-
*
14-
* CustomAuth::CustomAuth(<file_config_data>, <api_key>, <user_id>, <scope>, <claims>, <expire>);
15-
*
16-
* <file_config_data> - The filesystem data (file_config_data) obtained from FileConfig class object of service account key file.
17-
* <api_key> - The web API key of project.
18-
* <client_email> - The service account client Email.
19-
* <project_id> - The service account project ID.
20-
* <private_key> - The service account private key.
21-
* <user_id> - The unique identifier of the signed-in user must be a string, between 1-128 characters long, inclusive. Shorter uids offer better performance.
22-
* <claims> - Optional custom claims to include in the Security Rules auth / request.auth variables.
23-
* <expire> - The expiry period in seconds (less than 3600), 3300 is the default value.
24-
*
25-
* 2.------------------------
26-
*
27-
* CustomAuth::CustomAuth(<TimeStatusCallback>, <file_config_data>, <api_key>, <user_id>, <scope>, <claims>, <expire>);
28-
*
29-
* <TimeStatusCallback> - The time status callback that provide the UNIX timestamp value used for JWT token signing.
30-
* <file_config_data> - The filesystem data (file_config_data) obtained from FileConfig class object of service account key file.
31-
* <api_key> - The web API key of project.
32-
* <client_email> - The service account client Email.
33-
* <project_id> - The service account project ID.
34-
* <private_key> - The service account private key.
35-
* <user_id> - The unique identifier of the signed-in user must be a string, between 1-128 characters long, inclusive. Shorter uids offer better performance.
36-
* <claims> - Optional custom claims to include in the Security Rules auth / request.auth variables.
37-
* <expire> - The expiry period in seconds (less than 3600), 3300 is the default value.
38-
*
39-
* See examples/RealtimeDatabase/AccessControl/AccessControl.ino for how it can work with security rules for database access control.
40-
*
41-
* 3.------------------------
42-
*
43-
* initializeApp(<AsyncClient>, <FirebaseApp>, <user_auth_data>, <AsyncResultCallback>, <uid>);
44-
*
45-
* <AsyncClient> - The async client.
46-
* <FirebaseApp> - The authentication and access token handler.
47-
* <user_auth_data> - The user auth data (user_auth_data struct) that holds the user input sign-in credentials and token.
48-
*
49-
* The <user_auth_data> can be obtained from the following sign-in credentials, access key, auth token providers classs via getAuth function i.e.
50-
* CustomAuth, ServiceAuth, UserAuth, NoAuth, CustomToken, AccessToken, IDToken, LegacyToken.
51-
*
52-
* <AsyncResultCallback> - The AsyncResultCallback function for debugging.
53-
* <uid> - Optional The user defined task UID for debugging.
54-
*
55-
* 4.------------------------
56-
*
57-
* initializeApp(<AsyncClient>, <FirebaseApp>, <user_auth_data>, <timeoutMs>, <AsyncResultCallback>);
58-
*
59-
* <AsyncClient> - The async client.
60-
* <FirebaseApp> - The authentication and access token handler.
61-
* <user_auth_data> - The user auth data (user_auth_data struct) that holds the user input sign-in credentials and token.
62-
*
63-
* The <user_auth_data> can be obtained from the following sign-in credentials, access key, auth token providers classs via getAuth function i.e.
64-
* CustomAuth, ServiceAuth, UserAuth, NoAuth, CustomToken, AccessToken, IDToken, LegacyToken.
65-
*
66-
* <timeoutMs> - Optional. The await timeout in milliseconds.
67-
* <AsyncResultCallback> - Optional. The async result callback (AsyncResultCallback) for debugging.
68-
*
69-
* NOTE:
70-
*
71-
* The valid time is required for private key signing process in JWT token generation.
72-
* In case TimeStatusCallback was not assigned in the CustomAuth class constructor,
73-
* use FirebaseApp::setTime before calling initializeApp.
74-
*
75-
* The timeoutMs is the timeout for waiting the authentication process to be done.
76-
*
77-
* By providing AsyncResultCallback in the initializeApp function, the debug information will be collected and send to AsyncResultCallback
78-
* function immediately.
797
*/
808

81-
// To define build options in your sketch,
82-
// adding the following macros before FirebaseClient.h
839
#define ENABLE_CUSTOM_AUTH
8410
#define ENABLE_FS
8511

examples/App/AppInitialization/NoAuth/NoAuth.ino

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,10 @@
11
/**
2-
* ABOUT:
3-
*
42
* The bare minimum example for using non-authentication.
53
*
64
* The read and write conditions in the security rules should be true for all conditions.
75
*
86
* The complete usage guidelines, please read README.md or visit https://github.com/mobizt/FirebaseClient
97
*
10-
* SYNTAX:
11-
*
12-
* 1.------------------------
13-
*
14-
* NoAuth::NoAuth();
15-
*
16-
* 2.------------------------
17-
*
18-
* initializeApp(<AsyncClient>, <FirebaseApp>, <user_auth_data>, <AsyncResultCallback>, <uid>);
19-
*
20-
* <AsyncClient> - The async client.
21-
* <FirebaseApp> - The authentication and access token handler.
22-
* <user_auth_data> - The user auth data (user_auth_data struct) that holds the user input sign-in credentials and token.
23-
*
24-
* The <user_auth_data> can be obtained from the following sign-in credentials, access key, auth token providers classs via getAuth function i.e.
25-
* CustomAuth, ServiceAuth, UserAuth, NoAuth, CustomToken, AccessToken, IDToken, LegacyToken.
26-
*
27-
* <AsyncResultCallback> - The AsyncResultCallback function for debugging.
28-
* <uid> - Optional The user defined task UID for debugging.
29-
*
30-
* 3.------------------------
31-
*
32-
* initializeApp(<AsyncClient>, <FirebaseApp>, <user_auth_data>, <timeoutMs>, <AsyncResultCallback>);
33-
*
34-
* <AsyncClient> - The async client.
35-
* <FirebaseApp> - The authentication and access token handler.
36-
* <user_auth_data> - The user auth data (user_auth_data struct) that holds the user input sign-in credentials and token.
37-
*
38-
* The <user_auth_data> can be obtained from the following sign-in credentials, access key, auth token providers classs via getAuth function i.e.
39-
* CustomAuth, ServiceAuth, UserAuth, NoAuth, CustomToken, AccessToken, IDToken, LegacyToken.
40-
*
41-
* <timeoutMs> - Optional. The await timeout in milliseconds.
42-
* <AsyncResultCallback> - Optional. The async result callback (AsyncResultCallback) for debugging.
43-
*
44-
* NOTE:
45-
*
46-
* The timeoutMs is the timeout for waiting the authentication process to be done.
47-
*
48-
* By providing AsyncResultCallback in the initializeApp function, the debug information will be collected and send to AsyncResultCallback
49-
* function immediately.
50-
*
518
*/
529

5310
#include <FirebaseClient.h>

examples/App/AppInitialization/ReAuthenticate/ReAuthenticate.ino

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,9 @@
11
/**
2-
* ABOUT:
3-
*
42
* This is example for how to disable the re-authentication and force the authentication processes.
53
*
64
* The complete usage guidelines, please read README.md or visit https://github.com/mobizt/FirebaseClient
7-
*
8-
* SYNTAX:
9-
*
10-
* 1.------------------------
11-
*
12-
* FirebaseApp::autoRefresh(<enable>);
13-
*
14-
* <enable> - Set to true to enable auto-refresh and false for disable auto-refresh.
15-
*
16-
* 2.------------------------
17-
*
18-
* FirebaseApp::refreshToken();
19-
*
20-
* The complete usage guidelines, please visit https://github.com/mobizt/FirebaseClient
215
*/
226

23-
// To define build options in your sketch,
24-
// adding the following macros before FirebaseClient.h
257
#define ENABLE_USER_AUTH
268

279
#include <FirebaseClient.h>

examples/App/AppInitialization/SaveAndLoad/SaveAndLoad.ino

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
/**
2-
* ABOUT:
3-
*
42
* The example for storing the authentication credentials to file and loading it for later use.
53
*
64
* The complete usage guidelines, please read README.md or visit https://github.com/mobizt/FirebaseClient
75
*/
86

9-
// To define build options in your sketch,
10-
// adding the following macros before FirebaseClient.h
117
#define ENABLE_USER_AUTH
128
#define ENABLE_FS
139

examples/App/AppInitialization/ServiceAuth/ServiceAuth.ino

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,11 @@
11
/**
2-
* ABOUT:
3-
*
42
* The bare minimum example for using Firebase OAuth2.0 authentication.
53
*
64
* This example requires the service account credentials that obtains from the JSON key file.
75
*
86
* The complete usage guidelines, please read README.md or visit https://github.com/mobizt/FirebaseClient
9-
*
10-
* SYNTAX:
11-
*
12-
* 1.------------------------
13-
*
14-
* ServiceAuth::ServiceAuth(<client_email>, <project_id>, <private_key>, <expire>);
15-
*
16-
* <timestamp> - The current UNiX timestamp (seonds since Jan 1, 1970 midnight).
17-
* <client_email> - The service account client Email.
18-
* <project_id> - The service account project ID.
19-
* <private_key> - The service account private key.
20-
* <expire> - The expiry period in seconds (less than 3600), 3300 is the default value.
21-
*
22-
* 2.------------------------
23-
*
24-
* ServiceAuth::ServiceAuth(<TimeStatusCallback>, <client_email>, <project_id>, <private_key>, <expire>);
25-
*
26-
* <TimeStatusCallback> - The time status callback that provide the UNIX timestamp value used for JWT token signing.
27-
* <client_email> - The service account client Email.
28-
* <project_id> - The service account project ID.
29-
* <private_key> - The service account private key.
30-
* <expire> - The expiry period in seconds (less than 3600), 3300 is the default value.
31-
*
32-
* 3.------------------------
33-
*
34-
* initializeApp(<AsyncClient>, <FirebaseApp>, <user_auth_data>, <AsyncResultCallback>, <uid>);
35-
*
36-
* <AsyncClient> - The async client.
37-
* <FirebaseApp> - The authentication and access token handler.
38-
* <user_auth_data> - The user auth data (user_auth_data struct) that holds the user input sign-in credentials and token.
39-
*
40-
* The <user_auth_data> can be obtained from the following sign-in credentials, access key, auth token providers classs via getAuth function i.e.
41-
* CustomAuth, ServiceAuth, UserAuth, NoAuth, CustomToken, AccessToken, IDToken, LegacyToken.
42-
*
43-
* <AsyncResultCallback> - The AsyncResultCallback function for debugging.
44-
* <uid> - Optional The user defined task UID for debugging.
45-
*
46-
* 4.------------------------
47-
*
48-
* initializeApp(<AsyncClient>, <FirebaseApp>, <user_auth_data>, <timeoutMs>, <AsyncResultCallback>);
49-
*
50-
* <AsyncClient> - The async client.
51-
* <FirebaseApp> - The authentication and access token handler.
52-
* <user_auth_data> - The user auth data (user_auth_data struct) that holds the user input sign-in credentials and token.
53-
*
54-
* The <user_auth_data> can be obtained from the following sign-in credentials, access key, auth token providers classs via getAuth function i.e.
55-
* CustomAuth, ServiceAuth, UserAuth, NoAuth, CustomToken, AccessToken, IDToken, LegacyToken.
56-
*
57-
* <timeoutMs> - Optional. The await timeout in milliseconds.
58-
* <AsyncResultCallback> - Optional. The async result callback (AsyncResultCallback) for debugging.
59-
*
60-
* NOTE:
61-
*
62-
* The valid time is required for private key signing process in JWT token generation.
63-
* In case TimeStatusCallback was not assigned in the CustomAuth class constructor,
64-
* use FirebaseApp::setTime before calling initializeApp.
65-
*
66-
* The timeoutMs is the timeout for waiting the authentication process to be done.
67-
*
68-
* By providing AsyncResultCallback in the initializeApp function, the debug information will be collected and send to AsyncResultCallback
69-
* function immediately.
707
*/
718

72-
// To define build options in your sketch
739
#define ENABLE_SERVICE_AUTH
7410

7511
#include <FirebaseClient.h>

0 commit comments

Comments
 (0)