ServiceStack 的 Config.AdminAuthSecret 不工作

ServiceStack's Config.AdminAuthSecret is not working

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

我已经设置了 AdminAuthSecret,如下所示:

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

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

ServiceStackHostclass:

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

            return false;
        }

但断点始终未命中。知道出了什么问题吗?

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

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

Config.AdminAuthSecret 用于绕过受 RequiredRole 和 RequiredPermission 属性保护的服务。我刚刚将其扩展为绕过 [Authenticate] 服务以及 in this commit which will be available from v4.0.39+ that's now available on MyGet