ServiceStack的Config.AdminAuthSecret无效

时间:2015-02-24 07:58:52

标签: servicestack

我有使用授权属性的服务我想使用ServiceStack的 AdminAuthSecret 功能,但它不起作用。

我已设置 AdminAuthSecret ,如下所示:

public void Configure(Container container, IAppHost host)
        {
            // more code...
            host.Config.AdminAuthSecret = "9999";
            // more code...
        }

因此,我检查了ServiceStack的源代码以便对其进行调试,并在以下位置设置了断点:

ServiceStackHost类:

 public bool HasValidAuthSecret(IRequest httpReq)
        {
            if (Config.AdminAuthSecret != null)
            {
                var authSecret = httpReq.GetParam("authsecret");
                return authSecret == Config.AdminAuthSecret;
            }

            return false;
        }

但断点永远不会发生。知道什么是错的吗?

1 个答案:

答案 0 :(得分:2)

注意:在ServiceStack中设置配置的API是:

SetConfig(new HostConfig {
    AdminAuthSecret = "9999"
});

Config.AdminAuthSecret用于绕过受RequiredRole和RequiredPermission属性保护的服务。我刚刚将其扩展为旁路[Authenticate]服务以及in this commit,该服务可从v4.0.39 +现在available on MyGet获得。