This commit is contained in:
2025-08-07 09:16:23 +08:00
parent c97bd0ab55
commit 70bfe43a80
34 changed files with 532 additions and 135 deletions

View File

@@ -29,24 +29,25 @@ public static class AuthenticationJwtComponentSystem
ValidateIssuer = true, // 验证发行者
ValidateAudience = true, // 验证受众
ValidateIssuerSigningKey = true, // 验证签名密钥
ValidIssuer = "Fantasy", // 有效的发行者
ValidAudience = "Fantasy", // 有效的受众
ValidIssuer = "NoBug", // 有效的发行者
ValidAudience = "NoBug", // 有效的受众
IssuerSigningKey = new RsaSecurityKey(rsa) // RSA公钥作为签名密钥
};
}
public static string GetToken(this AuthenticationJwtComponent self, long aId, string address, uint sceneId)
public static string GetToken(this AuthenticationJwtComponent self, long aId, string address, uint sceneId, int region)
{
var jwtPayload = new JwtPayload()
{
{ "aId", aId },
{ "Address", address },
{ "SceneId", sceneId }
{ "SceneId", sceneId },
{ "Region", region },
};
var jwtSecurityToken = new JwtSecurityToken(
issuer: "Fantasy",
audience: "Fantasy",
issuer: "NoBug",
audience: "NoBug",
claims: jwtPayload.Claims,
expires: DateTime.UtcNow.AddMilliseconds(3000),
signingCredentials: self.SigningCredentials);

View File

@@ -11,9 +11,10 @@ public static class AuthenticationJwtHelper
/// <param name="aId">AccountId</param>
/// <param name="address">目标服务器的地址</param>
/// <param name="sceneId">分配的Scene的Id</param>
/// <param name="region">账号所属地区</param>
/// <returns></returns>
public static string GetToken(Scene scene, long aId, string address, uint sceneId)
public static string GetToken(Scene scene, long aId, string address, uint sceneId, int region)
{
return scene.GetComponent<AuthenticationJwtComponent>().GetToken(aId, address, sceneId);
return scene.GetComponent<AuthenticationJwtComponent>().GetToken(aId, address, sceneId, region);
}
}