What's the format of sid issued by IdentityServer4?

405 views Asked by At

Out of the tokens issued by Thinktecture IdentityServer4, there is one called sid - the session id. In my application, I would like to link this id with some of my other logics. But I am not sure if I can assume it's always a GUID string. I tested a few. They are all valid GUIDs. Just wondering if my assumption is right.

1

There are 1 answers

0
John Cheng On

I looked into the source code of IdentityServer4 and found out the sid is generated by:

public static string CreateUniqueId(int length = 16)
{
    var bytes = new byte[length];
    new RNGCryptoServiceProvider().GetBytes(bytes);
    return ByteArrayToString(bytes);
}

According to this link, the result can be parsed as a GUID.