Authentication Microsoft文档示例中有关SignalR Core身份验证的未定义变量
我有一个ASP.NETCore2.2WebAPI,它使用SignalrCore。 我正在关注有关SignalR身份验证的Microsoft文档,但在某一部分中遇到了困难。如果您在此处查看他们的样本: 他们有一个部分我需要帮助:Authentication Microsoft文档示例中有关SignalR Core身份验证的未定义变量,authentication,signalr,asp.net-core-webapi,asp.net-core-signalr,Authentication,Signalr,Asp.net Core Webapi,Asp.net Core Signalr,我有一个ASP.NETCore2.2WebAPI,它使用SignalrCore。 我正在关注有关SignalR身份验证的Microsoft文档,但在某一部分中遇到了困难。如果您在此处查看他们的样本: 他们有一个部分我需要帮助: // Configure JWT Bearer Auth to expect our security key options.TokenValidationParameters = new TokenValidat
// Configure JWT Bearer Auth to expect our security key
options.TokenValidationParameters =
new TokenValidationParameters
{
LifetimeValidator = (before, expires, token, param) =>
{
return expires > DateTime.UtcNow;
},
ValidateAudience = false,
ValidateIssuer = false,
ValidateActor = false,
ValidateLifetime = true,
IssuerSigningKey = SecurityKey
};
什么是安全密钥?它在任何地方都没有定义。
谢谢您可以查看源代码,并找到
安全密钥的定义
public static readonly SymmetricSecurityKey SecurityKey = new SymmetricSecurityKey(Guid.NewGuid().ToByteArray());
谢谢陶。在那个例子中,他们使用的是随机GUID。但是在我的实时应用程序中,我应该从某处获取安全密钥吗?也许是从我的身份验证服务器?(Auth0)@Fabricio Rodriguez一般来说,没有必要,但这取决于你。SecurityKey
仅用于加密和解密期间的签名。谢谢。我会实施,看看它是否有效