MASTER_4073-user_hasGrant #1107

Merged
alexm merged 4 commits from 4073-user-hasGrant-master into master 2022-10-28 11:15:58 +00:00
Member
No description provided.
alexm added the
CR / Tests passed
label 2022-10-26 06:29:29 +00:00
alexm added 1 commit 2022-10-26 06:29:31 +00:00
gitea/salix/pipeline/head This commit looks good Details
f65d06fc7d
fixes #4073
alexm requested review from juan 2022-10-26 06:29:45 +00:00
juan requested changes 2022-10-26 18:49:39 +00:00
@ -49,3 +54,2 @@
const role = await models.Role.findById(roleFk, null, myOptions);
const hasRole = await models.Account.hasRole(userId, role.name, myOptions);
if (!hasRole)
Owner

La comprovació de si hereda el rol (hasRole), en cas de no pasar rol, s'ha de fer sobre en el rol que te actualment userToUpdate. Si no, qualsevol usuari amb grant podría donar grant als demes usuaris independentment del rol que tinguen.

Es a dir, nomes pots asignar grant a un usuari, si tens grant, i si heretes el rol sobre el que vas a asignar grant.

La comprovació de si hereda el rol (`hasRole`), en cas de no pasar rol, s'ha de fer sobre en el rol que te actualment `userToUpdate`. Si no, qualsevol usuari amb grant podría donar grant als demes usuaris independentment del rol que tinguen. Es a dir, nomes pots asignar grant a un usuari, si tens grant, i si heretes el rol sobre el que vas a asignar grant.
alexm marked this conversation as resolved
@ -1 +1,4 @@
ALTER TABLE `account`.`user` ADD hasGrant TINYINT(1) NOT NULL;
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
VALUES('Account', 'privileges', '*', 'ALLOW', 'ROLE', '$authenticated');
Owner

No definir-ho ací, definir-ho com a ACL estatic en el fitxer del model Account.json, secció acls.

https://gitea.verdnatura.es/verdnatura/salix/src/branch/dev/back/models/account.json

No definir-ho ací, definir-ho com a ACL estatic en el fitxer del model Account.json, secció `acls`. https://gitea.verdnatura.es/verdnatura/salix/src/branch/dev/back/models/account.json
alexm marked this conversation as resolved
@ -1,2 +1,2 @@
Privileges: Privilegios
Has grant: Tiene privilegios
Has grant: Puede dar privilegios
Owner

Puede delegar privilegios

Puede delegar privilegios
alexm marked this conversation as resolved
alexm added 1 commit 2022-10-27 07:01:22 +00:00
alexm requested review from juan 2022-10-27 07:01:36 +00:00
alexm added 1 commit 2022-10-27 07:28:21 +00:00
gitea/salix/pipeline/head There was a failure building this commit Details
5c65314162
use findById
juan requested changes 2022-10-27 13:40:25 +00:00
@ -52,3 +64,2 @@
if (!hasRole)
throw new UserError(`You don't have enough privileges`);
if (!hasRole || !hasRoleFromUser)
Owner

Açò ha de ferse fora del if (!hasRole)

Açò ha de ferse fora del `if (!hasRole)`
alexm marked this conversation as resolved
alexm added 1 commit 2022-10-28 06:10:03 +00:00
gitea/salix/pipeline/head This commit looks good Details
ad1b429d10
check if user has role from userToUpdate
alexm requested review from juan 2022-10-28 06:10:24 +00:00
juan approved these changes 2022-10-28 10:58:06 +00:00
alexm merged commit 70c97120b3 into master 2022-10-28 11:15:58 +00:00
alexm deleted branch 4073-user-hasGrant-master 2022-10-28 11:15:59 +00:00
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: verdnatura/salix#1107
No description provided.