Skip to content

Commit b925b28

Browse files
authored
Pass all scopes in token request and update IndividualLocalAuth template (#26232)
* Pass all scopes in token request and update IndividualLocalAuth template * Fix build and address feedback from peer review
1 parent 650bbeb commit b925b28

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

src/Components/Web.JS/dist/Release/blazor.server.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Components/Web.JS/dist/Release/blazor.webassembly.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Components/WebAssembly/Authentication.Msal/src/Interop/AuthenticationService.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class MsalAuthorizeService implements AuthorizeService {
5454
private readonly _msalApplication: Msal.PublicClientApplication;
5555
private _account: Msal.AccountInfo | undefined;
5656
private _redirectCallback: Promise<AuthenticationResult | null> | undefined;
57+
private _requestedScopes: string[] | undefined;
5758

5859
constructor(private readonly _settings: AuthorizeServiceConfiguration) {
5960
if (this._settings.auth?.knownAuthorities?.length == 0) {
@@ -81,10 +82,23 @@ class MsalAuthorizeService implements AuthorizeService {
8182
return;
8283
}
8384

85+
const scopes: string[] = [];
86+
if (this._settings.defaultAccessTokenScopes && this._settings.defaultAccessTokenScopes.length > 0) {
87+
scopes.push(...this._settings.defaultAccessTokenScopes)
88+
}
89+
90+
if (this._settings.additionalScopesToConsent && this._settings.additionalScopesToConsent.length > 0) {
91+
scopes.push(...this._settings.additionalScopesToConsent);
92+
}
93+
94+
if (this._requestedScopes && this._requestedScopes.length > 0) {
95+
scopes.push(...this._requestedScopes);
96+
}
97+
8498
const silentRequest = {
8599
redirectUri: this._settings.auth?.redirectUri,
86100
account: account,
87-
scopes: this._settings.defaultAccessTokenScopes
101+
scopes: scopes
88102
};
89103

90104
const response = await this._msalApplication.acquireTokenSilent(silentRequest);
@@ -111,6 +125,7 @@ class MsalAuthorizeService implements AuthorizeService {
111125
return;
112126
}
113127

128+
this._requestedScopes = scopes;
114129
const silentRequest = {
115130
redirectUri: this._settings.auth?.redirectUri,
116131
account: account,
@@ -162,7 +177,7 @@ class MsalAuthorizeService implements AuthorizeService {
162177
const silentRequest = {
163178
redirectUri: request.redirectUri,
164179
account: account,
165-
scopes: request.scopes,
180+
scopes: request.scopes.concat(request.extraScopesToConsent || [])
166181
};
167182
await this._msalApplication.acquireTokenSilent(silentRequest);
168183
}

src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/wwwroot/appsettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
////#if (IndividualLocalAuth)
33
//"Local": {
4-
// "Authority": "https://login.microsoftonline.com/",
4+
// "Authority": "https:////login.microsoftonline.com/",
55
// "ClientId": "33333333-3333-3333-33333333333333333"
66
//}
77
////#endif

0 commit comments

Comments
 (0)