我正在迟发型但每当我尝试导航到http://MyApp/hangfire,它重定向我到我的应用程序的登录页面,虽然我没有登录。为什么迟发型需要验证我的MVC的Web应用程序中查看仪表盘
我没有明确配置任何授权要求...例如我在web.config中找到了下面的内容,但是为了实现这个目的,我尝试了一下。
<location path="hangfire">
<system.web>
<authorization>
<allow roles="Administrator" />
<deny users="*" />
</authorization>
</system.web>
从理论上讲,这是我想要的东西,当我登录到我的主要的Web应用程序,我将与Administrator
角色身份登录所以这个规则应该工作。
但我是否有配置在web.config与否,每当我试图浏览到http://MyApp/hangfire,它重定向我到我的应用程序登录页面,在web.config配置:
<authentication mode="Forms">
<forms loginUrl="~/Account/Login" timeout="960" />
</authentication>
它不会在我的本地机器上执行此操作,只是当我发布到我的主机时。当我登录时,HangFire是否无法识别我的主应用程序提供的身份验证Cookie?我认为一般来说,hangfire应用程序不需要身份验证,那么还有什么其他配置可以认为它的确如此?
更新1:
我加入了授权过滤器每hangfire docs,但同样的事情发生。这是我在Startup.cs代码:
using Hangfire;
using Hangfire.Logging;
using Hangfire.Dashboard;
using Hangfire.SqlServer;
using Microsoft.Owin;
using OTIS.Web.AppCode;
using OTISScheduler.AppServ;
using Owin;
using System.Web.Security;
[assembly: OwinStartup(typeof(OTIS.Web.App_Start.Startup))]
namespace OTIS.Web.App_Start
{
public class Startup
{
public void Configuration(IAppBuilder app) {
app.UseHangfire(config => {
config.UseSqlServerStorage("DefaultConnection");
config.UseServer();
//Dashboard authorization
config.UseAuthorizationFilters(new AuthorizationFilter
{
Users = "USERA", // allow only specified users (comma delimited list)
Roles = "Account Administrator, Administrator" // allow only specified roles(comma delimited list)
});
});
LogProvider.SetCurrentLogProvider(new StubLogProviderForHangfire());
GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute { Attempts = 0 });
var scheduleTasksInitializer = new ScheduleTasksInitializer();
scheduleTasksInitializer.ScheduleTasks();
}
}
}
更新2:
每更detailed instructions showing basic authentication,我也试过这个......仍然没有luck..redirects我到我的应用程序的登录页面。
config.UseAuthorizationFilters(
new BasicAuthAuthorizationFilter(
new BasicAuthAuthorizationFilterOptions
{
// Require secure connection for dashboard
RequireSsl = false,
SslRedirect = false,
// Case sensitive login checking
LoginCaseSensitive = true,
// Users
Users = new[]
{
new BasicAuthAuthorizationUser
{
Login = "MyLogin",
// Password as plain text
PasswordClear = "MyPwd"
}
}
}));
感谢输入,但我把这些代码中还是一样的结果。我没有使用Autofac或OAuth ...只是基本的asp.net基本成员资格。任何其他想法? – 2015-04-04 22:40:42
对于仪表板的所有文档目前不工作,希望只是临时问题。请您更新链接? – cpoDesign 2016-01-09 20:55:26