-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Changes from all commits
3ef8aab
ec18b4d
81126a6
2086d17
6f32783
ff0cca9
6988e56
09ef790
794daae
60aa290
e347406
cc31b76
7962851
2ed5158
d7de325
5dfebbc
dd95f87
8c373f6
821c756
bda9d3e
c379423
1242c3d
c3852b3
7d69b73
649cb96
079aae7
ed9b55c
7662a2d
9ac21aa
8aa5742
46b6bee
95ccd1c
453289d
637616f
f0abd54
0ebe988
628c398
97bd750
1bfaeaa
fa13c76
f44e861
14dd663
aff6d17
cabe8d2
2de14ce
80b05ce
190780f
16141bc
f161eb3
686751e
075bfc8
45b1750
00e7c8c
0505666
c2929ff
5a0e144
5132107
5c86721
cc36d77
ed250ae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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; | ||
|
@@ -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 | ||
{ | ||
|
@@ -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) | ||
.AddSignIn("AzureAD", Configuration, options => Configuration.Bind("AzureAD", options)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
services.AddControllersWithViews(options => | ||
{ | ||
var policy = new AuthorizationPolicyBuilder() | ||
.RequireAuthenticatedUser() | ||
.Build(); | ||
options.Filters.Add(new AuthorizeFilter(policy)); | ||
}); | ||
services.AddRazorPages(); | ||
}).AddMicrosoftIdentityUI(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By removing |
||
|
||
services.AddRazorPages(); | ||
} | ||
|
||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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> |
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": "*" | ||
} |
There was a problem hiding this comment.
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 anAuthenticationBuilder
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).