gpt4 book ai didi

c# - 如何保护 MVC Hangfire 仪表板

转载 作者:太空宇宙 更新时间:2023-11-03 13:12:14 24 4
gpt4 key购买 nike

我使用的是 Visual Studio 2013 MVC,我安装了“Hangfire”来执行计划任务。 ( http://hangfire.io/ )

如何使用密码保护 Web 监控 UI 页面 ( http://localhost/Hangfire)?

谢谢

最佳答案

请查看documentation

简而言之。您可以使用已经创建的授权过滤器或实现您自己的

using Hangfire.Dashboard;

public class MyRestrictiveAuthorizationFilter : IAuthorizationFilter
{
public bool Authorize(IDictionary<string, object> owinEnvironment)
{
// In case you need an OWIN context, use the next line.
var context = new OwinContext(owinEnvironment);
return false;
}
}

附加信息:

您还可以查看 special package Hangfire.Dashboard.Authorization其中包含您需要的逻辑

关于c# - 如何保护 MVC Hangfire 仪表板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28021135/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com