Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@microsoft/mgt-msal2-provider
Advanced tools
The Microsoft Graph Toolkit (mgt) library is a collection of authentication providers and UI components powered by Microsoft Graph.
The @microsoft/mgt-msal2-provider
package exposes the Msal2Provider
class which uses msal-browser to sign in users and acquire tokens to use with Microsoft Graph. This provider also supports multiple account logins.
Install the packages
npm install @microsoft/mgt-element @microsoft/mgt-msal2-provider
Initialize the provider in code with Msal2Config
import {Providers, LoginType} from '@microsoft/mgt-element';
import {Msal2Provider, PromptType} from '@microsoft/mgt-msal2-provider/dist/es6/exports';
// initialize the auth provider globally
Providers.globalProvider = new Msal2Provider({
clientId: 'clientId',
scopes?: string[],
authority?: string,
redirectUri?: string,
loginType?: LoginType, // LoginType.Popup or LoginType.Redirect (redirect is default)
prompt?: PromptType, // PromptType.CONSENT, PromptType.LOGIN or PromptType.SELECT_ACCOUNT
sid?: string, // Session ID
loginHint?: string,
domainHint?: string,
isMultiAccountEnabled?: boolean, // True by default, disables multiple account login if false
isIncrementalConsentDisabled?: boolean, //Disable incremental consent, true by default
isMultiAccountEnabled?: boolean // True by default, disables multiple account login if false
isIncrementalConsentDisabled?: boolean, //Disable incremental consent, true by default
options?: Configuration // msal js Configuration object
});
Initialize the provider in code with Msal2PublicClientApplicationConfig
if a PublicClientApplication
is already instantiated. For example, msal-angular
instantiates PublicClientApplication
on startup.
import {Providers, LoginType} from '@microsoft/mgt-element';
import {Msal2Provider, PromptType} from '@microsoft/mgt-msal2-provider/dist/es6/exports';
import {PublicClientApplication} from '@azure/msal-browser';
// initialize the auth provider globally
Providers.globalProvider = new Msal2Provider({
publicClientApplication: PublicClientApplication,
scopes?: string[],
authority?: string,
redirectUri?: string,
loginType?: LoginType, // LoginType.Popup or LoginType.Redirect (redirect is default)
prompt?: PromptType, // PromptType.CONSENT, PromptType.LOGIN or PromptType.SELECT_ACCOUNT
sid?: string, // Session ID
loginHint?: string,
domainHint?: string,
isMultiAccountEnabled?: boolean, // True by default, disables multiple account login if false
isIncrementalConsentDisabled?: boolean, //Disable incremental consent, true by default
});
Alternatively, initialize the provider in html (only client-id
is required):
<script type="module" src="../node_modules/@microsoft/mgt-msal2-provider/dist/es6/index.js" />
<mgt-msal2-provider client-id="<YOUR_CLIENT_ID>"
login-type="redirect/popup"
scopes="user.read,people.read"
redirect-uri="https://my.redirect/uri"
authority=""
login-hint=""
domain-hint="">
</mgt-msal2-provider>
Add the incremental-consent-disabled
boolean attribute if you wish to disable incremental consent.
Multi account login functionality is enabled by default. It can be disabled by adding the boolean attribute multi-account-disabled
in the html:
<script type="module" src="../node_modules/@microsoft/mgt-msal2-provider/dist/es6/index.js" />
<mgt-msal2-provider client-id="<YOUR_CLIENT_ID>"
login-type="redirect/popup"
scopes="user.read,people.read"
redirect-uri="https://my.redirect/uri"
authority=""
multi-account-disabled>
</mgt-msal2-provider>
It can also be enabled/disabled in the Msal2Config
object:
import {Providers, LoginType} from '@microsoft/mgt-element';
import {Msal2Provider, PromptType} from '@microsoft/mgt-msal2-provider/dist/es6/exports';
// initialize the auth provider globally
Providers.globalProvider = new Msal2Provider({
clientId: 'clientId',
isMultiAccountEnabled?: false
});
This feature allows multiple accounts to be signed in at the same time, and the user has the ability to switch between the signed in accounts.
See provider usage documentation to learn about how to use the providers with the mgt components, to sign in/sign out, get access tokens, call Microsoft Graph, and more.
4.0.0 (2024-02-05)
@microsoft/mgt-components
. Importing from the root of @microsoft/mgt-components
no longer has an automatic registration side effect. NOTE Components from @microsoft/mgt-react
will automatically register the underlying web component when they are used for the first time.@microsoft/mgt-react
but not using the wrapper components will not have components automatically registered in the browser. This leads to a breaking change when these applications emit raw web component markup rather than using the wrapper components.@lit/task
to schedule async data fetching (#2912) (14a96ff)FAQs
The Microsoft Graph Toolkit Msal 2.0 Provider
The npm package @microsoft/mgt-msal2-provider receives a total of 5,926 weekly downloads. As such, @microsoft/mgt-msal2-provider popularity was classified as popular.
We found that @microsoft/mgt-msal2-provider demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.