mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-28 00:06:53 +01:00
350b55644a
<!-- Thanks for creating a PR! To make it easier for reviewers and
everyone else to understand what your changes relate to, please add some
relevant content to the headings below. Feel free to ignore or delete
sections that you don't think are relevant. Thank you! ❤️ -->
## About the changes
<!-- Describe the changes introduced. What are they and why are they
being introduced? Feel free to also add screenshots or steps to view the
changes if they're visual. -->
Define and implements Project api token permissions
Assign permissions to existing roles
Adjust UI to support them
Adjust BE to implement
---------
Signed-off-by: andreas-unleash <andreas@getunleash.ai>
Co-authored-by: Fredrik Strand Oseberg <fredrik.no@gmail.com>
30 lines
1016 B
JavaScript
30 lines
1016 B
JavaScript
exports.up = function (db, cb) {
|
|
db.runSql(
|
|
`
|
|
INSERT INTO role_permission (role_id, permission_id)
|
|
SELECT (SELECT id as role_id from roles WHERE name = 'Owner' LIMIT 1),
|
|
p.id as permission_id
|
|
FROM permissions p
|
|
WHERE p.permission IN
|
|
('READ_PROJECT_API_TOKEN',
|
|
'CREATE_PROJECT_API_TOKEN',
|
|
'DELETE_PROJECT_API_TOKEN');
|
|
`,
|
|
cb,
|
|
);
|
|
};
|
|
|
|
exports.down = function (db, cb) {
|
|
db.runSql(
|
|
`
|
|
DELETE FROM role_permission
|
|
WHERE permission_id IN (SELECT id from permissions WHERE permission IN ('READ_PROJECT_API_TOKEN',
|
|
'CREATE_PROJECT_API_TOKEN',
|
|
'DELETE_PROJECT_API_TOKEN'))
|
|
AND role_id = (SELECT id as role_id from roles WHERE name = 'Owner' LIMIT 1)
|
|
|
|
`,
|
|
cb,
|
|
);
|
|
};
|