asp.net web api - Secure JSON Web Token in Web API / MVC 6 -
the security concerns: according https://auth0.com/blog/2015/03/31/critical-vulnerabilities-in-json-web-token-libraries/ lot of jwt libraries use token in order determine algorithm signature.
this our use case: want create login mechanism validates user hard credentials (username/password) , return jwt token e.g. 3 days lifetime. token should contain username , signature should guarantee token cannot "faked".
what library can use in web api / mvc 6? important signature algorithm can specified on decoding avoid vulnerability.
if possible avoid integrating complex oauth components.
i using system.identitymodel.tokens.jwt
library, , checked issue. generated token , validated in 1 of tests, removed signingcredentials
changes alg none. jwt generated "alg":"none"
failed validation.
here how generating token:
public string generatetoken(ssocontext context, signaturesettings settings) { var token = new jwtsecuritytoken( issuer: "myissuer", audience: "myaudience", claims: getclaims(context), //comment below line generate 'none' alg signingcredentials: new x509signingcredentials(settings.certificate), notbefore: datetime.utcnow, expires: datetime.utcnow.addhours(1) ); return new jwtsecuritytokenhandler().writetoken(token); }
when validate token exception expected message
idx10504: unable validate signature, token not have signature:
Comments
Post a Comment