npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@joeyroeters/firebase-oauth2-bride

v1.0.2

Published

A Node.js localhost middle-man tool designed to bridge Firebase Auth with standard OAuth2 protocols, specifically tailored for JetBrains IDEs and other environments requiring OAuth2 authentication

Downloads

6

Readme

npm downloads

Firebase Oauth2 Bride

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.

Problem Statement

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.

Solution

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.

Key Features

  • 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.

Installation and Usage

As a Dev Dependency

For projects specifically requiring Firebase Oauth2 Bride:

  1. Install the Package:
    npm install @joeyroeters/firebase-oauth2-bride
  2. Configure Google Service Account:
    • Create and place your Google Service Account JSON file in a desired project location.
  3. 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 is 3000).

As an Independent Installation

For environments needing a more generalized setup:

  1. Clone the Repository:
    git clone [email protected]:JoeyRoeters/firebase-oauth2-bride.git
  2. Install Dependencies:
    npm install
  3. Configure Google Service Account:
    • Copy and fill out config/google-service-account.json.example with your Firebase project details.
  4. Start the Server:
    npm run start
    • Adjust the port using --port (default is 3000).
    • Specify a different Google Service Account file with --config.

Endpoint

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 '[email protected]' \
--data-urlencode 'password=example'

Configuring JetBrains HTTP Client

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.

License

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.