Conversation
add multiple scenarios with configuration file
src/api/web/index.js
Outdated
| Search.configureStorage(storage); | ||
|
|
||
| router.use(auth.webUIJWTmiddleware()); | ||
| // router.use(auth.webUIJWTmiddleware()); |
There was a problem hiding this comment.
reminder: this is odd
src/lib/auth-utils.js
Outdated
|
|
||
| return credentials; | ||
| } else { | ||
| return; |
There was a problem hiding this comment.
may be you want it more readable..
ayusharma
left a comment
There was a problem hiding this comment.
Can you replace err with error. I'll run it locally later and give one more review.
src/lib/crypto-utils.js
Outdated
| return jwt.sign(payload, secretOrPrivateKey, { | ||
| notBefore: '1000', // Make sure the time will not rollback :) | ||
| ...options, | ||
| }, (err, token) => { |
There was a problem hiding this comment.
arrow ===> function expression
test/lib/server_process.js
Outdated
|
|
||
| this.childFork.on('error', (err) => { | ||
| console.log('error process', err); | ||
| // console.log('error process', err); |
src/lib/auth-utils.js
Outdated
| }); | ||
| } else { | ||
| // i am wiling to use here _.isNil but flow does not like it yet. | ||
| if (typeof security.api.jwt !== 'undefined' && |
There was a problem hiding this comment.
Destructure...
const {jwt} = security.api;
src/lib/auth-utils.js
Outdated
| export function createSessionToken(): CookieSessionToken { | ||
| return { | ||
| // npmjs.org sets 10h expire | ||
| expires: new Date(Date.now() + 10 * 60 * 60 * 1000), |
There was a problem hiding this comment.
can we have this as a constant somewhere?
| } | ||
|
|
||
| export function getAuthenticatedMessage(user: string): string { | ||
| return `you are authenticated as '${user}'`; |
There was a problem hiding this comment.
Yes, it's intended. Don't ask me why :-) ... it was there already and unless I know what it does i cannot remove it.
src/lib/auth-utils.js
Outdated
| } | ||
|
|
||
| export function isAESLegacy(security: Security): boolean { | ||
| return _.isNil(security.api.legacy) === false && |
src/lib/auth-utils.js
Outdated
|
|
||
| return credentials; | ||
| } else { | ||
| return; |
There was a problem hiding this comment.
may be you want it more readable..
src/lib/auth-utils.js
Outdated
| if (_.isString(token) && scheme.toUpperCase() === TOKEN_BEARER.toUpperCase()) { | ||
| return verifyJWTPayload(token, secret); | ||
| } else { | ||
| return; |
There was a problem hiding this comment.
it was mostly for debugging. Removed
priscilawebdev
left a comment
There was a problem hiding this comment.
Great! Looks fine 👍
I forgot add this before 😷
in case we want more output
|
Thanks @priscilawebdev @ayusharma for CR, this is a nice feature. |
* feat: add support for jwt on api * test: add unit test for sign token with jwt add multiple scenarios with configuration file * chore: add JWT verification on middleware * chore: restore headless * chore: restore middleware header validation * refactor: fix login whether user exists * refactor: JWT is signed asynchronously * refactor: better structure and new naming convention * test: add unit test for token signature * test: add unit test for creating user with JWT enabled #168 * docs: add security section jwt * refactor: renable web auth middleware * test(auth): add legacy disabled scenario * chore: update gitignore * chore: add some es6 sugar * feat: enable JWT token signature for new installations * chore: add yaml files to git I forgot add this before 😷 * chore: trace log on auth in case we want more output
* feat: add support for jwt on api * test: add unit test for sign token with jwt add multiple scenarios with configuration file * chore: add JWT verification on middleware * chore: restore headless * chore: restore middleware header validation * refactor: fix login whether user exists * refactor: JWT is signed asynchronously * refactor: better structure and new naming convention * test: add unit test for token signature * test: add unit test for creating user with JWT enabled #168 * docs: add security section jwt * refactor: renable web auth middleware * test(auth): add legacy disabled scenario * chore: update gitignore * chore: add some es6 sugar * feat: enable JWT token signature for new installations * chore: add yaml files to git I forgot add this before 😷 * chore: trace log on auth in case we want more output
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Type: feat
Description:
This PR aims to deprecate AES token generator but without replacing it and allow to use JWT as an alternative on API. (#168 (comment))
Provides customize JWT signature and verification based on
https://github.com/auth0/node-jsonwebtoken#usage
Default Security Config
Legacy
Legacy refers to the default authentification (#168 (comment)) used by
2.xand3.x. If you don't define thesecurityblock, legacy is being enabled by default..npmrcResolves #168 #729
🆕 enable JWT by default on API.
https://verdaccio.org/blog/2019/04/19/diving-into-jwt-support-for-verdaccio-4