IdentityServer4 icon indicating copy to clipboard operation
IdentityServer4 copied to clipboard

Hashing method IS4 uses?

Open behrooz66 opened this issue 8 years ago • 7 comments

This might be a silly question, but is there a way to know what is the hashing method IS4 uses to convert, for example, the refresh tokens when it saves them into the database? I would like to know if I can manually check string values to their hashed equivalents in the database.

behrooz66 avatar Jan 19 '18 23:01 behrooz66

is there a way to know what is the hashing method IS4 uses

Sure -- it is open source, after all :)

IIRC we use SHA256.

brockallen avatar Jan 19 '18 23:01 brockallen

Thanks @brockallen , can you tell me if there is any method in IS4 available I can use to manually verify a string against its hashed record? Here is an example I have right now. The refresh token delivered to the client is "e0e11b2a9638fb4e275ffdb9826f9dea10f9a9775c3ef519404516801f0fdfa8" , and in the record saved in the database the key is "/7NVsiMBEGZQqauIAi0OCv96PofmKu9LdmY9wNABWuU=".

Is there a way I manually verify the former against the latter and get a true/false result?

behrooz66 avatar Jan 19 '18 23:01 behrooz66

This is the code you're looking for: https://github.com/IdentityServer/IdentityServer4/blob/dev/src/IdentityServer4/Stores/Default/DefaultGrantStore.cs#L77

brockallen avatar Jan 20 '18 00:01 brockallen

Thanks @brockallen , this is very interesting. Can I ask if there is a similar code block you can point at for hashing client secrets and saving them in the db?

behrooz66 avatar Jan 20 '18 05:01 behrooz66

This: https://github.com/IdentityServer/IdentityServer4/blob/dev/src/IdentityServer4/Validation/HashedSharedSecretValidator.cs

I'll close this now, as the issue tracker is not a general Q&A board.

brockallen avatar Jan 20 '18 12:01 brockallen

Thanks, well, I wonder if you can answer my very last question on this. If there is a way for me to verify my hashed string against this value in the database manually?

behrooz66 avatar Jan 21 '18 18:01 behrooz66

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar Jan 13 '20 18:01 lock[bot]