Skip to content

Microsoft.Identity.Web refactor #272

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 60 commits into from
Feb 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
3ef8aab
Renamings:
jmprieur Dec 5, 2019
ec18b4d
More renaming for consistency
jmprieur Dec 5, 2019
81126a6
Updating the README.md with a breaking changes section
jmprieur Dec 6, 2019
2086d17
Attempt to move to pure OIDC and JwtBearer implementation (dropping t…
jmprieur Dec 10, 2019
6f32783
Raw OIDC configuration suggestion
Dec 12, 2019
ff0cca9
missing commit
Dec 12, 2019
6988e56
Using AzureAD appsettings section
Dec 12, 2019
09ef790
Experimenting UI as external RazorLibrary project
Dec 21, 2019
794daae
fix some comments and namings (#244)
jennyf19 Jan 8, 2020
60aa290
Removing AzureADOptions class
Jan 16, 2020
e347406
Added missing OpenIdConnectOptions binding
Jan 16, 2020
cc31b76
removed Microsoft.AspNetCore.Authentication.AzureAD.UI reference from…
Jan 16, 2020
7962851
reversing testing method
Jan 16, 2020
2ed5158
Commented non-working method
Jan 17, 2020
d7de325
Partial changes for B2C login
Jan 17, 2020
5dfebbc
Fixes for B2C sign-in
Jan 17, 2020
dd95f87
Fixed B2C NameClaimType to "name"
Jan 17, 2020
8c373f6
Renaming2 (#269)
jmprieur Jan 20, 2020
821c756
Merge branch 'master' into jmprieur/removingUis
Jan 22, 2020
bda9d3e
New class MicrosoftIdentityOptions, so we can merge AAD and B2C optio…
Jan 23, 2020
c379423
Attempt to merge B2C and AAD acquireToken logic
Jan 24, 2020
1242c3d
Allowing multiple OIDC schemes to be configured
Jan 24, 2020
c3852b3
Merge branch 'master' into renaming
jmprieur Jan 24, 2020
7d69b73
Added B2C ResetPassword and EditProfile in UI project
Jan 24, 2020
649cb96
Merge branch 'renaming' into jmprieur/removingUis
Jan 27, 2020
079aae7
Added comments and preparation for PR
Jan 27, 2020
ed9b55c
Preparation for PR
Jan 27, 2020
7662a2d
Havin the authority in the appsettings is not mandatory
Jan 27, 2020
9ac21aa
Fixed sample 5-1 to use refactored code
Jan 29, 2020
8aa5742
missing commit
Jan 29, 2020
46b6bee
Samples 5-2 to use refactored code
Jan 29, 2020
95ccd1c
Moved samesite cookie logic to CookiePolicyOptionsExtensions class
Jan 29, 2020
453289d
Gitignore for test project
Jan 29, 2020
637616f
Added IsV2Authority tests
Jan 29, 2020
f0abd54
Added license info
Jan 29, 2020
0ebe988
Added BuildAuthority unit tests
Jan 29, 2020
628c398
Addressing PR reviews
Jan 29, 2020
97bd750
Added B2C tests on AadIssuerValidatorTests
Jan 29, 2020
1bfaeaa
Renaming policy to userFlow
Jan 29, 2020
fa13c76
Fix spelling mistakes
Jan 30, 2020
f44e861
Added missing error page in UI project
Jan 30, 2020
14dd663
Addressing PR comments about overwriting custom OIDC and JWT events f…
Jan 30, 2020
aff6d17
Fixed MT scenarios
Jan 30, 2020
cabe8d2
Fixed all samples in folder 1 to use refactored code
Jan 30, 2020
2de14ce
Updated all samples to use new code
Jan 30, 2020
80b05ce
Renaming policy to user flow
Jan 30, 2020
190780f
Added B2C Password Reset Policy
pmaytak Feb 1, 2020
16141bc
Merge pull request #275 from Azure-Samples/B2C-reset-policy
pmaytak Feb 1, 2020
f161eb3
Merge branch 'master' into jmprieur/removingUis
Feb 5, 2020
686751e
Merging from master and resolving the conflicts
jmprieur Feb 10, 2020
075bfc8
Moving Web app calling Web API to its own sub folder
jmprieur Feb 18, 2020
45b1750
Jmprieur/webappwebapib2c (#298)
jmprieur Feb 18, 2020
00e7c8c
Merge branch 'master' into jmprieur/removingUis
jmprieur Feb 18, 2020
0505666
- Cleaned appsettings
Feb 18, 2020
c2929ff
Added older role claim const
Feb 18, 2020
5a0e144
Added policy on APIs to check for scope 'read'
Feb 18, 2020
5132107
Refactored scopes policy
Feb 19, 2020
5c86721
Renamings and PR comments
Feb 19, 2020
cc36d77
Merge pull request #300 from Azure-Samples/tibre/mergeCleanup
Feb 19, 2020
ed250ae
Fixing the failing unit test (because the tenant ID is now retrieved …
jmprieur Feb 19, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
/Microsoft.Identity.Web/.vs
/Microsoft.Identity.Web/bin
/Microsoft.Identity.Web/obj
/Microsoft.Identity.Web.UI/.vs
/Microsoft.Identity.Web.UI/bin
/Microsoft.Identity.Web.UI/obj
/Microsoft.Identity.Web.Test/.vs
/Microsoft.Identity.Web.UI/bin
/Microsoft.Identity.Web.UI/obj
/Microsoft.Identity.Web.Test/bin
Expand Down Expand Up @@ -37,9 +41,6 @@
/2-WebApp-graph-user/2-2-TokenCache/.vs
/2-WebApp-graph-user/2-2-TokenCache/bin
/2-WebApp-graph-user/2-2-TokenCache/obj
/2-WebApp-graph-user/2-3-Best-Practices/.vs
/2-WebApp-graph-user/2-3-Best-Practices/bin
/2-WebApp-graph-user/2-3-Best-Practices/obj
/2-WebApp-graph-user/2-3-Multi-Tenant/.vs
/2-WebApp-graph-user/2-3-Multi-Tenant/bin
/2-WebApp-graph-user/2-3-Multi-Tenant/obj
Expand Down Expand Up @@ -118,6 +119,13 @@
/4-WebApp-your-API/Client/obj
/2-WebApp-graph-user/2-4-Sovereign-Call-MSGraph/bin
/2-WebApp-graph-user/2-4-Sovereign-Call-MSGraph/obj
/4-WebApp-your-API/4-1-MyOrg/.vs
/4-WebApp-your-API/4-1-MyOrg/Client/bin
/4-WebApp-your-API/4-1-MyOrg/Client/obj
/4-WebApp-your-API/4-1-MyOrg/TodoListService/bin
/4-WebApp-your-API/4-1-MyOrg/TodoListService/obj
/4-WebApp-your-API/4-2-B2C/.vs
/4-WebApp-your-API/4-2-B2C/Client/obj
/4-WebApp-your-API/4-2-B2C/TodoListService/obj
/4-WebApp-your-API/4-2-B2C/Client/bin
/4-WebApp-your-API/4-2-B2C/TodoListService/bin
2 changes: 1 addition & 1 deletion 1-WebApp-OIDC/1-1-MyOrg/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ cd "1-WebApp-OIDC\1-1-MyOrg"
by this line:

```CSharp
services.AddMicrosoftIdentityPlatformAuthentication(Configuration);
services.AddSignIn(Configuration);
```

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.
Expand Down
13 changes: 9 additions & 4 deletions 1-WebApp-OIDC/1-1-MyOrg/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
Expand All @@ -7,6 +8,7 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Identity.Web;
using Microsoft.Identity.Web.UI;

namespace WebApp_OpenIDConnect_DotNet
{
Expand All @@ -32,16 +34,19 @@ public void ConfigureServices(IServiceCollection services)
});

// Sign-in users with the Microsoft identity platform
services.AddMicrosoftIdentityPlatformAuthentication(Configuration);
//services.AddSignIn(Configuration);
services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to give the flexibility of having many authentication schemes configured, AddSignIn is built on top of an AuthenticationBuilder so developers can have many schemes with different names, without having the extension library overwriting their configs or hardcoding a specific scheme name.

The default is OpenIdConnectDefaults.AuthenticationScheme (OpenIdConnect).

.AddSignIn("AzureAD", Configuration, options => Configuration.Bind("AzureAD", options));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AddSignIn expected an Action<OpenIdConnectOptions> so it is easier to extend the configurations done by the extension library.


services.AddControllersWithViews(options =>
{
var policy = new AuthorizationPolicyBuilder()
.RequireAuthenticatedUser()
.Build();
options.Filters.Add(new AuthorizeFilter(policy));
});
services.AddRazorPages();
}).AddMicrosoftIdentityUI();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By removing AzureAD.UI packages, all of our samples needed an action result for sign-in, sign-out (and edit profile for B2C). A razor project called Microsoft.Identity.UI was created with a standard action result and views for these cases, however it is completely optional to use them.


services.AddRazorPages();
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
Expand Down
4 changes: 2 additions & 2 deletions 1-WebApp-OIDC/1-1-MyOrg/Views/Shared/_LoginPartial.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
<span class="navbar-text text-dark">Hello @User.Identity.Name!</span>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="AzureAD" asp-controller="Account" asp-action="SignOut">Sign out</a>
<a class="nav-link text-dark" asp-area="MicrosoftIdentity" asp-controller="Account" asp-action="SignOut">Sign out</a>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Microsoft.Identity.UI will register a route area named MicrosoftIdentity.

</li>
}
else
{
<li class="nav-item">
<a class="nav-link text-dark" asp-area="AzureAD" asp-controller="Account" asp-action="SignIn">Sign in</a>
<a class="nav-link text-dark" asp-area="MicrosoftIdentity" asp-controller="Account" asp-action="SignIn">Sign in</a>
</li>
}
</ul>
9 changes: 8 additions & 1 deletion 1-WebApp-OIDC/1-1-MyOrg/WebApp-OpenIDConnect-DotNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,17 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.AzureAD.UI" Version="3.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Microsoft.Identity.Web.UI\Microsoft.Identity.Web.UI.csproj" />
<ProjectReference Include="..\..\Microsoft.Identity.Web\Microsoft.Identity.Web.csproj" />
</ItemGroup>

Expand Down
10 changes: 8 additions & 2 deletions 1-WebApp-OIDC/1-1-MyOrg/WebApp-OpenIDConnect-DotNet.sln
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2027
# Visual Studio Version 16
VisualStudioVersion = 16.0.29519.87
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebApp-OpenIDConnect-DotNet", "WebApp-OpenIDConnect-DotNet.csproj", "{8DCFEEC2-0A85-4C7E-B96A-21C9184470B1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Identity.Web", "..\..\Microsoft.Identity.Web\Microsoft.Identity.Web.csproj", "{E0CEF26A-6CE6-4505-851B-6580D5564752}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Identity.Web.UI", "..\..\Microsoft.Identity.Web.UI\Microsoft.Identity.Web.UI.csproj", "{57CF1884-743D-4BF3-B14B-4F8660469038}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -21,6 +23,10 @@ Global
{E0CEF26A-6CE6-4505-851B-6580D5564752}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E0CEF26A-6CE6-4505-851B-6580D5564752}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E0CEF26A-6CE6-4505-851B-6580D5564752}.Release|Any CPU.Build.0 = Release|Any CPU
{57CF1884-743D-4BF3-B14B-4F8660469038}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{57CF1884-743D-4BF3-B14B-4F8660469038}.Debug|Any CPU.Build.0 = Debug|Any CPU
{57CF1884-743D-4BF3-B14B-4F8660469038}.Release|Any CPU.ActiveCfg = Release|Any CPU
{57CF1884-743D-4BF3-B14B-4F8660469038}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
34 changes: 17 additions & 17 deletions 1-WebApp-OIDC/1-1-MyOrg/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"AzureAd": {
"Instance": "https://login.microsoftonline.com/",
"Domain": "[Enter the domain of your tenant, e.g. contoso.onmicrosoft.com]",
"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]",
"ClientId": "[Enter the Client Id (Application ID obtained from the Azure portal), e.g. ba74781c2-53c2-442a-97c2-3d60re42f403]",
"CallbackPath": "/signin-oidc",
"SignedOutCallbackPath ": "/signout-callback-oidc"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"
{
"AzureAd": {
"Instance": "https://login.microsoftonline.com/",
"Domain": "[Enter the domain of your tenant, e.g. contoso.onmicrosoft.com]",
"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]",
"ClientId": "[Enter the Client Id (Application ID obtained from the Azure portal), e.g. ba74781c2-53c2-442a-97c2-3d60re42f403]",
"CallbackPath": "/signin-oidc",
"SignedOutCallbackPath ": "/signout-callback-oidc"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"
}
4 changes: 2 additions & 2 deletions 1-WebApp-OIDC/1-2-AnyOrg/README-1-1-to-1-2.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ The actual sign-in audience (accounts to sign-in) is the lowest set of what is s

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.

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.
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.

```CSharp
public void ConfigureServices(IServiceCollection services)
{
...
// Sign-in users with the Microsoft identity platform
services.AddMicrosoftIdentityPlatformAuthentication(Configuration);
services.AddSignIn(Configuration);

// Restrict users to specific belonging to specific tenants
services.Configure<OpenIdConnectOptions>(AzureADDefaults.OpenIdScheme, options =>
Expand Down
2 changes: 1 addition & 1 deletion 1-WebApp-OIDC/1-2-AnyOrg/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ cd "1-WebApp-OIDC\1-2-AnyOrg"
by this line:

```CSharp
services.AddMicrosoftIdentityPlatformAuthentication(Configuration);
services.AddSignIn(Configuration);
```

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.
Expand Down
10 changes: 7 additions & 3 deletions 1-WebApp-OIDC/1-2-AnyOrg/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
Expand All @@ -7,6 +8,7 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Identity.Web;
using Microsoft.Identity.Web.UI;

namespace WebApp_OpenIDConnect_DotNet
{
Expand All @@ -32,15 +34,17 @@ public void ConfigureServices(IServiceCollection services)
});

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

services.AddControllersWithViews(options =>
{
var policy = new AuthorizationPolicyBuilder()
.RequireAuthenticatedUser()
.Build();
options.Filters.Add(new AuthorizeFilter(policy));
});
}).AddMicrosoftIdentityUI();

services.AddRazorPages();
}

Expand Down
4 changes: 2 additions & 2 deletions 1-WebApp-OIDC/1-2-AnyOrg/Views/Shared/_LoginPartial.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
<span class="navbar-text text-dark">Hello @User.Identity.Name!</span>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="AzureAD" asp-controller="Account" asp-action="SignOut">Sign out</a>
<a class="nav-link text-dark" asp-area="MicrosoftIdentity" asp-controller="Account" asp-action="SignOut">Sign out</a>
</li>
}
else
{
<li class="nav-item">
<a class="nav-link text-dark" asp-area="AzureAD" asp-controller="Account" asp-action="SignIn">Sign in</a>
<a class="nav-link text-dark" asp-area="MicrosoftIdentity" asp-controller="Account" asp-action="SignIn">Sign in</a>
</li>
}
</ul>
5 changes: 1 addition & 4 deletions 1-WebApp-OIDC/1-2-AnyOrg/WebApp-OpenIDConnect-DotNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.AzureAD.UI" Version="3.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Microsoft.Identity.Web.UI\Microsoft.Identity.Web.UI.csproj" />
<ProjectReference Include="..\..\Microsoft.Identity.Web\Microsoft.Identity.Web.csproj" />
</ItemGroup>

Expand Down
10 changes: 8 additions & 2 deletions 1-WebApp-OIDC/1-2-AnyOrg/WebApp-OpenIDConnect-DotNet.sln
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2027
# Visual Studio Version 16
VisualStudioVersion = 16.0.29709.97
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebApp-OpenIDConnect-DotNet", "WebApp-OpenIDConnect-DotNet.csproj", "{8DCFEEC2-0A85-4C7E-B96A-21C9184470B1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Identity.Web", "..\..\Microsoft.Identity.Web\Microsoft.Identity.Web.csproj", "{E0CEF26A-6CE6-4505-851B-6580D5564752}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Identity.Web.UI", "..\..\Microsoft.Identity.Web.UI\Microsoft.Identity.Web.UI.csproj", "{32BCFB8C-7DF5-43D2-9B39-C48B4B707E0E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -21,6 +23,10 @@ Global
{E0CEF26A-6CE6-4505-851B-6580D5564752}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E0CEF26A-6CE6-4505-851B-6580D5564752}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E0CEF26A-6CE6-4505-851B-6580D5564752}.Release|Any CPU.Build.0 = Release|Any CPU
{32BCFB8C-7DF5-43D2-9B39-C48B4B707E0E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{32BCFB8C-7DF5-43D2-9B39-C48B4B707E0E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{32BCFB8C-7DF5-43D2-9B39-C48B4B707E0E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{32BCFB8C-7DF5-43D2-9B39-C48B4B707E0E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 1 addition & 1 deletion 1-WebApp-OIDC/1-3-AnyOrgOrPersonal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ In the **appsettings.json** file:
by this line:

```CSharp
services.AddMicrosoftIdentityPlatformAuthentication(Configuration);
services.AddSignIn(Configuration);
```

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.
Expand Down
10 changes: 6 additions & 4 deletions 1-WebApp-OIDC/1-3-AnyOrgOrPersonal/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Microsoft.AspNetCore.Authentication.AzureAD.UI;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
Expand All @@ -8,6 +7,8 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Identity.Web;
using Microsoft.Extensions.Hosting;
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
using Microsoft.Identity.Web.UI;

namespace WebApp_OpenIDConnect_DotNet
{
Expand All @@ -33,15 +34,16 @@ public void ConfigureServices(IServiceCollection services)
});

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

services.AddControllersWithViews(options =>
{
var policy = new AuthorizationPolicyBuilder()
.RequireAuthenticatedUser()
.Build();
options.Filters.Add(new AuthorizeFilter(policy));
});
}).AddMicrosoftIdentityUI();

services.AddRazorPages();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
{
<ul class="nav navbar-nav navbar-right">
<li class="navbar-text">Hello @User.Identity.Name!</li>
<li><a asp-area="AzureAD" asp-controller="Account" asp-action="SignOut">Sign out</a></li>
<li><a asp-area="MicrosoftIdentity" asp-controller="Account" asp-action="SignOut">Sign out</a></li>
</ul>
}
else
{
<ul class="nav navbar-nav navbar-right">
<li><a asp-area="AzureAD" asp-controller="Account" asp-action="SignIn">Sign in</a></li>
<li><a asp-area="MicrosoftIdentity" asp-controller="Account" asp-action="SignIn">Sign in</a></li>
</ul>
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.AzureAD.UI" Version="3.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Microsoft.Identity.Web.UI\Microsoft.Identity.Web.UI.csproj" />
<ProjectReference Include="..\..\Microsoft.Identity.Web\Microsoft.Identity.Web.csproj" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2027
# Visual Studio Version 16
VisualStudioVersion = 16.0.29709.97
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebApp-OpenIDConnect-DotNet", "WebApp-OpenIDConnect-DotNet.csproj", "{8DCFEEC2-0A85-4C7E-B96A-21C9184470B1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Identity.Web", "..\..\Microsoft.Identity.Web\Microsoft.Identity.Web.csproj", "{E0CEF26A-6CE6-4505-851B-6580D5564752}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Identity.Web.UI", "..\..\Microsoft.Identity.Web.UI\Microsoft.Identity.Web.UI.csproj", "{B39D1761-FD13-4F21-85AF-FF59DF5C708A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -21,6 +23,10 @@ Global
{E0CEF26A-6CE6-4505-851B-6580D5564752}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E0CEF26A-6CE6-4505-851B-6580D5564752}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E0CEF26A-6CE6-4505-851B-6580D5564752}.Release|Any CPU.Build.0 = Release|Any CPU
{B39D1761-FD13-4F21-85AF-FF59DF5C708A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B39D1761-FD13-4F21-85AF-FF59DF5C708A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B39D1761-FD13-4F21-85AF-FF59DF5C708A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B39D1761-FD13-4F21-85AF-FF59DF5C708A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Loading