【发布时间】:2018-05-19 18:19:25
【问题描述】:
我在 GitHub 有以下应用程序,并将其部署到 Azure 应用服务上的 https://stratml.services,身份验证定义为 Microsoft 帐户,任何请求都需要 Microsoft 帐户登录。然而,在“prod”中会发生此挑战https://stratml.services/Home/IdentityName 不返回任何内容。
我一直在关注this 和this,但是我不想使用 EntityFramework,从后者的描述来看,这似乎暗示如果我正确配置了我的身份验证方案,我不必这样做。
以下代码在我的 Start 类中:
services.AddAuthentication(options =>
{
options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = MicrosoftAccountDefaults.AuthenticationScheme;
}).AddMicrosoftAccount(microsoftOptions =>
{
microsoftOptions.ClientId = Configuration["Authentication:AppId"];
microsoftOptions.ClientSecret = Configuration["Authentication:Key"];
microsoftOptions.CallbackPath = new PathString("/.auth/login/microsoftaccount/callback");
});
更新:感谢我能够得到的第一个答案,它现在授权给 Microsoft 并尝试向我的应用程序反馈,但是我收到以下错误:
InvalidOperationException: No IAuthenticationSignInHandler is configured to handle sign in for the scheme: Cookies
请访问https://stratml.services/Home/IdentityName,GitHub 已更新。
services.AddAuthentication(options =>
{
options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = MicrosoftAccountDefaults.AuthenticationScheme;
}).AddCookie(option =>
{
option.Cookie.Name = ".myAuth"; //optional setting
}).AddMicrosoftAccount(microsoftOptions =>
{
microsoftOptions.ClientId = Configuration["Authentication:AppId"];
microsoftOptions.ClientSecret = Configuration["Authentication:Key"];
});
【问题讨论】:
标签: c# azure authentication asp.net-core-2.0