Skip to content

Commit b1b0b4b

Browse files
Tiago Brenckjmprieurjennyf19pmaytak
authored
Microsoft.Identity.Web refactor (#272)
* Renamings: - AddMicrosoftIdentityPlatformAuthentication => AddSignIn - AddMsal => AddWebAppCallProtectedWebApi * More renaming for consistency * Updating the README.md with a breaking changes section * Attempt to move to pure OIDC and JwtBearer implementation (dropping the comfort AzureAD layers) This code does not work yet .... * Raw OIDC configuration suggestion * missing commit * Using AzureAD appsettings section * Experimenting UI as external RazorLibrary project * fix some comments and namings (#244) * Removing AzureADOptions class * Added missing OpenIdConnectOptions binding Added logic to check if authority has v2.0 before modifying it * removed Microsoft.AspNetCore.Authentication.AzureAD.UI reference from web project * reversing testing method * Commented non-working method * Partial changes for B2C login * Fixes for B2C sign-in * Fixed B2C NameClaimType to "name" * Renaming2 (#269) * Renaming GetAccessTokenOnBehalfOfUserAsync into GetAccessTokenForUserAsync as the OnBehalfOfUser was telling too much about OBO, whereas in the case of a Web App this was not the OBO flow. * Addressing PR feedback * New class MicrosoftIdentityOptions, so we can merge AAD and B2C options in the same class Add AuthorityHelpers Helper method to check if authority is V2 Helper method to build AAD or B2C AuthorityHelpers Refactored AddSignIn so parameters shows in a logical order * Attempt to merge B2C and AAD acquireToken logic * Allowing multiple OIDC schemes to be configured * Added B2C ResetPassword and EditProfile in UI project Added B2C exclusive OIDC event handlers Fixed 1-5 samples to use Microsoft.Identity.UI project * Added comments and preparation for PR * Preparation for PR * Havin the authority in the appsettings is not mandatory * Fixed sample 5-1 to use refactored code * missing commit * Samples 5-2 to use refactored code * Moved samesite cookie logic to CookiePolicyOptionsExtensions class * Gitignore for test project * Added IsV2Authority tests * Added license info * Added BuildAuthority unit tests * Addressing PR reviews * Added B2C tests on AadIssuerValidatorTests * Renaming policy to userFlow * Fix spelling mistakes * Added missing error page in UI project * Addressing PR comments about overwriting custom OIDC and JWT events from the developer * Fixed MT scenarios Fixed broken unit test Added b2c NameClaimType config inside AddSignIn * Fixed all samples in folder 1 to use refactored code * Updated all samples to use new code * Renaming policy to user flow * Added B2C Password Reset Policy Added B2C Password Reset Policy ID to app settings. * Moving Web app calling Web API to its own sub folder * Jmprieur/webappwebapib2c (#298) * Experiment for a B2C Web app calling a B2C Web API. Needs more work. * Test and fix B2C web app calls web api scenario Fix issue in AadIssuerValidator when certains claims are not present (ex. policy) in the token Fix bug w/scopes and scopeKeySection Send "client_info=1" to request to get client info back from AAD B2C Add ClientInfo class + methods to pull out the TenantId from the ClientInfo Add full value to UserFlow as it was not picking up on short version In TokenAcquisition, check first for b2c and then do null tenant and then tenant specific, was using the wrong authority for b2c previously Fix bug in determining audience validation * Fixing missing references * Uncommenting a needed line * Fixing a build break * Fixing the configuration and a problem brought bad a by merge by jmprieur * add uitid to the claims for b2c * moving Web app calling Web API with B2C in own folder * Reading the 4-1-MyOrg folder * Update README.md Co-authored-by: jennyf19 <jeferrie@microsoft.com> * - Cleaned appsettings - Removed DisallowsSameSiteNone from WebAppServiceCollectionExtensions because it got moved to another class - Added edit profile button on login bar - Fixed merge on AuthorizeForScopesAttribute - Added options.TokenValidationParameters.NameClaimType = "name" on web api Startup to fix todo list * Added older role claim const * Added policy on APIs to check for scope 'read' * Refactored scopes policy * Renamings and PR comments * Fixing the failing unit test (because the tenant ID is now retrieved from the issuer) (#302) Co-authored-by: Jean-Marc Prieur <jmprieur@microsoft.com> Co-authored-by: jennyf19 <jeferrie@microsoft.com> Co-authored-by: pmaytak <34331512+pmaytak@users.noreply.github.com>
1 parent b940672 commit b1b0b4b

File tree

286 files changed

+29118
-728
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

286 files changed

+29118
-728
lines changed

.gitignore

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
/Microsoft.Identity.Web/.vs
99
/Microsoft.Identity.Web/bin
1010
/Microsoft.Identity.Web/obj
11+
/Microsoft.Identity.Web.UI/.vs
12+
/Microsoft.Identity.Web.UI/bin
13+
/Microsoft.Identity.Web.UI/obj
14+
/Microsoft.Identity.Web.Test/.vs
1115
/Microsoft.Identity.Web.UI/bin
1216
/Microsoft.Identity.Web.UI/obj
1317
/Microsoft.Identity.Web.Test/bin
@@ -37,9 +41,6 @@
3741
/2-WebApp-graph-user/2-2-TokenCache/.vs
3842
/2-WebApp-graph-user/2-2-TokenCache/bin
3943
/2-WebApp-graph-user/2-2-TokenCache/obj
40-
/2-WebApp-graph-user/2-3-Best-Practices/.vs
41-
/2-WebApp-graph-user/2-3-Best-Practices/bin
42-
/2-WebApp-graph-user/2-3-Best-Practices/obj
4344
/2-WebApp-graph-user/2-3-Multi-Tenant/.vs
4445
/2-WebApp-graph-user/2-3-Multi-Tenant/bin
4546
/2-WebApp-graph-user/2-3-Multi-Tenant/obj
@@ -118,6 +119,13 @@
118119
/4-WebApp-your-API/Client/obj
119120
/2-WebApp-graph-user/2-4-Sovereign-Call-MSGraph/bin
120121
/2-WebApp-graph-user/2-4-Sovereign-Call-MSGraph/obj
122+
/4-WebApp-your-API/4-1-MyOrg/.vs
123+
/4-WebApp-your-API/4-1-MyOrg/Client/bin
124+
/4-WebApp-your-API/4-1-MyOrg/Client/obj
125+
/4-WebApp-your-API/4-1-MyOrg/TodoListService/bin
126+
/4-WebApp-your-API/4-1-MyOrg/TodoListService/obj
121127
/4-WebApp-your-API/4-2-B2C/.vs
122128
/4-WebApp-your-API/4-2-B2C/Client/obj
123129
/4-WebApp-your-API/4-2-B2C/TodoListService/obj
130+
/4-WebApp-your-API/4-2-B2C/Client/bin
131+
/4-WebApp-your-API/4-2-B2C/TodoListService/bin

1-WebApp-OIDC/1-1-MyOrg/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ cd "1-WebApp-OIDC\1-1-MyOrg"
164164
by this line:
165165
166166
```CSharp
167-
services.AddMicrosoftIdentityPlatformAuthentication(Configuration);
167+
services.AddSignIn(Configuration);
168168
```
169169
170170
This enables your application to use the Microsoft identity platform endpoint. This endpoint is capable of signing-in users both with their Work and School and Microsoft Personal accounts.

1-WebApp-OIDC/1-1-MyOrg/Startup.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Microsoft.AspNetCore.Authorization;
1+
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
2+
using Microsoft.AspNetCore.Authorization;
23
using Microsoft.AspNetCore.Builder;
34
using Microsoft.AspNetCore.Hosting;
45
using Microsoft.AspNetCore.Http;
@@ -7,6 +8,7 @@
78
using Microsoft.Extensions.DependencyInjection;
89
using Microsoft.Extensions.Hosting;
910
using Microsoft.Identity.Web;
11+
using Microsoft.Identity.Web.UI;
1012

1113
namespace WebApp_OpenIDConnect_DotNet
1214
{
@@ -32,16 +34,19 @@ public void ConfigureServices(IServiceCollection services)
3234
});
3335

3436
// Sign-in users with the Microsoft identity platform
35-
services.AddMicrosoftIdentityPlatformAuthentication(Configuration);
37+
//services.AddSignIn(Configuration);
38+
services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
39+
.AddSignIn("AzureAD", Configuration, options => Configuration.Bind("AzureAD", options));
3640

3741
services.AddControllersWithViews(options =>
3842
{
3943
var policy = new AuthorizationPolicyBuilder()
4044
.RequireAuthenticatedUser()
4145
.Build();
4246
options.Filters.Add(new AuthorizeFilter(policy));
43-
});
44-
services.AddRazorPages();
47+
}).AddMicrosoftIdentityUI();
48+
49+
services.AddRazorPages();
4550
}
4651

4752
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.

1-WebApp-OIDC/1-1-MyOrg/Views/Shared/_LoginPartial.cshtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
<span class="navbar-text text-dark">Hello @User.Identity.Name!</span>
88
</li>
99
<li class="nav-item">
10-
<a class="nav-link text-dark" asp-area="AzureAD" asp-controller="Account" asp-action="SignOut">Sign out</a>
10+
<a class="nav-link text-dark" asp-area="MicrosoftIdentity" asp-controller="Account" asp-action="SignOut">Sign out</a>
1111
</li>
1212
}
1313
else
1414
{
1515
<li class="nav-item">
16-
<a class="nav-link text-dark" asp-area="AzureAD" asp-controller="Account" asp-action="SignIn">Sign in</a>
16+
<a class="nav-link text-dark" asp-area="MicrosoftIdentity" asp-controller="Account" asp-action="SignIn">Sign in</a>
1717
</li>
1818
}
1919
</ul>

1-WebApp-OIDC/1-1-MyOrg/WebApp-OpenIDConnect-DotNet.csproj

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,17 @@
1919
</ItemGroup>
2020

2121
<ItemGroup>
22-
<PackageReference Include="Microsoft.AspNetCore.Authentication.AzureAD.UI" Version="3.0.0" />
22+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0" />
23+
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.0.0">
24+
<PrivateAssets>all</PrivateAssets>
25+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
26+
</PackageReference>
27+
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.0.0" />
28+
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.0.0" />
2329
</ItemGroup>
2430

2531
<ItemGroup>
32+
<ProjectReference Include="..\..\Microsoft.Identity.Web.UI\Microsoft.Identity.Web.UI.csproj" />
2633
<ProjectReference Include="..\..\Microsoft.Identity.Web\Microsoft.Identity.Web.csproj" />
2734
</ItemGroup>
2835

1-WebApp-OIDC/1-1-MyOrg/WebApp-OpenIDConnect-DotNet.sln

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.27130.2027
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.29519.87
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebApp-OpenIDConnect-DotNet", "WebApp-OpenIDConnect-DotNet.csproj", "{8DCFEEC2-0A85-4C7E-B96A-21C9184470B1}"
77
EndProject
88
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Identity.Web", "..\..\Microsoft.Identity.Web\Microsoft.Identity.Web.csproj", "{E0CEF26A-6CE6-4505-851B-6580D5564752}"
99
EndProject
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Identity.Web.UI", "..\..\Microsoft.Identity.Web.UI\Microsoft.Identity.Web.UI.csproj", "{57CF1884-743D-4BF3-B14B-4F8660469038}"
11+
EndProject
1012
Global
1113
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1214
Debug|Any CPU = Debug|Any CPU
@@ -21,6 +23,10 @@ Global
2123
{E0CEF26A-6CE6-4505-851B-6580D5564752}.Debug|Any CPU.Build.0 = Debug|Any CPU
2224
{E0CEF26A-6CE6-4505-851B-6580D5564752}.Release|Any CPU.ActiveCfg = Release|Any CPU
2325
{E0CEF26A-6CE6-4505-851B-6580D5564752}.Release|Any CPU.Build.0 = Release|Any CPU
26+
{57CF1884-743D-4BF3-B14B-4F8660469038}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27+
{57CF1884-743D-4BF3-B14B-4F8660469038}.Debug|Any CPU.Build.0 = Debug|Any CPU
28+
{57CF1884-743D-4BF3-B14B-4F8660469038}.Release|Any CPU.ActiveCfg = Release|Any CPU
29+
{57CF1884-743D-4BF3-B14B-4F8660469038}.Release|Any CPU.Build.0 = Release|Any CPU
2430
EndGlobalSection
2531
GlobalSection(SolutionProperties) = preSolution
2632
HideSolutionNode = FALSE
Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
{
2-
"AzureAd": {
3-
"Instance": "https://login.microsoftonline.com/",
4-
"Domain": "[Enter the domain of your tenant, e.g. contoso.onmicrosoft.com]",
5-
"TenantId": "[Enter 'common', or 'organizations' or the Tenant Id (Obtained from the Azure portal. Select 'Endpoints' from the 'App registrations' blade and use the GUID in any of the URLs), e.g. da41245a5-11b3-996c-00a8-4d99re19f292]",
6-
"ClientId": "[Enter the Client Id (Application ID obtained from the Azure portal), e.g. ba74781c2-53c2-442a-97c2-3d60re42f403]",
7-
"CallbackPath": "/signin-oidc",
8-
"SignedOutCallbackPath ": "/signout-callback-oidc"
9-
},
10-
"Logging": {
11-
"LogLevel": {
12-
"Default": "Information",
13-
"Microsoft": "Warning",
14-
"Microsoft.Hosting.Lifetime": "Information"
15-
}
16-
},
17-
"AllowedHosts": "*"
1+
{
2+
"AzureAd": {
3+
"Instance": "https://login.microsoftonline.com/",
4+
"Domain": "[Enter the domain of your tenant, e.g. contoso.onmicrosoft.com]",
5+
"TenantId": "[Enter 'common', or 'organizations' or the Tenant Id (Obtained from the Azure portal. Select 'Endpoints' from the 'App registrations' blade and use the GUID in any of the URLs), e.g. da41245a5-11b3-996c-00a8-4d99re19f292]",
6+
"ClientId": "[Enter the Client Id (Application ID obtained from the Azure portal), e.g. ba74781c2-53c2-442a-97c2-3d60re42f403]",
7+
"CallbackPath": "/signin-oidc",
8+
"SignedOutCallbackPath ": "/signout-callback-oidc"
9+
},
10+
"Logging": {
11+
"LogLevel": {
12+
"Default": "Information",
13+
"Microsoft": "Warning",
14+
"Microsoft.Hosting.Lifetime": "Information"
15+
}
16+
},
17+
"AllowedHosts": "*"
1818
}

1-WebApp-OIDC/1-2-AnyOrg/README-1-1-to-1-2.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ The actual sign-in audience (accounts to sign-in) is the lowest set of what is s
5757

5858
In order to restrict users from specific organizations from signing-in to your web app, you'll need to customize your code a bit more to restrict issuers. In Azure AD, the token issuers are the Azure AD tenants which issue tokens to applications.
5959

60-
In the `Startup.cs` file, in the `ConfigureServices` method, after `services.AddMicrosoftIdentityPlatformAuthentication(Configuration)` add some code to filter issuers by overriding the `TokenValidationParameters.IssuerValidator` delegate.
60+
In the `Startup.cs` file, in the `ConfigureServices` method, after `services.AddSignIn(Configuration)` add some code to validate specific issuers by overriding the `TokenValidationParameters.IssuerValidator` delegate.
6161

6262
```CSharp
6363
public void ConfigureServices(IServiceCollection services)
6464
{
6565
...
6666
// Sign-in users with the Microsoft identity platform
67-
services.AddMicrosoftIdentityPlatformAuthentication(Configuration);
67+
services.AddSignIn(Configuration);
6868

6969
// Restrict users to specific belonging to specific tenants
7070
services.Configure<OpenIdConnectOptions>(AzureADDefaults.OpenIdScheme, options =>

1-WebApp-OIDC/1-2-AnyOrg/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ cd "1-WebApp-OIDC\1-2-AnyOrg"
156156
by this line:
157157
158158
```CSharp
159-
services.AddMicrosoftIdentityPlatformAuthentication(Configuration);
159+
services.AddSignIn(Configuration);
160160
```
161161
162162
This enables your application to use the Microsoft identity platform endpoint. This endpoint is capable of signing-in users both with their Work and School and Microsoft Personal accounts.

1-WebApp-OIDC/1-2-AnyOrg/Startup.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Microsoft.AspNetCore.Authorization;
1+
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
2+
using Microsoft.AspNetCore.Authorization;
23
using Microsoft.AspNetCore.Builder;
34
using Microsoft.AspNetCore.Hosting;
45
using Microsoft.AspNetCore.Http;
@@ -7,6 +8,7 @@
78
using Microsoft.Extensions.DependencyInjection;
89
using Microsoft.Extensions.Hosting;
910
using Microsoft.Identity.Web;
11+
using Microsoft.Identity.Web.UI;
1012

1113
namespace WebApp_OpenIDConnect_DotNet
1214
{
@@ -32,15 +34,17 @@ public void ConfigureServices(IServiceCollection services)
3234
});
3335

3436
// Sign-in users with the Microsoft identity platform
35-
services.AddMicrosoftIdentityPlatformAuthentication(Configuration);
37+
services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
38+
.AddSignIn("AzureAD", Configuration, options => Configuration.Bind("AzureAD", options));
3639

3740
services.AddControllersWithViews(options =>
3841
{
3942
var policy = new AuthorizationPolicyBuilder()
4043
.RequireAuthenticatedUser()
4144
.Build();
4245
options.Filters.Add(new AuthorizeFilter(policy));
43-
});
46+
}).AddMicrosoftIdentityUI();
47+
4448
services.AddRazorPages();
4549
}
4650

1-WebApp-OIDC/1-2-AnyOrg/Views/Shared/_LoginPartial.cshtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
<span class="navbar-text text-dark">Hello @User.Identity.Name!</span>
88
</li>
99
<li class="nav-item">
10-
<a class="nav-link text-dark" asp-area="AzureAD" asp-controller="Account" asp-action="SignOut">Sign out</a>
10+
<a class="nav-link text-dark" asp-area="MicrosoftIdentity" asp-controller="Account" asp-action="SignOut">Sign out</a>
1111
</li>
1212
}
1313
else
1414
{
1515
<li class="nav-item">
16-
<a class="nav-link text-dark" asp-area="AzureAD" asp-controller="Account" asp-action="SignIn">Sign in</a>
16+
<a class="nav-link text-dark" asp-area="MicrosoftIdentity" asp-controller="Account" asp-action="SignIn">Sign in</a>
1717
</li>
1818
}
1919
</ul>

1-WebApp-OIDC/1-2-AnyOrg/WebApp-OpenIDConnect-DotNet.csproj

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@
1818
</ItemGroup>
1919

2020
<ItemGroup>
21-
<PackageReference Include="Microsoft.AspNetCore.Authentication.AzureAD.UI" Version="3.0.0" />
22-
</ItemGroup>
23-
24-
<ItemGroup>
21+
<ProjectReference Include="..\..\Microsoft.Identity.Web.UI\Microsoft.Identity.Web.UI.csproj" />
2522
<ProjectReference Include="..\..\Microsoft.Identity.Web\Microsoft.Identity.Web.csproj" />
2623
</ItemGroup>
2724

1-WebApp-OIDC/1-2-AnyOrg/WebApp-OpenIDConnect-DotNet.sln

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.27130.2027
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.29709.97
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebApp-OpenIDConnect-DotNet", "WebApp-OpenIDConnect-DotNet.csproj", "{8DCFEEC2-0A85-4C7E-B96A-21C9184470B1}"
77
EndProject
88
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Identity.Web", "..\..\Microsoft.Identity.Web\Microsoft.Identity.Web.csproj", "{E0CEF26A-6CE6-4505-851B-6580D5564752}"
99
EndProject
10+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Identity.Web.UI", "..\..\Microsoft.Identity.Web.UI\Microsoft.Identity.Web.UI.csproj", "{32BCFB8C-7DF5-43D2-9B39-C48B4B707E0E}"
11+
EndProject
1012
Global
1113
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1214
Debug|Any CPU = Debug|Any CPU
@@ -21,6 +23,10 @@ Global
2123
{E0CEF26A-6CE6-4505-851B-6580D5564752}.Debug|Any CPU.Build.0 = Debug|Any CPU
2224
{E0CEF26A-6CE6-4505-851B-6580D5564752}.Release|Any CPU.ActiveCfg = Release|Any CPU
2325
{E0CEF26A-6CE6-4505-851B-6580D5564752}.Release|Any CPU.Build.0 = Release|Any CPU
26+
{32BCFB8C-7DF5-43D2-9B39-C48B4B707E0E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27+
{32BCFB8C-7DF5-43D2-9B39-C48B4B707E0E}.Debug|Any CPU.Build.0 = Debug|Any CPU
28+
{32BCFB8C-7DF5-43D2-9B39-C48B4B707E0E}.Release|Any CPU.ActiveCfg = Release|Any CPU
29+
{32BCFB8C-7DF5-43D2-9B39-C48B4B707E0E}.Release|Any CPU.Build.0 = Release|Any CPU
2430
EndGlobalSection
2531
GlobalSection(SolutionProperties) = preSolution
2632
HideSolutionNode = FALSE

1-WebApp-OIDC/1-3-AnyOrgOrPersonal/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ In the **appsettings.json** file:
151151
by this line:
152152
153153
```CSharp
154-
services.AddMicrosoftIdentityPlatformAuthentication(Configuration);
154+
services.AddSignIn(Configuration);
155155
```
156156
157157
This enables your application to use the Microsoft identity platform endpoint. This endpoint is capable of signing-in users both with their Work and School and Microsoft Personal accounts.

1-WebApp-OIDC/1-3-AnyOrgOrPersonal/Startup.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using Microsoft.AspNetCore.Authentication.AzureAD.UI;
2-
using Microsoft.AspNetCore.Authorization;
1+
using Microsoft.AspNetCore.Authorization;
32
using Microsoft.AspNetCore.Builder;
43
using Microsoft.AspNetCore.Hosting;
54
using Microsoft.AspNetCore.Http;
@@ -8,6 +7,8 @@
87
using Microsoft.Extensions.DependencyInjection;
98
using Microsoft.Identity.Web;
109
using Microsoft.Extensions.Hosting;
10+
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
11+
using Microsoft.Identity.Web.UI;
1112

1213
namespace WebApp_OpenIDConnect_DotNet
1314
{
@@ -33,15 +34,16 @@ public void ConfigureServices(IServiceCollection services)
3334
});
3435

3536
// Sign-in users with the Microsoft identity platform
36-
services.AddMicrosoftIdentityPlatformAuthentication(Configuration);
37+
services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
38+
.AddSignIn("AzureAD", Configuration, options => Configuration.Bind("AzureAD", options));
3739

3840
services.AddControllersWithViews(options =>
3941
{
4042
var policy = new AuthorizationPolicyBuilder()
4143
.RequireAuthenticatedUser()
4244
.Build();
4345
options.Filters.Add(new AuthorizeFilter(policy));
44-
});
46+
}).AddMicrosoftIdentityUI();
4547

4648
services.AddRazorPages();
4749
}

1-WebApp-OIDC/1-3-AnyOrgOrPersonal/Views/Shared/_LoginPartial.cshtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
{
44
<ul class="nav navbar-nav navbar-right">
55
<li class="navbar-text">Hello @User.Identity.Name!</li>
6-
<li><a asp-area="AzureAD" asp-controller="Account" asp-action="SignOut">Sign out</a></li>
6+
<li><a asp-area="MicrosoftIdentity" asp-controller="Account" asp-action="SignOut">Sign out</a></li>
77
</ul>
88
}
99
else
1010
{
1111
<ul class="nav navbar-nav navbar-right">
12-
<li><a asp-area="AzureAD" asp-controller="Account" asp-action="SignIn">Sign in</a></li>
12+
<li><a asp-area="MicrosoftIdentity" asp-controller="Account" asp-action="SignIn">Sign in</a></li>
1313
</ul>
1414
}

1-WebApp-OIDC/1-3-AnyOrgOrPersonal/WebApp-OpenIDConnect-DotNet.csproj

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@
1818
</ItemGroup>
1919

2020
<ItemGroup>
21-
<PackageReference Include="Microsoft.AspNetCore.Authentication.AzureAD.UI" Version="3.0.0" />
22-
</ItemGroup>
23-
24-
<ItemGroup>
21+
<ProjectReference Include="..\..\Microsoft.Identity.Web.UI\Microsoft.Identity.Web.UI.csproj" />
2522
<ProjectReference Include="..\..\Microsoft.Identity.Web\Microsoft.Identity.Web.csproj" />
2623
</ItemGroup>
2724

1-WebApp-OIDC/1-3-AnyOrgOrPersonal/WebApp-OpenIDConnect-DotNet.sln

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.27130.2027
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.29709.97
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebApp-OpenIDConnect-DotNet", "WebApp-OpenIDConnect-DotNet.csproj", "{8DCFEEC2-0A85-4C7E-B96A-21C9184470B1}"
77
EndProject
88
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Identity.Web", "..\..\Microsoft.Identity.Web\Microsoft.Identity.Web.csproj", "{E0CEF26A-6CE6-4505-851B-6580D5564752}"
99
EndProject
10+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Identity.Web.UI", "..\..\Microsoft.Identity.Web.UI\Microsoft.Identity.Web.UI.csproj", "{B39D1761-FD13-4F21-85AF-FF59DF5C708A}"
11+
EndProject
1012
Global
1113
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1214
Debug|Any CPU = Debug|Any CPU
@@ -21,6 +23,10 @@ Global
2123
{E0CEF26A-6CE6-4505-851B-6580D5564752}.Debug|Any CPU.Build.0 = Debug|Any CPU
2224
{E0CEF26A-6CE6-4505-851B-6580D5564752}.Release|Any CPU.ActiveCfg = Release|Any CPU
2325
{E0CEF26A-6CE6-4505-851B-6580D5564752}.Release|Any CPU.Build.0 = Release|Any CPU
26+
{B39D1761-FD13-4F21-85AF-FF59DF5C708A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27+
{B39D1761-FD13-4F21-85AF-FF59DF5C708A}.Debug|Any CPU.Build.0 = Debug|Any CPU
28+
{B39D1761-FD13-4F21-85AF-FF59DF5C708A}.Release|Any CPU.ActiveCfg = Release|Any CPU
29+
{B39D1761-FD13-4F21-85AF-FF59DF5C708A}.Release|Any CPU.Build.0 = Release|Any CPU
2430
EndGlobalSection
2531
GlobalSection(SolutionProperties) = preSolution
2632
HideSolutionNode = FALSE

0 commit comments

Comments
 (0)