Firebase Oauth2 Bride is a development tool engineered to facilitate the integration of Firebase authentication within systems that traditionally support only OAuth2 protocols. This tool is particularly useful for environments like JetBrains IDEs (such as Rider, WebStorm, IntelliJ), which do not directly support Firebase Auth. Firebase Oauth2 Bride acts as a middle-man server that authenticates with Firebase using the "email + password" method and then formats the Firebase Auth token to match the expected OAuth2 standards.
Developers using JetBrains IDEs encounter significant hurdles when attempting to use Firebase for authentication. The IDEs' built-in HTTP clients support OAuth2 but not Firebase Auth directly, which can lead to workflow inefficiencies. Specifically, when trying to authenticate using Google's OAuth2 methods, developers face an error stating "this browser or app may not be secure" because of security restrictions on the embedded JetBrains browser (JCEF). Furthermore, Firebase Auth's token structure does not align with the OAuth2 expected format, complicating direct integration.
Firebase Oauth2 Bride solves these issues by serving as a local intermediary that handles Firebase authentication requests. It accepts credentials via a simple API, authenticates with Firebase, and returns the credentials in an OAuth2-compliant format. This setup allows developers to use their existing tools and workflows without the need for complex adaptations or manual token handling.
- Middle-Man Authentication: Handles the authentication by receiving credentials, logging into Firebase, and returning the tokens in the OAuth2 format.
- Supports "Email + Password" Authentication: Specifically designed to work with the Firebase "email + password" authentication method.
- Streamlines Development Workflow: Eliminates the need for manual token copying or regeneration by automating the token acquisition and formatting process, saving developers significant time and reducing the risk of errors.
- Easy Integration with JetBrains HTTP Client: Configured to easily integrate with the HTTP client in JetBrains IDEs, allowing for seamless development and testing within these popular development environments.
For projects specifically requiring Firebase Oauth2 Bride:
-
Install the Package:
npm install @joeyroeters/firebase-oauth2-bride
-
Configure Google Service Account:
- Create and place your Google Service Account JSON file in a desired project location.
-
Start the Server:
npm run start --prefix node_modules/@joeyroeters/firebase-oauth2-bride -- --config {{path to google service account}}
- Optionally, use the
--port
option to specify a custom port if necessary (default is3000
).
- Optionally, use the
For environments needing a more generalized setup:
-
Clone the Repository:
git clone git@github.com:JoeyRoeters/firebase-oauth2-bride.git
-
Install Dependencies:
npm install
-
Configure Google Service Account:
- Copy and fill out
config/google-service-account.json.example
with your Firebase project details.
- Copy and fill out
-
Start the Server:
npm run start
- Adjust the port using
--port
(default is3000
). - Specify a different Google Service Account file with
--config
.
- Adjust the port using
The server exposes a single endpoint for authentication, which accepts POST
requests with the following parameters:
curl --location 'http://localhost:3000/auth' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'username=example@internet.net' \
--data-urlencode 'password=example'
To set up the JetBrains HTTP client to use Firebase Oauth2 Bride, create a new environment in the client settings with the following configuration:
{
"dev-api": {
"Security": {
"Auth": {
"FirebaseAuth":
{
"Type": "OAuth2",
"Grant Type": "Password",
"Client ID": "notApplicable",
"Token URL": "http://localhost:{{port|3000=default}}/token",
"Username": "{{firebase-email}}",
"Password": "{{firebase-password}}"
}
}
}
}
}
Replace {{port}}
, {{firebase-email}}
, and {{firebase-password}}
with your actual data.
After configuring you can easily authenticate with Firebase using the JetBrains HTTP client, via "live templates", "File and Code Templates" or directly in the HTTP client. For example, to authenticate and get the token, you can use the following request:
POST http://localhost/example
Authorization: Bearer {{$auth.token("FirebaseAuth")}}
For more information on how to use the JetBrains HTTP client, refer to the official documentation.
Usage of this software is subject to the terms and conditions as defined in the LICENSE.txt file.
Note: This software is not free for redistribution or resale.