34 lines
1.5 KiB
C#
34 lines
1.5 KiB
C#
|
using Microsoft.Owin.Security;
|
|||
|
using Microsoft.Owin.Security.ActiveDirectory;
|
|||
|
using Microsoft.Owin.Security.Cookies;
|
|||
|
using Microsoft.Owin.Security.OpenIdConnect;
|
|||
|
using Owin;
|
|||
|
using System.Configuration;
|
|||
|
using System.IdentityModel.Tokens;
|
|||
|
|
|||
|
namespace pnp.api.contosoorders {
|
|||
|
public partial class Startup {
|
|||
|
// For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
|
|||
|
public void ConfigureAuth(IAppBuilder app) {
|
|||
|
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
|
|||
|
|
|||
|
app.UseCookieAuthentication(new CookieAuthenticationOptions());
|
|||
|
|
|||
|
app.UseOpenIdConnectAuthentication(
|
|||
|
new OpenIdConnectAuthenticationOptions {
|
|||
|
ClientId = ConfigurationManager.AppSettings["ida:ClientId"],
|
|||
|
Authority = $"https://login.microsoftonline.com/{(ConfigurationManager.AppSettings["ida:Tenant"])}",
|
|||
|
PostLogoutRedirectUri = ConfigurationManager.AppSettings["ida:PostLogoutRedirectUri"],
|
|||
|
});
|
|||
|
|
|||
|
app.UseWindowsAzureActiveDirectoryBearerAuthentication(
|
|||
|
new WindowsAzureActiveDirectoryBearerAuthenticationOptions {
|
|||
|
Tenant = ConfigurationManager.AppSettings["ida:Tenant"],
|
|||
|
TokenValidationParameters = new TokenValidationParameters {
|
|||
|
ValidAudience = ConfigurationManager.AppSettings["ida:Audience"]
|
|||
|
},
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
}
|