繁体   English   中英

使用 GET 进行身份验证时,Servicestack 向我发送错误

[英]Servicestack is sending me an error when using GET for Auth

我在 JSON JWT 身份验证中遇到错误。

GET Authenticate 请求被禁用,启用 set AuthFeature.AllowGetAuthenticateRequests=true

这在几天前起作用了,我无法弄清楚我们改变了什么来打破它。 我在身份验证功能中找不到此属性。 我什至从 GitHub 单元测试中复制了代码。 它没有看到 AuthFeature 中有 AllowGetAuthenticateRequests 的属性

        Plugins.Add(new AuthFeature(() => new CustomUserSession(),
            new IAuthProvider[]
            {
                new BasicAuthProvider(),                    //Sign-in with HTTP Basic Auth
                new JwtAuthProvider(AppSettings) {
                    //HashAlgorithm = "HM256",
                    //PrivateKey = privateKey.ExportParameters(true),
                    AuthKeyBase64 = AppSettings.GetString("jwt.auth.key"),
                    RequireSecureConnection = false,
                    //Turn on for Prod: EncryptPayload = true
                    }, //JWT TOKENS
                new CredentialsAuthProvider(AppSettings)
            })
        {
            HtmlRedirect = "/",
            //IncludeRegistrationService = true,
        });

AuthFeature.AllowGetAuthenticateRequests属性是一个 lambda,您可以在其中启用所有 GET 请求:

Plugins.Add(new AuthFeature(...) {
    AllowGetAuthenticateRequests = req => true
});

如果它没有出现,那么您可能安装了较旧的预发布版本,要安装最新版本,请清除您的 NuGet 包缓存

$ nuget locals all -clear

然后再次恢复您的解决方案。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM