0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Added collections CRUD permissions

refs https://github.com/TryGhost/Team/issues/3220

- Added permissions for collection resources
This commit is contained in:
Naz 2023-06-07 17:23:54 +07:00 committed by naz
parent abf45dcd14
commit 05bb82cf1a
6 changed files with 133 additions and 13 deletions

View file

@ -0,0 +1,54 @@
const {combineTransactionalMigrations, addPermissionWithRoles} = require('../../utils');
module.exports = combineTransactionalMigrations(
addPermissionWithRoles({
name: 'Browse collections',
action: 'browse',
object: 'collection'
}, [
'Administrator',
'Admin Integration',
'Editor',
'Author',
'Contributor'
]),
addPermissionWithRoles({
name: 'Read collections',
action: 'read',
object: 'collection'
}, [
'Administrator',
'Admin Integration',
'Editor',
'Author',
'Contributor'
]),
addPermissionWithRoles({
name: 'Edit collections',
action: 'edit',
object: 'collection'
}, [
'Administrator',
'Admin Integration',
'Editor'
]),
addPermissionWithRoles({
name: 'Add collections',
action: 'add',
object: 'collection'
}, [
'Administrator',
'Admin Integration',
'Editor',
'Author'
]),
addPermissionWithRoles({
name: 'Delete collections',
action: 'destroy',
object: 'collection'
}, [
'Administrator',
'Admin Integration',
'Editor'
])
);

View file

@ -642,6 +642,31 @@
"name": "Browse mentions",
"action_type": "browse",
"object_type": "mention"
},
{
"name": "Browse collections",
"action_type": "browse",
"object_type": "collection"
},
{
"name": "Read collections",
"action_type": "read",
"object_type": "collection"
},
{
"name": "Edit collections",
"action_type": "edit",
"object_type": "collection"
},
{
"name": "Add collections",
"action_type": "add",
"object_type": "collection"
},
{
"name": "Delete collections",
"action_type": "destroy",
"object_type": "collection"
}
]
},
@ -785,7 +810,8 @@
"explore": "read",
"comment": "all",
"link": "all",
"mention": "browse"
"mention": "browse",
"collection": "all"
},
"DB Backup Integration": {
"db": "all"
@ -826,7 +852,8 @@
"explore": "read",
"comment": "all",
"link": "all",
"mention": "browse"
"mention": "browse",
"collection": "all"
},
"Editor": {
"notification": "all",
@ -843,7 +870,8 @@
"snippet": "all",
"label": ["browse", "read"],
"product": ["browse", "read"],
"newsletter": ["browse", "read"]
"newsletter": ["browse", "read"],
"collection": "all"
},
"Author": {
"post": ["browse", "read", "add"],
@ -858,7 +886,8 @@
"snippet": ["browse", "read"],
"label": ["browse", "read"],
"product": ["browse", "read"],
"newsletter": ["browse", "read"]
"newsletter": ["browse", "read"],
"collection": ["browse", "read", "add"]
},
"Contributor": {
"post": ["browse", "read", "add"],
@ -870,7 +899,8 @@
"theme": ["browse"],
"email_preview": "read",
"email": "read",
"snippet": ["browse", "read"]
"snippet": ["browse", "read"],
"collection": ["browse", "read"]
}
}
},

View file

@ -45,7 +45,7 @@ describe('Database Migration (special functions)', function () {
const permissions = this.obj;
// If you have to change this number, please add the relevant `havePermission` checks below
permissions.length.should.eql(110);
permissions.length.should.eql(115);
permissions.should.havePermission('Export database', ['Administrator', 'DB Backup Integration']);
permissions.should.havePermission('Import database', ['Administrator', 'Self-Serve Migration Integration', 'DB Backup Integration']);
@ -182,6 +182,12 @@ describe('Database Migration (special functions)', function () {
permissions.should.havePermission('Report comments', ['Administrator', 'Admin Integration']);
permissions.should.havePermission('Browse links', ['Administrator', 'Admin Integration']);
permissions.should.havePermission('Browse mentions', ['Administrator', 'Admin Integration']);
permissions.should.havePermission('Browse collections', ['Administrator', 'Editor', 'Author', 'Contributor', 'Admin Integration']);
permissions.should.havePermission('Read collections', ['Administrator', 'Editor', 'Author', 'Contributor', 'Admin Integration']);
permissions.should.havePermission('Edit collections', ['Administrator', 'Editor', 'Admin Integration']);
permissions.should.havePermission('Add collections', ['Administrator', 'Editor', 'Author', 'Admin Integration']);
permissions.should.havePermission('Delete collections', ['Administrator', 'Editor', 'Admin Integration']);
});
describe('Populate', function () {

View file

@ -191,7 +191,7 @@ describe('Migration Fixture Utils', function () {
const rolesAllStub = sinon.stub(models.Role, 'findAll').returns(Promise.resolve(dataMethodStub));
fixtureManager.addFixturesForRelation(fixtures.relations[0]).then(function (result) {
const FIXTURE_COUNT = 101;
const FIXTURE_COUNT = 106;
should.exist(result);
result.should.be.an.Object();
result.should.have.property('expected', FIXTURE_COUNT);

View file

@ -36,7 +36,7 @@ const validateRouteSettings = require('../../../../../core/server/services/route
describe('DB version integrity', function () {
// Only these variables should need updating
const currentSchemaHash = '2445c734ffb514d11b56e74591bcde4e';
const currentFixturesHash = '869ceb3302303494c645f4201540ead3';
const currentFixturesHash = '93c3b3cb8bca34a733634e74ee514172';
const currentSettingsHash = '4f23a583335dcb4cb3fae553122ea200';
const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01';

View file

@ -642,6 +642,31 @@
"name": "Browse mentions",
"action_type": "browse",
"object_type": "mention"
},
{
"name": "Browse collections",
"action_type": "browse",
"object_type": "collection"
},
{
"name": "Read collections",
"action_type": "read",
"object_type": "collection"
},
{
"name": "Edit collections",
"action_type": "edit",
"object_type": "collection"
},
{
"name": "Add collections",
"action_type": "add",
"object_type": "collection"
},
{
"name": "Delete collections",
"action_type": "destroy",
"object_type": "collection"
}
]
},
@ -965,7 +990,8 @@
"explore": "read",
"comment": "all",
"link": "all",
"mention": "browse"
"mention": "browse",
"collection": "all"
},
"DB Backup Integration": {
"db": "all"
@ -1006,7 +1032,8 @@
"explore": "read",
"comment": "all",
"link": "all",
"mention": "browse"
"mention": "browse",
"collection": "all"
},
"Editor": {
"notification": "all",
@ -1023,7 +1050,8 @@
"snippet": "all",
"label": ["browse", "read"],
"product": ["browse", "read"],
"newsletter": ["browse", "read"]
"newsletter": ["browse", "read"],
"collection": "all"
},
"Author": {
"post": ["browse", "read", "add"],
@ -1038,7 +1066,8 @@
"snippet": ["browse", "read"],
"label": ["browse", "read"],
"product": ["browse", "read"],
"newsletter": ["browse", "read"]
"newsletter": ["browse", "read"],
"collection": ["browse", "read", "add"]
},
"Contributor": {
"post": ["browse", "read", "add"],
@ -1050,7 +1079,8 @@
"theme": ["browse"],
"email_preview": "read",
"email": "read",
"snippet": ["browse", "read"]
"snippet": ["browse", "read"],
"collection": ["browse", "read"]
}
}
},