Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can you create a shared secret for IdentityServer4?

All the documentation and examples I've seen all use C# code to generate the secret, like this:

new Secret("secret".Sha256())

This is fine for an initial setup and inserting into the database on startup, but what if I want to add a secret directly to the database at run time. Preferably I'd like to give instructions to a customer that doesn't involve any code.

I've tried using online tools to hash the string then Base64 encode the string but it's not matching what the code generates so I think I'm missing a step.

like image 277
cassonchris Avatar asked Sep 21 '25 00:09

cassonchris


1 Answers

The code for that function is here:

https://github.com/IdentityServer/IdentityServer4/blob/master/src/IdentityServer4/src/Extensions/HashExtensions.cs

You could create a tool or library of your own that meets your requirements. We have a SQL implementation so we can easily import clients directly into our DB should we need to.

like image 89
mackie Avatar answered Sep 23 '25 10:09

mackie