Skip to content

Commit 16b6ac0

Browse files
nmetulevelisenyang
andauthored
Renamed teams-sso-provider to teams-msal2-provider (#1298)
Co-authored-by: Elise Yang <[email protected]>
1 parent 695479b commit 16b6ac0

File tree

16 files changed

+86
-75
lines changed

16 files changed

+86
-75
lines changed

auth.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
// import { TeamsProvider } from './packages/providers/mgt-teams-provider/dist/es6/TeamsProvider.js';
1010
// TeamsProvider.handleAuth();
1111

12-
import { TeamsSSOProvider } from './packages/providers/mgt-teams-sso-provider/dist/es6/TeamsSSOProvider.js';
13-
TeamsSSOProvider.handleAuth();
12+
import { TeamsMsal2Provider } from './packages/providers/mgt-teams-msal2-provider/dist/es6/TeamsMsal2Provider.js';
13+
TeamsMsal2Provider.handleAuth();
1414
</script>
1515
</head>
1616
<body>

index.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,20 @@
2222
auth-popup-url="auth.html"
2323
></mgt-teams-provider> -->
2424

25-
<!-- <mgt-teams-sso-provider
25+
<!-- <mgt-teams-msal2-provider
2626
client-id="72482bff-ecae-44f5-8fdc-513b7f5602e7"
2727
scopes="user.read,user.read.all,mail.readBasic,people.read.all,sites.read.all,user.readbasic.all,contacts.read,presence.read,presence.read.all,tasks.readwrite,tasks.read"
2828
auth-popup-url="auth.html"
29-
></mgt-teams-sso-provider> -->
29+
></mgt-teams-msal2-provider> -->
3030

31-
<!-- Teams SSO provider in SSO mode (see "teams-sso-node" sample) -->
32-
<!-- <mgt-teams-sso-provider
31+
<!-- Teams Msal2 provider in SSO mode (see "teams-sso-node" sample) -->
32+
<!-- <mgt-teams-msal2-provider
3333
client-id="72482bff-ecae-44f5-8fdc-513b7f5602e7"
3434
scopes="user.read,user.read.all,mail.readBasic,people.read.all,sites.read.all,user.readbasic.all,contacts.read,presence.read,presence.read.all,tasks.readwrite,tasks.read"
3535
auth-popup-url="auth.html"
3636
sso-url="http://localhost:5000/api/token"
3737
http-method="POST"
38-
></mgt-teams-sso-provider> -->
38+
></mgt-teams-msal2-provider> -->
3939

4040
<!-- <mgt-msal-provider
4141
client-id="a974dfa0-9f57-49b9-95db-90f04ce2111a"

packages/mgt/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ The components are also available as [React components](https://docs.microsoft.c
3030
[Providers](https://docs.microsoft.com/graph/toolkit/providers) enable authentication and provide the implementation for acquiring access tokens on various platforms and expose a Microsoft Graph Client for calling the Microsoft Graph APIs. The components work best when used with a provider, but the providers can be used on their own.
3131

3232
* [Msal Provider](https://docs.microsoft.com/graph/toolkit/providers/msal)
33+
* [Msal2 Provider](https://docs.microsoft.com/graph/toolkit/providers/msal2)
3334
* [SharePoint Provider](https://docs.microsoft.com/graph/toolkit/providers/sharepoint)
3435
* [Teams Provider](https://docs.microsoft.com/graph/toolkit/providers/teams)
36+
* [Teams Msal2 Provider](https://docs.microsoft.com/graph/toolkit/providers/teams-msal2)
3537
* [Proxy Provider](https://docs.microsoft.com/graph/toolkit/providers/proxy)
3638
* [Simple Provider](https://docs.microsoft.com/graph/toolkit/providers/custom)
3739

packages/mgt/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"@microsoft/mgt-proxy-provider": "*",
5151
"@microsoft/mgt-sharepoint-provider": "*",
5252
"@microsoft/mgt-msal2-provider": "*",
53-
"@microsoft/mgt-teams-sso-provider": "*"
53+
"@microsoft/mgt-teams-msal2-provider": "*"
5454
},
5555
"devDependencies": {
5656
"@webcomponents/webcomponentsjs": "^2.5.0"

packages/mgt/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ export * from '@microsoft/mgt-teams-provider';
1212
export * from '@microsoft/mgt-proxy-provider';
1313
export * from '@microsoft/mgt-sharepoint-provider';
1414
export * from '@microsoft/mgt-msal2-provider';
15-
export * from '@microsoft/mgt-teams-sso-provider';
15+
export * from '@microsoft/mgt-teams-msal2-provider';

packages/providers/mgt-msal-provider/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@
22

33
[![npm](https://img.shields.io/npm/v/@microsoft/mgt-msal-provider?style=for-the-badge)](https://www.npmjs.com/package/@microsoft/mgt-msal-provider)
44

5-
The [Microsoft Graph Toolkit (mgt)](https://aka.ms/mgt) library is a collection of authentication providers and UI components powered by Microsoft Graph.
5+
⚠️⚠️⚠️ This package is no longer receiving new features and will only receive critical bug and security fixes. All new applications should use [`@microsoft/mgt-msal2-provider`](https://docs.microsoft.com/graph/toolkit/providers/msal2) instead. ⚠️⚠️⚠️
6+
7+
The `@microsoft/mgt-msal-provider` package exposes the `MsalProvider` class which uses MSAL.js to sign in users and acquire tokens to use with Microsoft Graph via the Implicit Grant Flow.
68

7-
The `@microsoft/mgt-msal-provider` package exposes the `MsalProvider` class which uses MSAL.js to sign in users and acquire tokens to use with Microsoft Graph.
9+
For authentication based on the more secure OAuth 2.0 Authorization Code Flow with PKCE, please use the [`@microsoft/mgt-msal2-provider`](https://docs.microsoft.com/graph/toolkit/providers/msal2) instead.
810

911
[See docs for full documentation of the MsalProvider](https://docs.microsoft.com/graph/toolkit/providers/msal)
1012

13+
The [Microsoft Graph Toolkit (mgt)](https://aka.ms/mgt) library is a collection of authentication providers and UI components powered by Microsoft Graph.
14+
1115
## Usage
1216

1317
1. Install the packages

packages/providers/mgt-teams-sso-provider/README.md renamed to packages/providers/mgt-teams-msal2-provider/README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
1-
# Microsoft Graph Toolkit Microsoft Teams SSO Provider
1+
# Microsoft Graph Toolkit Microsoft Teams Msal2 Provider
22

3-
[![npm](https://img.shields.io/npm/v/@microsoft/mgt-teams-sso-provider?style=for-the-badge)](https://www.npmjs.com/package/@microsoft/mgt-teams-sso-provider)
3+
[![npm](https://img.shields.io/npm/v/@microsoft/mgt-teams-msal2-provider?style=for-the-badge)](https://www.npmjs.com/package/@microsoft/mgt-teams-msal2-provider)
44

5-
The [Microsoft Graph Toolkit (mgt)](https://aka.ms/mgt) library is a collection of authentication providers and UI components powered by Microsoft Graph.
5+
The `@microsoft/mgt-teams-msal2-provider` package exposes the `TeamsMsal2Provider` class to be used inside your Microsoft Teams tab applications to authenticate users, to call Microsoft Graph, and to power the Microsoft Graph Toolkit components. The provider is built on top of [msal-browser](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-browser) and supports both the interactive sign in flow on the client and Single Sign-On (SSO) flow via your own backend. SSO mode is enabled by setting `ssoUrl` \ `sso-url` and requires a backend service to handle the on-behalf-of flow.
66

7-
The `@microsoft/mgt-teams-sso-provider` package exposes the `TeamsSSOProvider` class to be used inside your Microsoft Teams tab applications to authenticate users, to call Microsoft Graph, and to power the mgt components.
7+
[See the full documentation of the TeamsMsal2Provider](https://docs.microsoft.com/graph/toolkit/providers/teams-msal2)
88

9-
[See docs for full documentation of the TeamsSSOProvider](https://docs.microsoft.com/graph/toolkit/providers/teamssso)
9+
The [Microsoft Graph Toolkit (mgt)](https://aka.ms/mgt) library is a collection of authentication providers and UI components powered by Microsoft Graph.
1010

1111
## Usage
1212

13-
The TeamsSSOProvider requires the usage of the Microsoft Teams SDK which is not automatically installed.
13+
The TeamsMsal2Provider requires the usage of the Microsoft Teams SDK which is not automatically installed.
1414

1515
1. Install the packages
1616

1717
```bash
18-
npm install @microsoft/teams-js @microsoft/mgt-element @microsoft/mgt-teams-sso-provider
18+
npm install @microsoft/teams-js @microsoft/mgt-element @microsoft/mgt-teams-msal2-provider
1919
```
2020

2121
1. Before initializing the provider, create a new page in your application (ex: https://mydomain.com/auth) that will handle the auth redirect. Call the `handleAuth` function to handle all client side auth or permission consent.
2222

2323
```ts
2424
import * as MicrosoftTeams from "@microsoft/teams-js/dist/MicrosoftTeams";
25-
import {TeamsSSOProvider} from '@microsoft/mgt-teams-sso-provider';
25+
import {TeamsMsal2Provider} from '@microsoft/mgt-teams-msal2-provider';
2626
27-
TeamsSSOProvider.microsoftTeamsLib = MicrosoftTeams;
28-
TeamsSSOProvider.handleAuth();
27+
TeamsMsal2Provider.microsoftTeamsLib = MicrosoftTeams;
28+
TeamsMsal2Provider.handleAuth();
2929
```
3030

3131
3. Initialize the provider in your main code (not on your auth page). The provider can be used in "client side auth" mode or SSO mode. SSO mode is enabled by setting `ssoUrl` \ `sso-url` and requires a backend service to handle the on-behalf-of flow.
3232

3333
```ts
3434
import {Providers} from '@microsoft/mgt-element';
35-
import {TeamsSSOProvider} from '@microsoft/mgt-teams-sso-provider';
35+
import {TeamsMsal2Provider} from '@microsoft/mgt-teams-msal2-provider';
3636
import * as MicrosoftTeams from "@microsoft/teams-js/dist/MicrosoftTeams";
3737
38-
TeamsSSOProvider.microsoftTeamsLib = MicrosoftTeams;
38+
TeamsMsal2Provider.microsoftTeamsLib = MicrosoftTeams;
3939
40-
Providers.globalProvider = new TeamsSSOProvider({
40+
Providers.globalProvider = new TeamsMsal2Provider({
4141
clientId: string;
4242
authPopupUrl: string; // ex: "https://mydomain.com/auth" or "/auth"
4343
scopes?: string[];
@@ -53,7 +53,7 @@ The TeamsSSOProvider requires the usage of the Microsoft Teams SDK which is not
5353
```html
5454
<script type="module" src="../node_modules/@microsoft/mgt-teams-provider/dist/es6/index.js" />
5555
56-
<mgt-teams-sso-provider client-id="<YOUR_CLIENT_ID>"
56+
<mgt-teams-msal2-provider client-id="<YOUR_CLIENT_ID>"
5757
auth-popup-url="/AUTH-PATH"
5858
scopes="user.read,people.read..."
5959
authority=""

packages/providers/mgt-teams-sso-provider/package.json renamed to packages/providers/mgt-teams-msal2-provider/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "@microsoft/mgt-teams-sso-provider",
2+
"name": "@microsoft/mgt-teams-msal2-provider",
33
"version": "2.0.0",
4-
"description": "The Microsoft Graph Toolkit Teams Single Sign-On Provider",
4+
"description": "The Microsoft Graph Toolkit Teams Msal2 Provider based on Msal2 for interactive authentication on the client. The provider also supports Single Sign-On(SSO) via a dev provided backend",
55
"keywords": [
66
"microsoft graph",
77
"microsoft graph toolkit",

packages/providers/mgt-teams-sso-provider/src/TeamsSSOProvider.ts renamed to packages/providers/mgt-teams-msal2-provider/src/TeamsMsal2Provider.ts

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -86,60 +86,60 @@ interface AuthParams {
8686
}
8787

8888
/**
89-
* Interface to define the configuration when creating a TeamsSSOProvider
89+
* Interface to define the configuration when creating a TeamsMsal2Provider
9090
*
9191
* @export
92-
* @interface TeamsSSOConfig
92+
* @interface TeamsMsal2Config
9393
*/
94-
export interface TeamsSSOConfig {
94+
export interface TeamsMsal2Config {
9595
/**
9696
* The app clientId
9797
*
9898
* @type {string}
99-
* @memberof TeamsSSOConfig
99+
* @memberof TeamsMsal2Config
100100
*/
101101
clientId: string;
102102
/**
103103
* The relative or absolute path of the html page that will handle the authentication
104104
*
105105
* @type {string}
106-
* @memberof TeamsSSOConfig
106+
* @memberof TeamsMsal2Config
107107
*/
108108
authPopupUrl: string;
109109
/**
110110
* The scopes to use when authenticating the user
111111
*
112112
* @type {string[]}
113-
* @memberof TeamsSSOConfig
113+
* @memberof TeamsMsal2Config
114114
*/
115115
scopes?: string[];
116116
/**
117117
* Additional Msal configurations options to use
118118
* See Msal.js documentation for more details
119119
*
120120
* @type {Configuration}
121-
* @memberof TeamsSSOConfig
121+
* @memberof TeamsMsal2Config
122122
*/
123123
msalOptions?: Configuration;
124124
/**
125125
* The relative or absolute path to the token exchange backend service
126126
*
127127
* @type {string}
128-
* @memberof TeamsSSOConfig
128+
* @memberof TeamsMsal2Config
129129
*/
130130
ssoUrl?: string;
131131
/**
132132
* Should the provider display a consent popup automatically if needed
133133
*
134134
* @type {string}
135-
* @memberof TeamsSSOConfig
135+
* @memberof TeamsMsal2Config
136136
*/
137137
autoConsent?: boolean;
138138
/**
139139
* Should the provider display a consent popup automatically if needed
140140
*
141141
* @type {AuthMethod}
142-
* @memberof TeamsSSOConfig
142+
* @memberof TeamsMsal2Config
143143
*/
144144
httpMethod?: HttpMethod;
145145
}
@@ -148,17 +148,17 @@ export interface TeamsSSOConfig {
148148
* Enables authentication of Single page apps inside of a Microsoft Teams tab
149149
*
150150
* @export
151-
* @class TeamsSSOProvider
151+
* @class TeamsMsal2Provider
152152
* @extends {Msal2Provider}
153153
*/
154-
export class TeamsSSOProvider extends Msal2Provider {
154+
export class TeamsMsal2Provider extends Msal2Provider {
155155
/**
156156
* Gets whether the Teams provider can be used in the current context
157157
* (Whether the app is running in Microsoft Teams)
158158
*
159159
* @readonly
160160
* @static
161-
* @memberof TeamsSSOProvider
161+
* @memberof TeamsMsal2Provider
162162
*/
163163
public static get isAvailable(): boolean {
164164
return TeamsHelper.isAvailable;
@@ -170,7 +170,7 @@ export class TeamsSSOProvider extends Msal2Provider {
170170
* the microsoftTeams global variable.
171171
*
172172
* @static
173-
* @memberof TeamsSSOProvider
173+
* @memberof TeamsMsal2Provider
174174
*/
175175
public static get microsoftTeamsLib(): any {
176176
return TeamsHelper.microsoftTeamsLib;
@@ -186,22 +186,22 @@ export class TeamsSSOProvider extends Msal2Provider {
186186
* @memberof IProvider
187187
*/
188188
public get name() {
189-
return 'MgtTeamsSSOProvider';
189+
return 'MgtTeamsMsal2Provider';
190190
}
191191

192192
/**
193193
* Handle all authentication redirects in the authentication page and authenticates the user
194194
*
195195
* @static
196196
* @returns
197-
* @memberof TeamsSSOProvider
197+
* @memberof TeamsMsal2Provider
198198
*/
199199
public static async handleAuth() {
200200
// we are in popup world now - authenticate and handle it
201201
const teams = TeamsHelper.microsoftTeamsLib;
202202
if (!teams) {
203203
// tslint:disable-next-line: no-console
204-
console.error('Make sure you have referenced the Microsoft Teams sdk before using the TeamsSSOProvider');
204+
console.error('Make sure you have referenced the Microsoft Teams sdk before using the TeamsMsal2Provider');
205205
return;
206206
}
207207

@@ -282,9 +282,9 @@ export class TeamsSSOProvider extends Msal2Provider {
282282

283283
protected clientId: string;
284284

285-
private static _localStorageParametersKey = 'msg-teamsssoprovider-auth-parameters';
286-
private static _sessionStorageLoginInProgress = 'msg-teamsssoprovider-login-in-progress';
287-
private static _sessionStorageLogoutInProgress = 'msg-teamsssoprovider-logout-in-progress';
285+
private static _localStorageParametersKey = 'msg-TeamsMsal2Provider-auth-parameters';
286+
private static _sessionStorageLoginInProgress = 'msg-TeamsMsal2Provider-login-in-progress';
287+
private static _sessionStorageLogoutInProgress = 'msg-TeamsMsal2Provider-logout-in-progress';
288288

289289
private teamsContext;
290290
private _authPopupUrl: string;
@@ -294,7 +294,7 @@ export class TeamsSSOProvider extends Msal2Provider {
294294
private _autoConsent: boolean;
295295
private _httpMethod: HttpMethod;
296296

297-
constructor(config: TeamsSSOConfig) {
297+
constructor(config: TeamsMsal2Config) {
298298
super({
299299
clientId: config.clientId,
300300
loginType: LoginType.Redirect,
@@ -321,7 +321,7 @@ export class TeamsSSOProvider extends Msal2Provider {
321321
* Opens the teams authentication popup to the authentication page
322322
*
323323
* @returns {Promise<void>}
324-
* @memberof TeamsSSOProvider
324+
* @memberof TeamsMsal2Provider
325325
*/
326326
public async login(): Promise<void> {
327327
// In SSO mode the login should not be able to be run via user click
@@ -345,7 +345,7 @@ export class TeamsSSOProvider extends Msal2Provider {
345345
isConsent: this._autoConsent
346346
};
347347

348-
localStorage.setItem(TeamsSSOProvider._localStorageParametersKey, JSON.stringify(authParams));
348+
localStorage.setItem(TeamsMsal2Provider._localStorageParametersKey, JSON.stringify(authParams));
349349

350350
const url = new URL(this._authPopupUrl, new URL(window.location.href));
351351

@@ -411,7 +411,7 @@ export class TeamsSSOProvider extends Msal2Provider {
411411
*
412412
* @param {AuthenticationProviderOptions} options
413413
* @returns {Promise<string>}
414-
* @memberof TeamsSSOProvider
414+
* @memberof TeamsMsal2Provider
415415
*/
416416
public async getAccessToken(options: AuthenticationProviderOptions): Promise<string> {
417417
if (!this.teamsContext && TeamsHelper.microsoftTeamsLib) {
@@ -504,7 +504,7 @@ export class TeamsSSOProvider extends Msal2Provider {
504504
* Makes sure we can get an access token before considered logged in
505505
*
506506
* @returns {Promise<void>}
507-
* @memberof TeamsSSOProvider
507+
* @memberof TeamsMsal2Provider
508508
*/
509509
private async internalLogin(): Promise<void> {
510510
// Try to get access token
@@ -536,7 +536,7 @@ export class TeamsSSOProvider extends Msal2Provider {
536536
* Get a token via the Teams SDK
537537
*
538538
* @returns {Promise<string>}
539-
* @memberof TeamsSSOProvider
539+
* @memberof TeamsMsal2Provider
540540
*/
541541
private async getClientToken(): Promise<string> {
542542
const teams = TeamsHelper.microsoftTeamsLib;

packages/providers/mgt-teams-sso-provider/src/index.ts renamed to packages/providers/mgt-teams-msal2-provider/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
* -------------------------------------------------------------------------------------------
66
*/
77

8-
export * from './TeamsSSOProvider';
9-
export * from './mgt-teams-sso-provider';
8+
export * from './TeamsMsal2Provider';
9+
export * from './mgt-teams-msal2-provider';

0 commit comments

Comments
 (0)