Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@equinor/fusion-framework-module-azure-identity

Package Overview
Dependencies
Maintainers
4
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@equinor/fusion-framework-module-azure-identity

Fusion Framework authentication module using Azure Identity. Supports ambient credentials (DefaultAzureCredential), interactive browser login, and static token modes.

latest
Source
npmnpm
Version
0.2.0
Version published
Maintainers
4
Created
Source

@equinor/fusion-framework-module-azure-identity

Azure Identity authentication module for the Fusion Framework. Provides three authentication modes — ambient credentials, interactive browser login, and static token — all registering under the 'auth' module slot as a drop-in replacement for @equinor/fusion-framework-module-msal-node.

When to use

ScenarioMode
CI/CD with OIDC (GitHub Actions azure/login, Azure Pipelines)default_credential
Managed identity (Azure VMs, App Service, Container Apps)default_credential
Azure CLI login (az login) flowing through automaticallydefault_credential
CLI tools requiring user sign-in via browserinteractive
Scripts with a pre-obtained FUSION_TOKENtoken_only

Both this module and @equinor/fusion-framework-module-msal-node register under the 'auth' slot, so only one can be active at a time.

Install

pnpm add @equinor/fusion-framework-module-azure-identity

Quick start

Default credential (CI/CD, managed identity)

No configuration needed — credentials are resolved from the environment automatically.

import { enableAzureIdentityAuth } from '@equinor/fusion-framework-module-azure-identity';

enableAzureIdentityAuth(configurator);

Interactive browser login

Opens the user's default browser for Azure AD login. Tokens and the AuthenticationRecord are cached to the OS keychain so subsequent invocations resolve silently.

import { enableAzureIdentityInteractive } from '@equinor/fusion-framework-module-azure-identity';

enableAzureIdentityInteractive(configurator, {
  tenantId: '3aa4a235-...',
  clientId: 'a318b8e1-...',
  redirectPort: 49741,
  onOpen: (url) => console.log(`Open: ${url}`),
});

Static token

Use a pre-obtained access token. Login and logout are not supported.

import { enableAzureIdentityTokenOnly } from '@equinor/fusion-framework-module-azure-identity';

enableAzureIdentityTokenOnly(configurator, process.env.FUSION_TOKEN!);

Acquiring tokens

After initialisation, acquire tokens the same way as with the MSAL module:

const token = await framework.auth.acquireAccessToken({
  request: { scopes: ['api://my-api/.default'] },
});

Authentication modes

default_credential — ambient environment

Uses DefaultAzureCredential which tries these sources in order:

  • Environment variables (AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_FEDERATED_TOKEN_FILE, etc.)
  • Workload identity (Kubernetes pods with Azure Workload Identity)
  • Managed identity (Azure VMs, App Service, Container Apps)
  • Azure CLI (az login session)
  • Azure PowerShell (Connect-AzAccount session)
  • Azure Developer CLI (azd auth login session)

In GitHub Actions after azure/login@v3 with OIDC, option 1 is used automatically.

login() and logout() throw — there is no interactive session to manage.

interactive — browser-based login

Uses InteractiveBrowserCredential with an authorization code flow through a localhost redirect. Designed for CLI tools (ffc auth login, ffc auth token).

  • On first run, opens the browser for Azure AD login
  • Saves the AuthenticationRecord to OS-level secure storage via @azure/msal-node-extensions (Keychain on macOS, DPAPI on Windows, libsecret on Linux)
  • On subsequent runs, loads the record and acquires tokens silently from the cached credential
// Explicit login (opens browser)
const record = await framework.auth.login({
  request: { scopes: ['api://my-api/.default'] },
});
console.log('Logged in as', record.username);

// Silent token acquisition (no browser)
const token = await framework.auth.acquireAccessToken({
  request: { scopes: ['api://my-api/.default'] },
});

// Clear cached credentials
await framework.auth.logout();

token_only — static access token

Returns a pre-obtained token string. login() and logout() throw.

Token cache persistence

The module registers cachePersistencePlugin from @azure/identity-cache-persistence at load time, enabling encrypted OS-level token caching:

PlatformBackend
macOSKeychain
WindowsDPAPI
Linuxlibsecret

In interactive mode, the AuthenticationRecord (account metadata that tells the credential which cached tokens to look up) is additionally stored via @azure/msal-node-extensions secure persistence.

Configurator API

The generic enableAzureIdentityAuth accepts a callback for full control:

enableAzureIdentityAuth(configurator, (builder) => {
  // Option A — mode-specific setter
  builder.setInteractive({ tenantId, clientId, redirectPort: 49741 });

  // Option B — full config object (discriminated union)
  builder.setConfig({
    mode: 'interactive',
    tenantId,
    clientId,
    redirectPort: 49741,
  });

  // Option C — default credential (no args)
  builder.setDefaultCredential();

  // Option D — static token
  builder.setTokenOnly(token);
});

Exports

ExportDescription
enableAzureIdentityAuthGeneric enabler with configurator callback
enableAzureIdentityDefaultCredentialOne-liner enabler for default_credential mode
enableAzureIdentityInteractiveOne-liner enabler for interactive mode
enableAzureIdentityTokenOnlyOne-liner enabler for token_only mode
AzureIdentityAuthConfiguratorConfigurator class with type-safe setters
AzureIdentityAuthConfigDiscriminated union config type
InteractiveAuthOptionsOptions for interactive mode
AuthProviderDefaultCredentialProvider class for ambient credentials
AuthProviderInteractiveBrowserProvider class for browser login
AuthProviderTokenOnlyProvider class for static tokens
IAuthProviderAuth provider interface
AzureIdentityModuleModule type for generic parameters
azureIdentityModuleRaw module definition

Keywords

azure

FAQs

Package last updated on 29 Apr 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts