Skip to content

Commit 1d2bba2

Browse files
committed
Merge branch 'feature/attachmentPermissions' of https://github.com/topcoder-platform/tc-project-service into feature/attachmentPermissions
2 parents 4b5f7fe + cc4cd9c commit 1d2bba2

File tree

20 files changed

+1573
-23
lines changed

20 files changed

+1573
-23
lines changed

config/default.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"idleTimeout": 1000
3636
},
3737
"kafkaConfig": {
38+
"hosts": "localhost:9092"
3839
},
3940
"analyticsKey": "",
4041
"VALID_ISSUERS": "[\"https:\/\/topcoder-newauth.auth0.com\/\",\"https:\/\/api.topcoder-dev.com\"]",
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--
2+
-- CREATE NEW TABLE:
3+
-- org_config
4+
--
5+
CREATE TABLE org_config (
6+
id bigint NOT NULL,
7+
"orgId" character varying(45) NOT NULL,
8+
"configName" character varying(45) NOT NULL,
9+
"configValue" character varying(512),
10+
"deletedAt" timestamp with time zone,
11+
"createdAt" timestamp with time zone,
12+
"updatedAt" timestamp with time zone,
13+
"deletedBy" bigint,
14+
"createdBy" bigint NOT NULL,
15+
"updatedBy" bigint NOT NULL
16+
);
17+
18+
CREATE SEQUENCE org_config_id_seq
19+
START WITH 1
20+
INCREMENT BY 1
21+
NO MINVALUE
22+
NO MAXVALUE
23+
CACHE 1;
24+
25+
ALTER SEQUENCE org_config_id_seq OWNED BY org_config.id;
26+
27+
ALTER TABLE org_config
28+
ALTER COLUMN id SET DEFAULT nextval('org_config_id_seq');

package-lock.json

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

postman.json

Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3476,6 +3476,216 @@
34763476
}
34773477
]
34783478
},
3479+
{
3480+
"name": "Organization Config",
3481+
"item": [
3482+
{
3483+
"name": "Create organization config",
3484+
"request": {
3485+
"method": "POST",
3486+
"header": [
3487+
{
3488+
"key": "Content-Type",
3489+
"value": "application/json"
3490+
},
3491+
{
3492+
"key": "Authorization",
3493+
"value": "Bearer {{jwt-token}}"
3494+
}
3495+
],
3496+
"body": {
3497+
"mode": "raw",
3498+
"raw": "{\r\n \"param\":{\r\n \"orgId\": \"20000013\",\r\n \"configName\": \"project_catalog_url\",\r\n \"configValue\": \"/projects/1\"\r\n }\r\n}"
3499+
},
3500+
"url": {
3501+
"raw": "{{api-url}}/v4/projects/metadata/orgConfig",
3502+
"host": [
3503+
"{{api-url}}"
3504+
],
3505+
"path": [
3506+
"v4",
3507+
"projects",
3508+
"metadata",
3509+
"orgConfig"
3510+
]
3511+
}
3512+
},
3513+
"response": []
3514+
},
3515+
{
3516+
"name": "List organization config - error without filter",
3517+
"request": {
3518+
"method": "GET",
3519+
"header": [
3520+
{
3521+
"key": "Content-Type",
3522+
"value": "application/json"
3523+
},
3524+
{
3525+
"key": "Authorization",
3526+
"value": "Bearer {{jwt-token}}"
3527+
}
3528+
],
3529+
"body": {
3530+
"mode": "raw",
3531+
"raw": ""
3532+
},
3533+
"url": {
3534+
"raw": "{{api-url}}/v4/projects/metadata/orgConfig",
3535+
"host": [
3536+
"{{api-url}}"
3537+
],
3538+
"path": [
3539+
"v4",
3540+
"projects",
3541+
"metadata",
3542+
"orgConfig"
3543+
]
3544+
}
3545+
},
3546+
"response": []
3547+
},
3548+
{
3549+
"name": "List organization config - filter",
3550+
"request": {
3551+
"method": "GET",
3552+
"header": [
3553+
{
3554+
"key": "Content-Type",
3555+
"value": "application/json"
3556+
},
3557+
{
3558+
"key": "Authorization",
3559+
"value": "Bearer {{jwt-token}}"
3560+
}
3561+
],
3562+
"body": {
3563+
"mode": "raw",
3564+
"raw": ""
3565+
},
3566+
"url": {
3567+
"raw": "{{api-url}}/v4/orgConfig?filter=orgId=in(20000010,20000013,20000015)%26configName%3Dproject_catalog_url",
3568+
"host": [
3569+
"{{api-url}}"
3570+
],
3571+
"path": [
3572+
"v4",
3573+
"orgConfig"
3574+
],
3575+
"query": [
3576+
{
3577+
"key": "filter",
3578+
"value": "orgId=in(20000010,20000013,20000015)%26configName%3Dproject_catalog_url"
3579+
}
3580+
]
3581+
}
3582+
},
3583+
"response": []
3584+
},
3585+
{
3586+
"name": "Get organization config",
3587+
"request": {
3588+
"method": "GET",
3589+
"header": [
3590+
{
3591+
"key": "Content-Type",
3592+
"value": "application/json"
3593+
},
3594+
{
3595+
"key": "Authorization",
3596+
"value": "Bearer {{jwt-token}}"
3597+
}
3598+
],
3599+
"body": {
3600+
"mode": "raw",
3601+
"raw": ""
3602+
},
3603+
"url": {
3604+
"raw": "{{api-url}}/v4/projects/metadata/orgConfig/1",
3605+
"host": [
3606+
"{{api-url}}"
3607+
],
3608+
"path": [
3609+
"v4",
3610+
"projects",
3611+
"metadata",
3612+
"orgConfig",
3613+
"1"
3614+
]
3615+
}
3616+
},
3617+
"response": []
3618+
},
3619+
{
3620+
"name": "Update organization config",
3621+
"request": {
3622+
"method": "PATCH",
3623+
"header": [
3624+
{
3625+
"key": "Content-Type",
3626+
"value": "application/json"
3627+
},
3628+
{
3629+
"key": "Authorization",
3630+
"value": "Bearer {{jwt-token}}"
3631+
}
3632+
],
3633+
"body": {
3634+
"mode": "raw",
3635+
"raw": "{\r\n \"param\":{\r\n \"configName\": \"project_catalog_url\"\r\n }\r\n}"
3636+
},
3637+
"url": {
3638+
"raw": "{{api-url}}/v4/projects/metadata/orgConfig/1",
3639+
"host": [
3640+
"{{api-url}}"
3641+
],
3642+
"path": [
3643+
"v4",
3644+
"projects",
3645+
"metadata",
3646+
"orgConfig",
3647+
"1"
3648+
]
3649+
}
3650+
},
3651+
"response": []
3652+
},
3653+
{
3654+
"name": "Delete organization config",
3655+
"request": {
3656+
"method": "DELETE",
3657+
"header": [
3658+
{
3659+
"key": "Content-Type",
3660+
"value": "application/json"
3661+
},
3662+
{
3663+
"key": "Authorization",
3664+
"value": "Bearer {{jwt-token}}"
3665+
}
3666+
],
3667+
"body": {
3668+
"mode": "raw",
3669+
"raw": ""
3670+
},
3671+
"url": {
3672+
"raw": "{{api-url}}/v4/projects/metadata/orgConfig/1",
3673+
"host": [
3674+
"{{api-url}}"
3675+
],
3676+
"path": [
3677+
"v4",
3678+
"projects",
3679+
"metadata",
3680+
"orgConfig",
3681+
"1"
3682+
]
3683+
}
3684+
},
3685+
"response": []
3686+
}
3687+
]
3688+
},
34793689
{
34803690
"name": "Product Category",
34813691
"item": [

src/models/orgConfig.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/* eslint-disable valid-jsdoc */
2+
3+
/**
4+
* The Organization config model
5+
*/
6+
module.exports = (sequelize, DataTypes) => {
7+
const OrgConfig = sequelize.define('OrgConfig', {
8+
id: { type: DataTypes.BIGINT, primaryKey: true, autoIncrement: true },
9+
orgId: { type: DataTypes.STRING(45), allowNull: false },
10+
configName: { type: DataTypes.STRING(45), allowNull: false },
11+
configValue: { type: DataTypes.STRING(512) },
12+
deletedAt: DataTypes.DATE,
13+
createdAt: { type: DataTypes.DATE, defaultValue: DataTypes.NOW },
14+
updatedAt: { type: DataTypes.DATE, defaultValue: DataTypes.NOW },
15+
deletedBy: DataTypes.BIGINT,
16+
createdBy: { type: DataTypes.BIGINT, allowNull: false },
17+
updatedBy: { type: DataTypes.BIGINT, allowNull: false },
18+
}, {
19+
tableName: 'org_config',
20+
paranoid: true,
21+
timestamps: true,
22+
updatedAt: 'updatedAt',
23+
createdAt: 'createdAt',
24+
deletedAt: 'deletedAt',
25+
});
26+
27+
return OrgConfig;
28+
};

src/permissions/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ module.exports = () => {
5656
Authorizer.setPolicy('projectType.delete', projectAdmin);
5757
Authorizer.setPolicy('projectType.view', true); // anyone can view project types
5858

59+
Authorizer.setPolicy('orgConfig.create', projectAdmin);
60+
Authorizer.setPolicy('orgConfig.edit', projectAdmin);
61+
Authorizer.setPolicy('orgConfig.delete', projectAdmin);
62+
Authorizer.setPolicy('orgConfig.view', true); // anyone can view project types
63+
5964
Authorizer.setPolicy('productCategory.create', projectAdmin);
6065
Authorizer.setPolicy('productCategory.edit', projectAdmin);
6166
Authorizer.setPolicy('productCategory.delete', projectAdmin);

src/routes/index.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ router.route('/v4/projects/metadata/projectTypes')
4242
router.route('/v4/projects/metadata/projectTypes/:key')
4343
.get(require('./projectTypes/get'));
4444

45+
router.route('/v4/projects/metadata/orgConfig')
46+
.get(require('./orgConfig/list'));
47+
48+
router.route('/v4/projects/metadata/orgConfig/:id(\\d+)')
49+
.get(require('./orgConfig/get'));
50+
4551
router.route('/v4/projects/metadata/productCategories')
4652
.get(require('./productCategories/list'));
4753
router.route('/v4/projects/metadata/productCategories/:key')
@@ -53,7 +59,7 @@ router.route('/v4/projects/metadata')
5359
.get(require('./metadata/list'));
5460

5561
router.all(
56-
RegExp(`\\/${apiVersion}\\/(projects|timelines)(?!\\/health).*`), (req, res, next) => (
62+
RegExp(`\\/${apiVersion}\\/(projects|timelines|orgConfig)(?!\\/health).*`), (req, res, next) => (
5763
// JWT authentication
5864
jwtAuth(config)(req, res, next)
5965
),
@@ -182,6 +188,13 @@ router.route('/v4/projects/:projectId(\\d+)/members/invite')
182188
.put(require('./projectMemberInvites/update'))
183189
.get(require('./projectMemberInvites/get'));
184190

191+
router.route('/v4/projects/metadata/orgConfig')
192+
.post(require('./orgConfig/create'));
193+
194+
router.route('/v4/projects/metadata/orgConfig/:id(\\d+)')
195+
.patch(require('./orgConfig/update'))
196+
.delete(require('./orgConfig/delete'));
197+
185198
// register error handler
186199
router.use((err, req, res, next) => { // eslint-disable-line no-unused-vars
187200
// DO NOT REMOVE next arg.. even though eslint

0 commit comments

Comments
 (0)