Reputation: 2989
I need to validate JWT token using middleware of .netcore. I am not able to use inbuilt functionality of .net core to Validate token, since JWT tokens uses an asymmetric key, there is a restriction for sharing public key. I would like to implement this functionality in middleware. Could you please let me know,what are the steps needs to be followed? In particular, I would like to know what all things needs to be added to startup class ?
Thanks Girish
Upvotes: 1
Views: 594
Reputation: 1956
I’m not sure if you’re misunderstanding the JWT in Net Core? You create a token on your server using your key (keep that secret). The token is constructed and a SignatureKey is added to the end (part 3 of the 3 part token). This is used alongside your private key to determine the authenticity automatically for you. The only thing you need to share with the client is the token string itself. Net Core will automatically confirm its validity for you when its passed to your service. You dont need to share any keys at all
Upvotes: 1