編集

次の方法で共有


@azure/msal-node package

Classes

NodeStorage

This class implements Storage for node, reading cache from user specified storage location or an extension library

TokenCache

In-memory token cache manager

DistributedCachePlugin
Deserializer

This class deserializes cache entities read from the file into in memory object types defined internally

Serializer
ClientApplication

Base abstract class for all ClientApplications - public and confidential

ClientAssertion

Client assertion of type jwt-bearer used in confidential client flows

ConfidentialClientApplication

This class is to be used to acquire tokens for confidential client applications (webApp, webAPI). Confidential client applications will configure application secrets, client certificates/assertions as applicable

PublicClientApplication

This class is to be used to acquire tokens for public client applications (desktop, mobile). Public client applications are not trusted to safely store application secrets, and therefore can only request tokens in the name of an user.

CryptoProvider

This class implements MSAL node's crypto interface, which allows it to perform base64 encoding and decoding, generating cryptographically random GUIDs and implementing Proof Key for Code Exchange specs for the OAuth Authorization Code Flow using PKCE (rfc here: https://tools.ietf.org/html/rfc7636).

GuidGenerator
HashUtils
PkceGenerator

https://tools.ietf.org/html/rfc7636#page-8

NodeAuthError
HttpClient

This class implements the API for network requests.

LoopbackClient
EncodingUtils
NetworkUtils

Interfaces

ITokenCache

Token cache interface for the client, giving access to cache APIs

ICacheClient
IPartitionManager
IConfidentialClientApplication

Interface for the ConfidentialClientApplication class defining the public API signatures

IPublicClientApplication

Interface for the PublicClientApplication class defining the public API signatures

Type Aliases

CacheKVStore

Key value store for in-memory cache

InMemoryCache

Intermittent type to handle in-memory data objects with defined types

JsonCache

Cache format read from the cache blob provided to the configuration during app instantiation

SerializedAccessTokenEntity

Access token credential type

SerializedAccountEntity

Account type

SerializedAppMetadataEntity

AppMetadata type

SerializedIdTokenEntity

Idtoken credential type

SerializedRefreshTokenEntity

Refresh token credential type

CacheOptions

Use this to configure the below cache configuration options:

  • cachePlugin - Plugin for reading and writing token cache to disk.
Configuration

Use the configuration object to configure MSAL and initialize the client application object

  • auth: this is where you configure auth elements like clientID, authority used for authenticating against the Microsoft Identity Platform
  • cache: this is where you configure cache location
  • system: this is where you can configure the network client, logger
NodeAuthOptions
  • clientId - Client id of the application.
  • authority - Url of the authority. If no value is set, defaults to https://login.microsoftonline.com/common.
  • knownAuthorities - Needed for Azure B2C and ADFS. All authorities that will be used in the client application. Only the host of the authority should be passed in.
  • clientSecret - Secret string that the application uses when requesting a token. Only used in confidential client applications. Can be created in the Azure app registration portal.
  • clientAssertion - Assertion string that the application uses when requesting a token. Only used in confidential client applications. Assertion should be of type urn:ietf:params:oauth:client-assertion-type:jwt-bearer.
  • clientCertificate - Certificate that the application uses when requesting a token. Only used in confidential client applications. Requires hex encoded X.509 SHA-1 thumbprint of the certificiate, and the PEM encoded private key (string should contain -----BEGIN PRIVATE KEY----- ... -----END PRIVATE KEY----- )
  • protocolMode - Enum that represents the protocol that msal follows. Used for configuring proper endpoints.
  • skipAuthorityMetadataCache - A flag to choose whether to use or not use the local metadata cache during authority initialization. Defaults to false.
NodeConfiguration
NodeSystemOptions

Type for configuring logger and http client options

  • logger - Used to initialize the Logger object; TODO: Expand on logger details or link to the documentation on logger
  • networkClient - Http client used for all http get and post calls. Defaults to using MSAL's default http client.
NodeTelemetryOptions
AuthorizationCodeRequest

Request object passed by user to acquire a token from the server exchanging a valid authorization code (second leg of OAuth2.0 Authorization Code flow)

  • scopes - Array of scopes the application is requesting access to.
  • claims - A stringified claims request which will be added to all /authorize and /token calls
  • authority: - URL of the authority, the security token service (STS) from which MSAL will acquire tokens. If authority is set on client application object, this will override that value. Overriding the value will cause for authority validation to happen each time. If the same authority will be used for all request, set on the application object instead of the requests.
  • correlationId - Unique GUID set per request to trace a request end-to-end for telemetry purposes.
  • redirectUri - The redirect URI of your app, where the authority will redirect to after the user inputs credentials and consents. It must exactly match one of the redirect URIs you registered in the portal.
  • tokenQueryParameters - String to string map of custom query parameters added to the /token call
  • code - The authorization_code that the user acquired in the first leg of the flow.
  • codeVerifier - The same code_verifier that was used to obtain the authorization_code. Required if PKCE was used in the authorization code grant request.For more information, see the PKCE RFC: https://tools.ietf.org/html/rfc7636
  • state - Unique GUID generated by the user that is cached by the user and sent to the server during the first leg of the flow. This string is sent back by the server with the authorization code. The user cached state is then compared with the state received from the server to mitigate the risk of CSRF attacks. See https://datatracker.ietf.org/doc/html/rfc6819#section-3.6.
AuthorizationUrlRequest

Request object passed by user to retrieve a Code from the server (first leg of authorization code grant flow)

  • scopes - Array of scopes the application is requesting access to.
  • claims - A stringified claims request which will be added to all /authorize and /token calls
  • authority - Url of the authority which the application acquires tokens from.
  • correlationId - Unique GUID set per request to trace a request end-to-end for telemetry purposes.
  • redirectUri - The redirect URI where authentication responses can be received by your application. It must exactly match one of the redirect URIs registered in the Azure portal.
  • extraScopesToConsent - Scopes for a different resource when the user needs consent upfront.
  • responseMode - Specifies the method that should be used to send the authentication result to your app. Can be query, form_post, or fragment. If no value is passed in, it defaults to query.
  • codeChallenge - Used to secure authorization code grant via Proof of Key for Code Exchange (PKCE). For more information, see the PKCE RCF:https://tools.ietf.org/html/rfc7636
  • codeChallengeMethod - The method used to encode the code verifier for the code challenge parameter. Can be "plain" or "S256". If excluded, code challenge is assumed to be plaintext. For more information, see the PKCE RCF: https://tools.ietf.org/html/rfc7636
  • state - A value included in the request that is also returned in the token response. A randomly generated unique value is typically used for preventing cross site request forgery attacks. The state is also used to encode information about the user's state in the app before the authentication request occurred.
  • prompt - Indicates the type of user interaction that is required. login: will force the user to enter their credentials on that request, negating single-sign on none: will ensure that the user isn't presented with any interactive prompt. if request can't be completed via single-sign on, the endpoint will return an interaction_required error consent: will the trigger the OAuth consent dialog after the user signs in, asking the user to grant permissions to the app select_account: will interrupt single sign-=on providing account selection experience listing all the accounts in session or any remembered accounts or an option to choose to use a different account create: will direct the user to the account creation experience instead of the log in experience
  • account - AccountInfo obtained from a getAccount API. Will be used in certain scenarios to generate login_hint if both loginHint and sid params are not provided.
  • loginHint - Can be used to pre-fill the username/email address field of the sign-in page for the user, if you know the username/email address ahead of time. Often apps use this parameter during re-authentication, having already extracted the username from a previous sign-in using the preferred_username claim.
  • sid - Session ID, unique identifier for the session. Available as an optional claim on ID tokens.
  • domainHint - Provides a hint about the tenant or domain that the user should use to sign in. The value of the domain hint is a registered domain for the tenant.
  • extraQueryParameters - String to string map of custom query parameters added to the /authorize call
  • tokenQueryParameters - String to string map of custom query parameters added to the /token call
  • nonce - A value included in the request that is returned in the id token. A randomly generated unique value is typically used to mitigate replay attacks.
ClientCredentialRequest

CommonClientCredentialRequest

  • scopes - Array of scopes the application is requesting access to.
  • authority - URL of the authority, the security token service (STS) from which MSAL will acquire tokens.
  • correlationId - Unique GUID set per request to trace a request end-to-end for telemetry purposes.
  • skipCache - Skip token cache lookup and force request to authority to get a a new token. Defaults to false.
  • clientAssertion - A Base64Url-encoded signed JWT assertion string used in the Client Credential flow
DeviceCodeRequest

Parameters for Oauth2 device code flow.

  • scopes - Array of scopes the application is requesting access to.
  • authority: - URL of the authority, the security token service (STS) from which MSAL will acquire tokens. If authority is set on client application object, this will override that value. Overriding the value will cause for authority validation to happen each time. If the same authority will be used for all request, set on the application object instead of the requests.
  • correlationId - Unique GUID set per request to trace a request end-to-end for telemetry purposes.
  • deviceCodeCallback - Callback containing device code response. Message should be shown to end user. End user can then navigate to the verification_uri, input the user_code, and input credentials.
  • cancel - Boolean to cancel polling of device code endpoint. While the user authenticates on a separate device, MSAL polls the the token endpoint of security token service for the interval specified in the device code response (usually 15 minutes). To stop polling and cancel the request, set cancel=true.
InteractiveRequest
OnBehalfOfRequest
  • scopes - Array of scopes the application is requesting access to.
  • authority - URL of the authority, the security token service (STS) from which MSAL will acquire tokens.
  • correlationId - Unique GUID set per request to trace a request end-to-end for telemetry purposes.
  • oboAssertion - The access token that was sent to the middle-tier API. This token must have an audience of the app making this OBO request.
  • skipCache - Skip token cache lookup and force request to authority to get a a new token. Defaults to false.
RefreshTokenRequest

CommonRefreshTokenRequest

  • scopes - Array of scopes the application is requesting access to.
  • claims - A stringified claims request which will be added to all /authorize and /token calls
  • authority - URL of the authority, the security token service (STS) from which MSAL will acquire tokens.
  • correlationId - Unique GUID set per request to trace a request end-to-end for telemetry purposes.
  • refreshToken - A refresh token returned from a previous request to the Identity provider.
  • tokenQueryParameters - String to string map of custom query parameters added to the /token call
  • forceCache - Force MSAL to cache a refresh token flow response when there is no account in the cache. Used for migration scenarios.
SilentFlowRequest

SilentFlow parameters passed by the user to retrieve credentials silently

  • scopes - Array of scopes the application is requesting access to.
  • claims - A stringified claims request which will be added to all /authorize and /token calls. When included on a silent request, cache lookup will be skipped and token will be refreshed.
  • authority - Url of the authority which the application acquires tokens from.
  • correlationId - Unique GUID set per request to trace a request end-to-end for telemetry purposes.
  • tokenQueryParameters - String to string map of custom query parameters added to the /token call
  • account - Account entity to lookup the credentials.
  • forceRefresh - Forces silent requests to make network calls if true.
UsernamePasswordRequest

UsernamePassword parameters passed by the user to retrieve credentials Note: The latest OAuth 2.0 Security Best Current Practice disallows the password grant entirely. This flow is added for internal testing.

  • scopes - Array of scopes the application is requesting access to.
  • claims - A stringified claims request which will be added to all /authorize and /token calls. When included on a silent request, cache lookup will be skipped and token will be refreshed.
  • authority - Url of the authority which the application acquires tokens from.
  • correlationId - Unique GUID set per request to trace a request end-to-end for telemetry purposes.
  • username - username of the client
  • password - credentials

Enums

ApiId

API Codes for Telemetry purposes. Before adding a new code you must claim it in the MSAL Telemetry tracker as these number spaces are shared across all MSALs 0-99 Silent Flow 600-699 Device Code Flow 800-899 Auth Code Flow

HttpMethod

http methods

HttpStatus
ProxyStatus

Functions

buildAppConfiguration({ auth: { authority?: string, authorityMetadata?: string, azureCloudOptions?: AzureCloudOptions, clientAssertion?: string, clientCapabilities?: Array<string>, clientCertificate?: { privateKey: string, thumbprint: string, x5c?: string }, clientId: string, clientSecret?: string, cloudDiscoveryMetadata?: string, knownAuthorities?: Array<string>, protocolMode?: ProtocolMode, skipAuthorityMetadataCache?: boolean }, cache: { cachePlugin?: ICachePlugin }, system: { loggerOptions?: LoggerOptions, networkClient?: INetworkModule, proxyUrl?: string }, telemetry: { application?: ApplicationTelemetry } })

Sets the default options when not explicitly configured from app developer

Function Details

buildAppConfiguration({ auth: { authority?: string, authorityMetadata?: string, azureCloudOptions?: AzureCloudOptions, clientAssertion?: string, clientCapabilities?: Array<string>, clientCertificate?: { privateKey: string, thumbprint: string, x5c?: string }, clientId: string, clientSecret?: string, cloudDiscoveryMetadata?: string, knownAuthorities?: Array<string>, protocolMode?: ProtocolMode, skipAuthorityMetadataCache?: boolean }, cache: { cachePlugin?: ICachePlugin }, system: { loggerOptions?: LoggerOptions, networkClient?: INetworkModule, proxyUrl?: string }, telemetry: { application?: ApplicationTelemetry } })

Sets the default options when not explicitly configured from app developer

function buildAppConfiguration(__namedParameters: { auth: { authority?: string, authorityMetadata?: string, azureCloudOptions?: AzureCloudOptions, clientAssertion?: string, clientCapabilities?: Array<string>, clientCertificate?: { privateKey: string, thumbprint: string, x5c?: string }, clientId: string, clientSecret?: string, cloudDiscoveryMetadata?: string, knownAuthorities?: Array<string>, protocolMode?: ProtocolMode, skipAuthorityMetadataCache?: boolean }, cache: { cachePlugin?: ICachePlugin }, system: { loggerOptions?: LoggerOptions, networkClient?: INetworkModule, proxyUrl?: string }, telemetry: { application?: ApplicationTelemetry } }): NodeConfiguration

Parameters

__namedParameters

{ auth: { authority?: string, authorityMetadata?: string, azureCloudOptions?: AzureCloudOptions, clientAssertion?: string, clientCapabilities?: Array<string>, clientCertificate?: { privateKey: string, thumbprint: string, x5c?: string }, clientId: string, clientSecret?: string, cloudDiscoveryMetadata?: string, knownAuthorities?: Array<string>, protocolMode?: ProtocolMode, skipAuthorityMetadataCache?: boolean }, cache: { cachePlugin?: ICachePlugin }, system: { loggerOptions?: LoggerOptions, networkClient?: INetworkModule, proxyUrl?: string }, telemetry: { application?: ApplicationTelemetry } }

Returns

Configuration