We are using verdaccio 4 and we want to configure JWT authentication.
We have read:
When we set the jwt configuration as in the sample:
security:
legacy: false
api:
jwt:
sign:
expiresIn: 60d
notBefore: 1
web:
sign:
expiresIn: 7d
notBefore: 1
We are having issue after connecting using with a user and it's password from the Web:
The GET request to http://localhost:4873/-/verdaccio/packages return the following content:
{
"error": "jwt not active"
}
What have I done wrong?
Use notBefore: 0
The JWT documentation explain the reason of it. I will close, but feel free to PR some improvement in the docs if you consider is misleading for users.
The JWT documentation explain the reason of it.
Thanks @juanpicado, I have read the documentation and I was surprised not to get any explanation regarding many options.
notBefore: expressed in seconds or a string describing a time span zeit/ms.60, "2 days", "10h", "7d". A numeric value is interpreted as a seconds count. If you use a string be sure you provide the time units (days, hours, etc), otherwise milliseconds unit is used by default ("120" is equal to "120ms").I don't find any reason here, I don't even know what this variable does and I have to guess what it is for just from the variable name...
I have set notBefore: 0 to both web and API. It still returns:
{
"error": "jwt not active"
}
Do you mind reopening @juanpicado ?
Since I couldn't find what notBefore is for.
0 the recommended parameter for security.web.sign.notBefore and security.api.jwt.sign.notBefore?notBefore: 1 in your config sample?I have found what is the option notBefore for after asking on SO and it is not in the documentation as you mentioned:
You can check this document
https://tools.ietf.org/html/rfc7519
The section
4.1.5. "nbf" (Not Before) ClaimThe "nbf" (not before) claim identifies the time before which the JWT MUST NOT be accepted for processing. The processing of the "nbf" claim requires that the current date/time MUST be after or equal to the not-before date/time listed in the "nbf" claim. Implementers MAY provide for some small leeway, usually no more than a few minutes, to account for clock skew. Its value MUST be a number containing a NumericDate value. Use of this claim is OPTIONAL.
The error is still here with notBefore: 0, to reproduce:
jwt authentication.401 error with jwt not active.