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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@itc-bio/vendure-entra-auth

v0.3.0

Published

Microsoft Entra ID and External ID authentication strategies for Vendure.

Readme

@itc-bio/vendure-entra-auth

Microsoft Entra ID and Microsoft Entra External ID authentication strategies for Vendure.

The package provides:

  • a Shop API strategy for customer login through an Entra External ID / CIAM tenant;
  • an Admin API strategy for dashboard users through a company Entra ID tenant;
  • a public entraAuthConfig GraphQL query that exposes only non-secret login metadata to browser UIs;
  • explicit Entra claim-to-Vendure-role mapping for administrator auto-provisioning.

Native Vendure authentication can remain enabled alongside these strategies for break-glass access.

Installation

npm install @itc-bio/vendure-entra-auth

The package expects Vendure ^3.6.0.

Vendure Config

// vendure-config.ts
import {
    EntraAuthPlugin,
    createEntraAdminAuthenticationStrategy,
    createEntraShopAuthenticationStrategy,
    parseRoleMappings,
    toPublicAuthProviderConfig,
} from '@itc-bio/vendure-entra-auth';
import { NativeAuthenticationStrategy, VendureConfig } from '@vendure/core';

const ciam = {
    issuer: process.env.ENTRA_CIAM_ISSUER!,
    clientId: process.env.ENTRA_CIAM_CLIENT_ID!,
    allowedRedirectUris: ['https://storefront.example.com/store/auth/callback'],
    scopes: ['openid', 'profile', 'email'],
    strategyName: 'entraCiam',
};

const admin = {
    issuer: process.env.ENTRA_ADMIN_ISSUER!,
    clientId: process.env.ENTRA_ADMIN_CLIENT_ID!,
    allowedRedirectUris: ['https://admin.example.com/dashboard/auth/callback'],
    roleMappings: parseRoleMappings(process.env.ENTRA_ADMIN_ROLE_MAPPINGS),
    scopes: ['openid', 'profile', 'email'],
    strategyName: 'entraAdmin',
};

export const config: VendureConfig = {
    authOptions: {
        shopAuthenticationStrategy: [
            new NativeAuthenticationStrategy(),
            createEntraShopAuthenticationStrategy({
                ...ciam,
                requireVerifiedEmail: true,
            }),
        ],
        adminAuthenticationStrategy: [
            new NativeAuthenticationStrategy(),
            createEntraAdminAuthenticationStrategy({
                ...admin,
                allowAutoCreate: false,
            }),
        ],
        // ...
    },
    plugins: [
        EntraAuthPlugin.init({
            ciam: toPublicAuthProviderConfig(ciam),
            admin: toPublicAuthProviderConfig(admin),
        }),
    ],
};

Browser Login Flow

The browser application owns the Microsoft authorization redirect:

  1. Generate state, nonce, a PKCE codeVerifier, and an S256 codeChallenge.
  2. Redirect to the configured Microsoft authorize endpoint.
  3. Receive code and state on the configured callback route.
  4. Validate state locally in the browser.
  5. Call Vendure's authenticate mutation with the authorization code, codeVerifier, redirectUri, and nonce.
  6. Let Vendure create its normal cookie or bearer-token session.

Shop API example:

mutation AuthenticateWithEntra($input: AuthenticationInput!) {
    authenticate(input: $input) {
        ... on CurrentUser {
            id
            identifier
        }
        ... on ErrorResult {
            errorCode
            message
        }
    }
}
{
    "input": {
        "entraCiam": {
            "code": "<authorization-code>",
            "codeVerifier": "<pkce-code-verifier>",
            "redirectUri": "https://storefront.example.com/store/auth/callback",
            "nonce": "<nonce>"
        }
    }
}

Admin API example:

{
    "input": {
        "entraAdmin": {
            "code": "<authorization-code>",
            "codeVerifier": "<pkce-code-verifier>",
            "redirectUri": "https://admin.example.com/dashboard/auth/callback",
            "nonce": "<nonce>"
        }
    }
}

The redirectUri must match both the Microsoft app registration and the strategy's allowedRedirectUris list.

Public Config Query

The plugin exposes non-secret login metadata so UIs do not need to hard-code tenant settings:

query EntraAuthConfig {
    entraAuthConfig {
        ciam {
            issuer
            clientId
            scopes
            strategyName
            allowedRedirectUris
        }
        admin {
            issuer
            clientId
            scopes
            strategyName
            allowedRedirectUris
        }
    }
}

The Shop API resolver returns CIAM config. The Admin API resolver returns admin config. Client secrets and token responses are never exposed.

Admin Role Mapping

Administrator auto-creation is disabled unless allowAutoCreate is set and at least one role mapping is configured.

Mappings use this syntax:

claim=value:VendureRoleCode

Examples:

groups=00000000-0000-0000-0000-000000000000:CatalogAdmin
roles=VendureAdmin:Administrator

The role code must already exist in Vendure. The plugin resolves role codes through Vendure's RoleService, so Entra configuration cannot invent new permissions.

Security Notes

  • Use authorization code flow with PKCE. Do not use implicit flow.
  • Keep native Vendure admin authentication enabled until SSO is proven and documented as your break-glass procedure.
  • Use allowedRedirectUris and allowedTenantIds in production.
  • Do not expose Microsoft token endpoint responses or ID-token claims to the browser.
  • Prefer app roles or group object IDs for admin authorization; do not grant administrator access based only on email domain.

Testing

npm test

The test suite covers claim parsing, role-code mapping, redirect allowlists, token endpoint errors, nonce mismatch, tenant allowlists, and basic claim mapping.