Skip to content

Commit 19863e9

Browse files
author
Maksym Mykhailenko
committed
fix: permission rule for billingAccountId
1 parent 58070b9 commit 19863e9

File tree

4 files changed

+40
-42
lines changed

4 files changed

+40
-42
lines changed

docs/permissions.html

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,29 @@ <h2 class="anchor-container">
294294
</div>
295295
</div>
296296
</div>
297+
<div class="row border-top">
298+
<div class="col py-2">
299+
<div class="permission-title anchor-container">
300+
<a href="#MANAGE_PROJECT_BILLING_ACCOUNT_ID" name="MANAGE_PROJECT_BILLING_ACCOUNT_ID" class="anchor"></a>Manage Project property &quot;billingAccountId&quot;
301+
</div>
302+
<div class="permission-variable"><small><code>MANAGE_PROJECT_BILLING_ACCOUNT_ID</code></small></div>
303+
<div class="text-black-50 small-text">Who can set or update the &quot;billingAccountId&quot; property.</div>
304+
</div>
305+
<div class="col-9 py-2">
306+
<div>
307+
</div>
308+
309+
<div>
310+
<span class="badge badge-success" title="Allowed Topcoder Role">Connect Manager</span>
311+
<span class="badge badge-success" title="Allowed Topcoder Role">administrator</span>
312+
</div>
313+
314+
<div>
315+
<span class="badge badge-dark" title="Allowed Topcoder Role">all:connect_project</span>
316+
<span class="badge badge-dark" title="Allowed Topcoder Role">write:projects-billing-accounts</span>
317+
</div>
318+
</div>
319+
</div>
297320
<div class="row border-top">
298321
<div class="col py-2">
299322
<div class="permission-title anchor-container">
@@ -332,30 +355,6 @@ <h2 class="anchor-container">
332355
</div>
333356
</div>
334357
</div>
335-
<div class="row border-top">
336-
<div class="col py-2">
337-
<div class="permission-title anchor-container">
338-
<a href="#MANAGE_PROJECT_BILLING_ACCOUNT_ID" name="MANAGE_PROJECT_BILLING_ACCOUNT_ID" class="anchor"></a>Manage Project property &quot;billingAccountId&quot;
339-
</div>
340-
<div class="permission-variable"><small><code>MANAGE_PROJECT_BILLING_ACCOUNT_ID</code></small></div>
341-
<div class="text-black-50 small-text">Who can set or update the &quot;billingAccountId&quot; property.</div>
342-
</div>
343-
<div class="col-9 py-2">
344-
<div>
345-
</div>
346-
347-
<div>
348-
<span class="badge badge-success" title="Allowed Topcoder Role">Connect Manager</span>
349-
<span class="badge badge-success" title="Allowed Topcoder Role">administrator</span>
350-
</div>
351-
352-
<div>
353-
<span class="badge badge-dark" title="Allowed Topcoder Role">all:connect_project</span>
354-
<span class="badge badge-dark" title="Allowed Topcoder Role">all:projects</span>
355-
<span class="badge badge-dark" title="Allowed Topcoder Role">write:projects-billing-accounts</span>
356-
</div>
357-
</div>
358-
</div>
359358
<div class="row">
360359
<div class="col pt-5 pb-2">
361360
<h2 class="anchor-container">

src/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ export const REGEX = {
268268
};
269269

270270
export const M2M_SCOPES = {
271+
// for backward compatibility we should allow ALL M2M operations with `CONNECT_PROJECT_ADMIN`
271272
CONNECT_PROJECT_ADMIN: 'all:connect_project',
272273
PROJECTS: {
273274
ALL: 'all:projects',

src/permissions/constants.js

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ const SCOPES_PROJECTS_WRITE = [
7676

7777
const SCOPES_PROJECTS_WRITE_BILLING_ACCOUNTS = [
7878
M2M_SCOPES.CONNECT_PROJECT_ADMIN,
79-
M2M_SCOPES.PROJECTS.ALL,
8079
M2M_SCOPES.PROJECTS.WRITE_BILLING_ACCOUNTS,
8180
];
8281

@@ -161,6 +160,19 @@ export const PERMISSION = { // eslint-disable-line import/prefer-default-export
161160
scopes: SCOPES_PROJECTS_WRITE,
162161
},
163162

163+
MANAGE_PROJECT_BILLING_ACCOUNT_ID: {
164+
meta: {
165+
title: 'Manage Project property "billingAccountId"',
166+
group: 'Project',
167+
description: 'Who can set or update the "billingAccountId" property.',
168+
},
169+
topcoderRoles: [
170+
USER_ROLE.MANAGER,
171+
USER_ROLE.TOPCODER_ADMIN,
172+
],
173+
scopes: SCOPES_PROJECTS_WRITE_BILLING_ACCOUNTS,
174+
},
175+
164176
DELETE_PROJECT: {
165177
meta: {
166178
title: 'Delete Project',
@@ -179,19 +191,6 @@ export const PERMISSION = { // eslint-disable-line import/prefer-default-export
179191
scopes: SCOPES_PROJECTS_WRITE,
180192
},
181193

182-
MANAGE_PROJECT_BILLING_ACCOUNT_ID: {
183-
meta: {
184-
title: 'Manage Project property "billingAccountId"',
185-
group: 'Project',
186-
description: 'Who can set or update the "billingAccountId" property.',
187-
},
188-
topcoderRoles: [
189-
USER_ROLE.MANAGER,
190-
USER_ROLE.TOPCODER_ADMIN,
191-
],
192-
scopes: SCOPES_PROJECTS_WRITE_BILLING_ACCOUNTS,
193-
},
194-
195194
/*
196195
* Project Member
197196
*/

src/routes/projects/update.spec.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
PROJECT_STATUS,
1515
BUS_API_EVENT,
1616
CONNECT_NOTIFICATION_EVENT,
17-
M2M_SCOPES,
1817
} from '../../constants';
1918

2019
const should = chai.should();
@@ -192,11 +191,11 @@ describe('Project', () => {
192191
});
193192
});
194193

195-
it(`should return the project using M2M token with "${M2M_SCOPES.PROJECTS.WRITE}" scope`, (done) => {
194+
it('should return the project using M2M token with "write:projects" scope', (done) => {
196195
request(server)
197196
.patch(`/v5/projects/${project1.id}`)
198197
.set({
199-
Authorization: `Bearer ${testUtil.m2m[M2M_SCOPES.PROJECTS.WRITE]}`,
198+
Authorization: `Bearer ${testUtil.m2m['write:projects']}`,
200199
})
201200
.send({
202201
name: 'updateProject name by M2M',
@@ -664,7 +663,7 @@ describe('Project', () => {
664663
request(server)
665664
.patch(`/v5/projects/${project1.id}`)
666665
.set({
667-
Authorization: `Bearer ${testUtil.m2m[M2M_SCOPES.PROJECTS.WRITE]}`,
666+
Authorization: `Bearer ${testUtil.m2m['write:projects-billing-accounts']}`,
668667
})
669668
.send({
670669
billingAccountId: 123,

0 commit comments

Comments
 (0)