Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save briandenicola/9e6716bd0cb071818c9a28324e7262fc to your computer and use it in GitHub Desktop.
Save briandenicola/9e6716bd0cb071818c9a28324e7262fc to your computer and use it in GitHub Desktop.
Azure AD Authentication with .net 3.1
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"
},
@briandenicola
Copy link
Author

dotnet new mvc --auth SingleOrg --tenant-id 834bd397-f53b-4659-92b8-555555555555 --client-id 7fb0dd07-157c-4cc2-8e70-444444444444 --domain demo.tech

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment