- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的 MVC WebApp 已部署到 Azure Paas 并使用 Azure AD 进行保护。身份验证设置使用下面的示例代码作为基础,它在本地主机中使用 IISExpress 或 IIS 运行。
https://github.com/Azure-Samples/active-directory-dotnet-webapp-webapi-openidconnect
但部署到 Azure 后无法正常工作。即使用户能够正确进行身份验证,也永远不会调用 AuthorizationCodeReceived 委托(delegate)。
这是设置身份验证的启动代码:
void ConfigureAuth(IAppBuilder app, Container container) {
_log.Debug("Configuring Azure Authentication");
AzureActiveDirectoryAppSetting setting = container.GetInstance<IAzureActiveDirectoryAppSettingFactory>().Get();
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions());
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions() {
ClientId = setting.ClientID,
Authority = setting.Authority,
PostLogoutRedirectUri = setting.PostLogoutRedirectUrl,
RedirectUri = setting.ReplyUrl,
Notifications = new OpenIdConnectAuthenticationNotifications() {
AuthorizationCodeReceived = new Func<Microsoft.Owin.Security.Notifications.AuthorizationCodeReceivedNotification, System.Threading.Tasks.Task>(args => OnAuthorizationCodeReceived(args, container)),
AuthenticationFailed = new Func<Microsoft.Owin.Security.Notifications.AuthenticationFailedNotification<OpenIdConnectMessage, OpenIdConnectAuthenticationOptions>, System.Threading.Tasks.Task>(OnAuthorizationFailed),
}
}
);
}
System.Threading.Tasks.Task OnAuthorizationFailed(Microsoft.Owin.Security.Notifications.AuthenticationFailedNotification<OpenIdConnectMessage, OpenIdConnectAuthenticationOptions> args) {
_log.Error("Authorization Failed");
return System.Threading.Tasks.Task.FromResult<string>(null);
}
System.Threading.Tasks.Task OnAuthorizationCodeReceived(Microsoft.Owin.Security.Notifications.AuthorizationCodeReceivedNotification args, Container container) {
_log.Debug("Authorization Code Received");
var auth = container.GetInstance<IClaimsBasedAuthentication>();
return auth.ReceiveSecurityClaim(args.Code, args.AuthenticationTicket.Identity, HttpContext.Current);
}
这是来自 Azure 的跟踪。如您所见,身份验证成功,但找不到“授权失败”或“已收到授权码”跟踪信息。第一个错误来自 AcquireTokenSilentAsync 调用。它失败了,因为 token 一开始就没有缓存。
感谢任何帮助。谢谢!
- 2017-06-10T22:18:59 PID[7692] Verbose Albatross.Security.AzureADOpenIDAuthentication:AzureADOpenIDAuthentication Created
- 2017-06-10T22:18:59 PID[7692] Information Albatross.Web.App_Start.Startup:Web App Configuration
- 2017-06-10T22:18:59 PID[7692] Information Albatross.Web.App_Start.Startup:All areas registered
- 2017-06-10T22:18:59 PID[7692] Information Albatross.Web.App_Start.Startup:Routes registered
- 2017-06-10T22:18:59 PID[7692] Information Albatross.Web.App_Start.Startup:Bundles registered
- 2017-06-10T22:18:59 PID[7692] Verbose Albatross.Web.App_Start.Startup:Configuring Azure Authentication
- 2017-06-10T22:18:59 PID[7692] Verbose Albatross.Web.App_Start.Startup:ClientID:xxx
- 2017-06-10T22:18:59 PID[7692] Verbose Albatross.Web.App_Start.Startup:Authority:https://login.microsoftonline.com/rushuioutlook.onmicrosoft.com
- 2017-06-10T22:18:59 PID[7692] Verbose Albatross.Web.App_Start.Startup:PostLogoutRedirectUrl:https://albatrossweb.azurewebsites.net/.auth/login/aad/callback/
- 2017-06-10T22:18:59 PID[7692] Verbose Albatross.Web.App_Start.Startup:ReplyUrl:https://albatrossweb.azurewebsites.net/.auth/login/aad/callback/
- 2017-06-10T22:18:59 PID[7692] Verbose Albatross.Web.App_Start.Startup:Tenant:rushuioutlook.onmicrosoft.com
- 2017-06-10T22:19:00 PID[7692] Verbose Received request: GET http://albatrossweb.azurewebsites.net/
- 2017-06-10T22:19:00 PID[7692] Information Redirecting: https://albatrossweb.azurewebsites.net/
- 2017-06-10T22:19:00 PID[7692] Verbose Received request: GET https://albatrossweb.azurewebsites.net/
- 2017-06-10T22:19:00 PID[7692] Information Redirecting: https://login.windows.net/25dd3578-72e5-4b70-a97b-3cc94f9d69cc/oauth2/authorize?response_type=code+id_token&redirect_uri=https%3A%2F%2Falbatrossweb.azurewebsites.net%2F.auth%2Flogin%2Faad%2Fcallback&client_id=40ca9b08-b857-4307-9ba3-5815031e9ddf&scope=openid+profile+email&response_mode=form_post&nonce=4a0abda18cf6448fb5b8095efb546871_- 20170610222400&state=redir%3D%252F
- 2017-06-10T22:19:29 PID[7692] Verbose Received request: POST https://albatrossweb.azurewebsites.net/.auth/login/aad/callback
- 2017-06-10T22:19:29 PID[7692] Verbose JWT validation succeeded. Subject: 'iit96kJ_mJn8Qt0f3kKAZm3qFKMGR2BMjVEnI45JBRc', Issuer: 'https://sts.windows.net/25dd3578-72e5-4b70-a97b-3cc94f9d69cc/'.
- 2017-06-10T22:19:29 PID[7692] Verbose Calling into external HTTP endpoint POST https://login.windows.net/25dd3578-72e5-4b70-a97b-3cc94f9d69cc/oauth2/token.
- 2017-06-10T22:19:29 PID[7692] Information Login completed for '<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="11746579707f516364627964787e64657d7e7e7a3f7e7f7c7872637e627e77653f727e7c" rel="noreferrer noopener nofollow">[email protected]</a>'. Provider: 'aad'.
- 2017-06-10T22:19:29 PID[7692] Verbose Writing 'AppServiceAuthSession' cookie for site 'albatrossweb.azurewebsites.net'. Length: 940.
- 2017-06-10T22:19:29 PID[7692] Information Redirecting: https://albatrossweb.azurewebsites.net/
- 2017-06-10T22:19:31 PID[7692] Verbose Received request: GET https://albatrossweb.azurewebsites.net/
- 2017-06-10T22:19:31 PID[7692] Verbose Found 'AppServiceAuthSession' cookie for site 'albatrossweb.azurewebsites.net'. Length: 940.
- 2017-06-10T22:19:31 PID[7692] Verbose Authenticated <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="93f6e7fbf2fdd3e1e6e0fbe6fafce6e7fffcfcf8bdfcfdfefaf0e1fce0fcf5e7bdf0fcfe" rel="noreferrer noopener nofollow">[email protected]</a> successfully using 'Session Cookie' authentication.
- 2017-06-10T22:19:31 PID[7692] Verbose [Routes(Preview)] No authorization configuration was found.
- 2017-06-10T22:19:33 PID[7692] Error Albatross.Web.Controllers.ServiceController:Microsoft.IdentityModel.Clients.ActiveDirectory.AdalSilentTokenAcquisitionException: Failed to acquire token silently as no token was found in the cache. Call method AcquireToken
编辑以澄清标记的答案:
正如 Nan Yu 所说,当启用“身份验证/授权”功能时,可能会重复出现此问题。工作设置如下图所示。
最佳答案
根据回复网址:https://albatrossweb.azurewebsites.net/.auth/login/aad/callback/ ,看来您启用了azure应用程序服务的“身份验证/授权”功能。我可以重现,如果我启用“身份验证/授权”功能,在这种情况下,简单的身份验证将接管身份验证过程。如果您启用了应用服务的“身份验证/授权”,请尝试禁用它并重试。
关于azure - 未为受 Azure Active Directory 保护的 Azure WebApp 调用 OpenIdConnectAuthenticationNotifications.AuthorizationCodeReceived 事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44509409/
当我尝试构建我的项目时,我遇到了这样的错误: FAILURE: Build failed with an exception. * What went wrong: Execution failed
我正在尝试从 Here 构建适用于 linux 3.7 内核的 Mali 驱动程序. 有一个单独的构建脚本,例如, #!/bin/bash export KDIR=/path/to/kernel/di
有没有一种方法可以使用普通的 lisp 创建目录。我想先创建一个文件夹,然后将我的 .txt .png 文件放入其中。我知道首先我可以在外部创建文件夹,然后使用 with-open-file 等在目录
Visual Studio 提示每次编译警告 MSB8029:中间目录或输出目录不能位于临时目录下,因为它可能导致增量构建出现问题。 我正在检查项目并更改了输出目录和中间目录,但我仍然在我的解决方案中
Visual Studio 提示每次编译警告 MSB8029:中间目录或输出目录不能位于临时目录下,因为它可能导致增量构建出现问题。 我正在检查项目并更改了输出目录和中间目录,但我仍然在我的解决方案中
我的客户安装了 Keycloak 以从 AWS Cognito 代理用户。 我需要这个 Keycloak 来代理来自 Azure Active Directory 的用户。 客户拥有 AAD 的 OF
我想从 macOS 上 parallel 命令的所有潜力中受益(似乎存在 2 个版本,GNU 和 Ole Tange 的版本,但我不确定)。 使用以下命令: parallel -j8 find {}
我需要实现一个 Active Directory(本地)管理器,用户可以在其中执行所有任务,例如添加用户、删除用户、分配许可证和分配组等。用户有用户名、密码和域 Controller 名称,所以他只需
我正在编写一个使用PHP adLDAP库与Active Directory交互的应用程序。 为了测试该应用程序,我需要使用Active Directory架构的本地LDAP DB以及示例数据。 我已经
我有一个包含两个域 AA.RR.COM 和 BB.RR.COM 的 Active Directory 林,其中包含用户和组。我需要搜索两个域中的用户,同时查询其中一个域(例如 AA.RT.COM)如何
我使用 Proxy-Address 属性作为确定用户电子邮件地址的主要方法(我只关心以“SMTP:”或“smtp:”为前缀的地址,此外,我使用以大写字母为前缀的地址SMTP 来确定主地址 - 这不是
这个问题不太可能对任何 future 的访客有帮助;它只与一个较小的地理区域、一个特定的时间点或一个非常狭窄的情况相关,通常不适用于全世界的互联网受众。如需帮助使此问题更广泛适用,visit the
所以我有一个目录 - 让我们说/dir/。在里面我有这些文件夹-/目录/fold1//目录/fold2//dir/fold3/ 这些文件夹 (fold1,2,3) 中的每一个都可能包含一个名为 foo
我正在使用 PHPmotion 在我本地的 ubuntu 机器上。 优步上传者在 phpmotion 中用于将文件上传到服务器。这是使用 perl 脚本(位于“ www/cgi-bin ”)上传文件。
我正在为我的公司开发一个基于 Web 的 Intranet。我只想知道用户使用事件目录登录详细信息登录应用程序是一件好事,还是我应该与应用程序数据库一起创建登录名。如果有什么比这更好的,请提出建议。这
我们有带有 AD 模块 1.0.4 的 Sitecore 6.5。 DEPARTMENT\SitecoreUsers AD 组中的用户可以登录 Sitecore,但 DEPARTMENT\Siteco
我使用的 AD 设置具有存储为(多个)安全组成员的用户。 我正在使用读取用户的 memberof 属性的软件来计算访问权限。 在 AD Explorer 中,我可以看到用户的 memberof 属性显
我们有一个在 .NET 上编写的 SaaS 应用程序,我们需要为我们的客户提供各种 SSO 方法。 不久前,我们对 OpenID 进行了标准化,希望这会成为一个通用标准,让我们不必支持不同的标准。不幸
我有 .Net 代码可以读取/写入我们本地的 Active Directory 域。阅读部分已经过测试并且工作正常,但我想测试“写作”部分。我的应用程序将修改事件目录中的一些用户配置文件,但我不想在实
我正在运行一个 ASP.NET 4.0 应用程序,它使用用户名(即 HttpContext.Current.Request.LogonUserIdentity.Name.ToString())来管理对
我是一名优秀的程序员,十分优秀!