Created
June 8, 2020 19:55
-
-
Save briandenicola/9e6716bd0cb071818c9a28324e7262fc to your computer and use it in GitHub Desktop.
Azure AD Authentication with .net 3.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
startup.cs | |
using Microsoft.AspNetCore.Authentication; | |
using Microsoft.AspNetCore.Authentication.AzureAD.UI; | |
services.AddAuthentication(AzureADDefaults.AuthenticationScheme) | |
.AddAzureAD(options => Configuration.Bind("AzureAd", options)); | |
services.AddControllersWithViews(options => | |
{ | |
var policy = new AuthorizationPolicyBuilder() | |
.RequireAuthenticatedUser() | |
.Build(); | |
options.Filters.Add(new AuthorizeFilter(policy)); | |
}); | |
app.UseAuthorization(); | |
App Settings: | |
{ | |
"AzureAd": { | |
"Instance": "https://login.microsoftonline.com/", | |
"Domain": "demo.tech", | |
"TenantId": "834bd397-f53b-4659-92b8-555555555555", | |
"ClientId": "7fb0dd07-157c-4cc2-8e70-444444444444", | |
"CallbackPath": "/signin-oidc" | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
dotnet new mvc --auth SingleOrg --tenant-id 834bd397-f53b-4659-92b8-555555555555 --client-id 7fb0dd07-157c-4cc2-8e70-444444444444 --domain demo.tech