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

fb-ms-approles

v0.2.0

Published

This project has the basic logic needed to sync the application roles assigned to a user in Microsoft Azure AD to the roles in the Firebase token upon login on that user using Firebase Authentication.

Downloads

7

Readme

README

This project has the basic logic needed to sync the application roles assigned to a user in Microsoft Azure AD to the roles in the Firebase token upon login on that user using Firebase Authentication.

What is this repository for?

  • Quick summary

When using Firebase Authentication using Microsoft, it is convenient to be able to use the Application Roles defined in Azure AD in the Firebase token. Natively, these roles are not present in the Firebase JWT token. This project includes the logic for a Firebase function defined as an Auth trigger to transfer these roles to the Firebase token and keep it updated.

Note that this requires the Blocking Functions functionality of Firebase, which is not included in the Free plan. However, given if you use Microsoft Azure AD, you probably have an Enterprise license anyway, so this shouldn't be an issue.

  • Version

This is version 0.1.1

How do I get set up?

  • Summary of set up:

To set up this library you need to include it as a dependency and expose a Firebase function created by this library using one of the two ways provided. You can either use the default setup of this hook, using the beforeSignIn function exposed by this library. Alternatively, in case you need more flexibility in configuring the hook, you can use the firebaseMsAppRoleHook method which has an options object as parameter (see Configuration below).

A full example:

import {beforeSignIn} from "fb-ms-approles";
exports.beforeSignIn = beforeSignIn;
  • Configuration

To configure the authentication hook (using firebaseMsAppRoleHook), you can pass an options object into this function:

type CustomHook<TokenType extends AccessTokenWithRole = AccessTokenWithRole> = (token: TokenType) => object;

interface HookOptions<TokenType extends AccessTokenWithRole = AccessTokenWithRole> {
    /**
     * Instructs the hook to log sensitive data (i.e. the full event context including the users' JWT token
     * provided by Microsoft. This can be used for debugging purposes, but should not be used in production.
     */
    includeSensitive: boolean,
    /**
     * Configure the field to store the application roles from the MS Token in, in the Firebase JWT token.
     */
    rolesField: string
    /**
     * Additional hook function to perform custom transformation of the Firebase JWT token based on the MS Token.
     */
    customHook?: CustomHook<TokenType>;
}

If you only want to specify the customHook and use the otherwise configured defaults, use beforeSignInWithHook.

  • Dependencies

This function depends on Firebase Functions

  • Deployment instructions:

During deployment, you need to manually select this function as the blocking function for the beforeSignIn() event. Also note that you need to include the ID Token in the "Additional provider token credentials" section. This allows the hook to access the original users' JWT token provided from MicroSoft, from which the app roles will be read. Failing to enable this will result in the function logging an error upon each invocation.

Note that we noticed during usage of this function, the ID Token setting may be deselected in case the function itself is redeployed. In this case, you will see the errors mentioned in the logging, even thought THE SETTING IS STILL SELECTED IN THE FIREBASE UI. This can be resolved by deselecting the setting, saving, reselecting the setting and saving again.

Contribution guidelines

  • Writing tests: TODO: Not yet provided by Firebase yet.
  • Code review
  • Other guidelines

Who do I talk to?

  • Repo owner or admin

The owner of this repo is Jeroen Benckhuijsen (jeroen.benckhuijsen at group9 dot nl)

  • Other community or team contact