【发布时间】:2018-01-30 16:40:44
【问题描述】:
在 Thinktecture IdentityServer4 发布的令牌中,有一个称为 sid - 会话 ID。在我的应用程序中,我想将此 id 与我的其他一些逻辑联系起来。但我不确定我是否可以假设它总是一个 GUID 字符串。我测试了几个。它们都是有效的 GUID。只是想知道我的假设是否正确。
【问题讨论】:
标签: identityserver4 thinktecture
在 Thinktecture IdentityServer4 发布的令牌中,有一个称为 sid - 会话 ID。在我的应用程序中,我想将此 id 与我的其他一些逻辑联系起来。但我不确定我是否可以假设它总是一个 GUID 字符串。我测试了几个。它们都是有效的 GUID。只是想知道我的假设是否正确。
【问题讨论】:
标签: identityserver4 thinktecture
我查看了IdentityServer4的源代码,发现sid是由以下生成的:
public static string CreateUniqueId(int length = 16)
{
var bytes = new byte[length];
new RNGCryptoServiceProvider().GetBytes(bytes);
return ByteArrayToString(bytes);
}
根据this链接,可以将结果解析为GUID。
【讨论】: