I am trying to understand JWT based authentication , following one of the you tube channel. It was mentioned to add the following contents in appsettings.json
"AllowedHosts": "*",
"JWT": {
"SecretKey": "A247DB24-C8AE-4B8A-8CB2-59637754BF2F",
"Issuer": "JokenTokenAuthorize",
"Audience" : "JokenTokenAuthorize"
}
use the following code for the generation of JWT
var SecretKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(token));
var authClaims = new List<Claim>
{
new Claim(ClaimTypes.Name , userDetails.UserName),
new Claim(ClaimTypes.Email, userDetails.UserName),
new Claim(JwtRegisteredClaimNames.Jti , Guid.NewGuid().ToString())
};
var tokengnerate = new JwtSecurityToken(
issuer: Configuration["JWT:Issuer"],
audience: Configuration["JWT:Audience"],
claims: authClaims,
expires: DateTime.Now.AddDays(1),
signingCredentials: new SigningCredentials(SecretKey, SecurityAlgorithms.HmacSha256Signature)
var tokenDAta = new JwtSecurityTokenHandler().WriteToken(tokengnerate);
As per the link What is secret key for JWT based authentication and how to generate it? The algorithm (HS256) used to sign the JWT means that the secret is a symmetric key that is known by both the sender and the receiver
What's the secret key means -> the one which is stored at server (appsettings.json) or the one which is returned by var SecretKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(token));
Got confused with terms secret, public or private keys