I have develop API to generate JWT token and hosted into MS Azure App Services.From Last couple of months we have issued around 1,000,00 token and now we want to clear/remove the all token from memory as per our business requirement.
If we not remove/clear the token from memory , It will still persist because we issue token for 1 years and it will consume our memory up to one years.
I have tried "Restart" option of app services but after restart, Previous generated token is still available in memory and we can access this JWT token.
Please suggest that how can we remove to previous generated token from Memory in MS App Services.
OUR MAIN OBJECTIVE TO REMOVE ALL PREVIOUS TOKEN FROM OUR MS AZURE APP SERVICES AND FREE TO MEMORY BECAUSE CURRENTLY OUR MOST OF MEMORY ARE TAKEN BY PREVIOUS TOKEN.
Thanks in advance!! Technologies:- C# .NET
using Microsoft.IdentityModel.Tokens;
using System.IdentityModel.Tokens.Jwt;
using System.Security.Claims;
public async static Task<string> GenerateToken(string userid, char type,string contactId)
{
string _userKeyCombination = userid+"|"+ contactId;
byte[] key = Convert.FromBase64String(_SecretKey);
SymmetricSecurityKey securityKey = new SymmetricSecurityKey(key);
SecurityTokenDescriptor descriptor = new SecurityTokenDescriptor();
descriptor.Subject = new ClaimsIdentity(claims: new[] { new Claim(type: ClaimTypes.Name,
value: _userKeyCombination) });
descriptor.Expires = DateTime.UtcNow.AddMonths(12));
descriptor.SigningCredentials = new SigningCredentials(securityKey, algorithm:
SecurityAlgorithms.HmacSha256Signature);
JwtSecurityTokenHandler handler = new JwtSecurityTokenHandler();
JwtSecurityToken token = handler.CreateJwtSecurityToken(descriptor);
string _token = handler.WriteToken(token);
return _token;
}