Skip to content

Commit c832f7c

Browse files
Merge pull request MicrosoftDocs#5 from Dickson-Mwendia/add-msal-node-overview
Draft msal node overview article
2 parents bc4f535 + 0af38ae commit c832f7c

File tree

1 file changed

+133
-2
lines changed

1 file changed

+133
-2
lines changed

nodejs/overview/overview.md

Lines changed: 133 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,137 @@ title: Overview
33
author: Dickson-Mwendia
44
---
55

6-
# Overview
6+
# Microsoft Authentication Library for Node (MSAL Node)
77

8-
Overview page.
8+
MSAL Node enables applications to authenticate users using [Azure AD](https://docs.microsoft.com/azure/active-directory/develop/v2-overview) work and school accounts, Microsoft personal accounts (MSA) and social identity providers like Facebook, Google, LinkedIn, and Microsoft accounts through [Azure AD B2C](https://docs.microsoft.com/azure/active-directory-b2c/active-directory-b2c-overview#identity-providers) service. It also enables your app to get tokens to access [Microsoft Cloud](https://www.microsoft.com/enterprise) services such as [Microsoft Graph](https://graph.microsoft.io).
9+
10+
### Supported OAuth2.0 grant types
11+
12+
The current version supports the following ways of acquiring tokens:
13+
14+
#### Public Client:
15+
16+
- [Authorization Code Grant](https://oauth.net/2/grant-types/authorization-code/) with [PKCE](https://oauth.net/2/pkce/)
17+
- [Device Code Grant](https://oauth.net/2/grant-types/device-code/)
18+
- [Refresh Token Grant](https://oauth.net/2/grant-types/refresh-token/)
19+
- [Silent Flow](https://docs.microsoft.com/azure/active-directory/develop/msal-acquire-cache-tokens#acquiring-tokens-silently-from-the-cache)
20+
- [Username and Password flow](https://docs.microsoft.com/azure/active-directory/develop/msal-authentication-flows#usernamepassword)
21+
22+
#### Confidential Client:
23+
24+
- [Authorization Code Grant](https://oauth.net/2/grant-types/authorization-code/) with a client credential
25+
- [Refresh Token Grant](https://oauth.net/2/grant-types/refresh-token/)
26+
- [Silent Flow](https://docs.microsoft.com/azure/active-directory/develop/msal-acquire-cache-tokens#acquiring-tokens-silently-from-the-cache)
27+
- [Client Credential Grant](https://oauth.net/2/grant-types/client-credentials/)
28+
- [On-behalf-of flow](https://docs.microsoft.com/azure/active-directory/develop/v2-oauth2-on-behalf-of-flow)
29+
- [Username and Password flow](https://docs.microsoft.com/azure/active-directory/develop/msal-authentication-flows#usernamepassword)
30+
31+
More details on different grant types supported by Microsoft authentication libraries in general can be found in [MSAL authentication flows](https://docs.microsoft.com/azure/active-directory/develop/msal-authentication-flows).
32+
33+
### Supported application scenarios
34+
35+
MSAL Node supports the following application scenarios:
36+
37+
- Desktop app that calls web APIs
38+
- Web app that calls web APIs
39+
- Web APIs that call web APIs
40+
- Daemon apps
41+
42+
Learn more about the application scenarios that MSAL Node supports in the [scenarios and authentication flows article](https://docs.microsoft.com/azure/active-directory/develop/authentication-flows-app-scenarios).
43+
44+
## Prerequisites
45+
46+
Before using `@azure/msal-node` you will need to register your app in the Azure portal. Follow thee steps in [App registration](https://docs.microsoft.com/graph/auth-register-app-v2) to register your application in the Azure portal.
47+
48+
## Installation
49+
50+
To install MSAL Node using npm, use the following commands:
51+
52+
```javascript
53+
npm install @azure/msal-node
54+
```
55+
56+
## Usage
57+
58+
### MSAL basics
59+
- [Understand difference in between Public Client and Confidential Clients](https://docs.microsoft.com/azure/active-directory/develop/msal-client-applications)
60+
- [Initialize a Public Client Application](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-node/docs/initialize-public-client-application.md)
61+
- [Initialize a Confidential Client Application](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-node/docs/initialize-confidential-client-application.md)
62+
- [Configuration](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-node/docs/configuration.md)
63+
- [Request](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-common/docs/request.md)
64+
- [Response](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-common/docs/Response.md)
65+
66+
## Samples
67+
68+
There are multiple [samples](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples/msal-node-samples) on GitHub that use MSAL Node to acquire tokens. Developers can use these sample apps for learning and testing purposes.
69+
70+
- [auth-code](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples/msal-node-samples/auth-code): Express app using OAuth2.0 authorization code flow.
71+
- [auth-code-pkce](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples/msal-node-samples/auth-code-pkce): Express app using OAuth2.0 authorization code flow with PKCE.
72+
- [device-code](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples/msal-node-samples/device-code): Command line app using OAuth 2.0 device code flow.
73+
- [refresh-token](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples/msal-node-samples/refresh-token): Command line app using OAuth 2.0 refresh flow.
74+
- [silent-flow](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples/msal-node-samples/silent-flow): Express app using OAuth2.0 authorization code flow to acquire a token and store in the token cache, and silent flow to use tokens in the token cache.
75+
- [client-credentials](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples/msal-node-samples/client-credentials): Daemon app using OAuth 2.0 client credential grant to acquire a token.
76+
- [on-behalf-of](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples/msal-node-samples/on-behalf-of): Web application using OAuth 2.0 auth code flow to acquire a token for a web API. The web API validates the token, and calls Microsoft Graph on behalf of the user who authenticated in the web application.
77+
- [username-password](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples/msal-node-samples/username-password): Web application using OAuth 2.0 resource owner password credentials (ROPC) flow to acquire a token for a web API.
78+
- [ElectronTestApp](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples/msal-node-samples/ElectronTestApp): Electron desktop application using OAuth 2.0 auth code with PKCE flow to acquire a token for a web API such as Microsoft Graph.
79+
- [ExpressTestApp](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples/msal-node-samples/ExpressTestApp): Express.js MVC web application using OAuth 2.0 auth code with PKCE flow to acquire a token for a web API such as Microsoft Graph.
80+
- [Hybrid SPA sample](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples/msal-browser-samples/HybridSample): Sample demonstrating how to use `enableSpaAuthorizationCode` to perform SSO for applications that leverage server-side and client-side authentication using MSAL Browser and MSAL Node.
81+
82+
B2C samples:
83+
84+
- [b2c-user-flows](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples/msal-node-samples/b2c-user-flows): Express app using OAuth2.0 authorization code flow.
85+
- [ms-identity-b2c-javascript-nodejs-management](https://github.com/Azure-Samples/ms-identity-b2c-javascript-nodejs-management/tree/main/Chapter2): Command line app using OAuth 2.0 client credentials flow for performing user management operations on an Azure AD / Azure AD B2C tenant
86+
87+
Others:
88+
89+
- [msal-node-extensions](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/extensions/samples/msal-node-extensions): Uses authorization code flow to acquire tokens and the [msal-extensions](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/extensions/) library to write the MSAL in-memory token cache to disk.
90+
91+
## Build and test
92+
93+
- If you don't have [lerna](https://github.com/lerna/lerna) installed, run `npm install -g lerna`
94+
- Run `lerna bootstrap` from anywhere within `microsoft-authentication-library-for-js.git`.
95+
- Navigate to `microsoft-authentication-library-for-js/lib/msal-common` and run `npm run build`
96+
- Navigate to `microsoft-authentication-library-for-js/lib/msal-node` and run `npm run build`
97+
98+
```javascript
99+
// to link msal-node and msal-common packages
100+
lerna bootstrap
101+
102+
// Change to the msal-node package directory
103+
cd lib/msal-common/
104+
105+
// To run build only for node package
106+
npm run build
107+
108+
// Change to the msal-node package directory
109+
cd lib/msal-node/
110+
111+
// To run build only for node package
112+
npm run build
113+
```
114+
115+
### Local development
116+
117+
Below is a list of commands you will probably find useful:
118+
119+
#### `npm run build:modules:watch`
120+
Runs the project in development/watch mode. Your project will be rebuilt upon changes. TSDX has a special logger for you convenience. Error messages are pretty printed and formatted for compatibility VS Code's Problems tab. The library will be rebuilt if you make edits.
121+
122+
#### `npm run build`
123+
Bundles the package to the `dist` folder.
124+
The package is optimized and bundled with Rollup into multiple formats (CommonJS, UMD, and ES Module).
125+
126+
#### `lerna bootstrap`
127+
If you are running the project in development/watch mode, or have made changes in `msal-common` and need them reflecting across the project, please run `lerna bootstrap` to link all the symbols. Please note that `npm install` will unlink all the code, hence it is advised to run `lerna bootstrap` post installation.
128+
129+
#### `npm run lint`
130+
Runs eslint with Prettier
131+
132+
#### `npm test`, `npm run test:coverage`, `npm run test:watch`
133+
Runs the test watcher (Jest) in an interactive mode.
134+
By default, runs tests related to files changed since the last commit.
135+
Generate code coverage by adding the flag --coverage. No additional setup needed. Jest can collect code coverage information from entire projects, including untested files.
136+
137+
## Reporting security issues
138+
139+
If you find a security issue with our libraries or services please report it to [[email protected]](mailto:[email protected]) with as much detail as possible. Your submission may be eligible for a bounty through the [Microsoft Bounty](https://aka.ms/bugbounty) program. Please do not post security issues to GitHub Issues or any other public site. We will contact you shortly upon receiving the information. We encourage you to get notifications of when security incidents occur by visiting [this page](https://technet.microsoft.com/security/dd252948) and subscribing to Security Advisory Alerts.

0 commit comments

Comments
 (0)