mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-01-20 22:52:46 -05:00
fix: potential issue on sign new jwt tokens
If the user was already loged, we were unwraping the token and signing a new token, passing through previous payload props to new token, this might causes https://github.com/auth0/node-jsonwebtoken/issues/326#issuecomment-288124020 This commit ensure the new token will be based on sign options defined on config file.
This commit is contained in:
parent
9af62c3ad2
commit
265849eaa9
1 changed files with 6 additions and 3 deletions
|
@ -411,10 +411,13 @@ class Auth implements IAuth {
|
|||
}
|
||||
|
||||
async jwtEncrypt(user: RemoteUser, signOptions: JWTSignOptions): string {
|
||||
const { real_groups } = user;
|
||||
const { real_groups, name, groups } = user;
|
||||
const realGroupsValidated = _.isNil(real_groups) ? [] : real_groups;
|
||||
const groupedGroups = _.isNil(groups) ? real_groups : groups.concat(realGroupsValidated);
|
||||
const payload: RemoteUser = {
|
||||
...user,
|
||||
group: real_groups && real_groups.length ? real_groups : undefined,
|
||||
real_groups: realGroupsValidated,
|
||||
name,
|
||||
groups: groupedGroups,
|
||||
};
|
||||
|
||||
const token: string = await signPayload(payload, this.secret, signOptions);
|
||||
|
|
Loading…
Add table
Reference in a new issue