In my production env right now I have my key hard coded:
new SigningCredentials(new SymmetricSecurityKey("my jey bla bla"), SecurityAlgorithms.HmacSha256Signature);
Moving the key to a config file is a bad idea, placing it here is even worst.
What is the best way to store and use the SymmetricSecurityKey?
Thanks
The best practice is to store your secrets in environment variables.
Windows:
Linux:
Then, to access it in your code you can use the System.Environment class. Specifically, the Environment.GetEnvironmentVariable method: