Skip to content

Commit 903b456

Browse files
authored
Merge pull request #42 from topcoder-platform/develop
feat: add authorization to stats endpoint
2 parents 54c4039 + 7bfac47 commit 903b456

11 files changed

+440
-112
lines changed

config/default.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module.exports = {
77
PORT: process.env.PORT || 3000,
88
API_VERSION: process.env.API_VERSION || 'v5',
99
AUTH_SECRET: process.env.AUTH_SECRET || 'mysecret',
10-
VALID_ISSUERS: process.env.VALID_ISSUERS || '["https://api.topcoder-dev.com", "https://api.topcoder.com", "https://topcoder-dev.auth0.com/"]',
10+
VALID_ISSUERS: process.env.VALID_ISSUERS || '["https://api.topcoder-dev.com", "https://api.topcoder.com", "https://topcoder-dev.auth0.com/", "https://auth.topcoder-dev.com/"]',
1111

1212
// used to get M2M token
1313
AUTH0_URL: process.env.AUTH0_URL,
@@ -27,7 +27,7 @@ module.exports = {
2727
TAGS_API_VERSION: process.env.TAGS_API_VERSION || '/v3',
2828
TAGS_FILTER: process.env.TAGS_FILTER || '/tags/?filter=domain%3DSKILLS%26status%3DAPPROVED&limit=1000'
2929
},
30-
GROUPS_API_URL: process.env.GROUPS_API_URL, //|| 'https://api.topcoder-dev.com/v5/groups',
30+
GROUPS_API_URL: process.env.GROUPS_API_URL, // || 'https://api.topcoder-dev.com/v5/groups',
3131
// aws config params
3232
AMAZON: {
3333
AWS_ACCESS_KEY_ID: process.env.AWS_ACCESS_KEY_ID,
@@ -111,5 +111,10 @@ module.exports = {
111111
// Member Statistics identifiable info fields, only admin, M2M, or member himself can fetch these fields
112112
STATISTICS_SECURE_FIELDS: process.env.STATISTICS_SECURE_FIELDS
113113
? process.env.STATISTICS_SECURE_FIELDS.split(',')
114-
: ['createdBy', 'updatedBy']
114+
: ['createdBy', 'updatedBy'],
115+
116+
// Public group id
117+
PUBLIC_GROUP_ID: process.env.PUBLIC_GROUP_ID || '10',
118+
// Private group ids will be excluded from results for non-admin users.
119+
PRIVATE_GROUP_IDS: JSON.parse(process.env.PRIVATE_GROUP_IDS || '["20000000"]')
115120
}

docs/member-api.postman_collection.json

+292-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"info": {
3-
"_postman_id": "03129edd-111f-4875-924d-2ffd2c0c18eb",
3+
"_postman_id": "2e554101-d99e-4522-8ce5-39ff8e6cca0e",
44
"name": "member-api",
55
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
66
},
@@ -3617,13 +3617,13 @@
36173617
}
36183618
],
36193619
"url": {
3620-
"raw": "{{URL}}/members/standlove/stats/history?fields=userId,handle,DATA_SCIENCE,DEVELOP,createdBy",
3620+
"raw": "{{URL}}/members/denis/stats/history?fields=userId,handle,DATA_SCIENCE,DEVELOP,createdBy",
36213621
"host": [
36223622
"{{URL}}"
36233623
],
36243624
"path": [
36253625
"members",
3626-
"standlove",
3626+
"denis",
36273627
"stats",
36283628
"history"
36293629
],
@@ -3667,20 +3667,138 @@
36673667
}
36683668
],
36693669
"url": {
3670-
"raw": "{{URL}}/members/standlove/stats/history?groupIds=10,20000000&fields=userId,handle,groupId",
3670+
"raw": "{{URL}}/members/denis/stats/history?groupIds=10,20000001&fields=userId,handle,groupId",
36713671
"host": [
36723672
"{{URL}}"
36733673
],
36743674
"path": [
36753675
"members",
3676-
"standlove",
3676+
"denis",
3677+
"stats",
3678+
"history"
3679+
],
3680+
"query": [
3681+
{
3682+
"key": "groupIds",
3683+
"value": "10,20000001"
3684+
},
3685+
{
3686+
"key": "fields",
3687+
"value": "userId,handle,groupId"
3688+
}
3689+
]
3690+
}
3691+
},
3692+
"response": []
3693+
},
3694+
{
3695+
"name": "get member history private statistics - groupIds by admin",
3696+
"event": [
3697+
{
3698+
"listen": "test",
3699+
"script": {
3700+
"exec": [
3701+
"pm.test(\"Status code is 200\", function () {",
3702+
" pm.response.to.have.status(200);",
3703+
"});"
3704+
],
3705+
"type": "text/javascript"
3706+
}
3707+
}
3708+
],
3709+
"request": {
3710+
"method": "GET",
3711+
"header": [
3712+
{
3713+
"key": "Accept",
3714+
"type": "text",
3715+
"value": "application/json"
3716+
},
3717+
{
3718+
"key": "Content-Type",
3719+
"type": "text",
3720+
"value": "application/json"
3721+
},
3722+
{
3723+
"key": "Authorization",
3724+
"value": "Bearer {{admin_token}}",
3725+
"type": "text"
3726+
}
3727+
],
3728+
"url": {
3729+
"raw": "{{URL}}/members/denis/stats/history?groupIds=10,20000001&fields=userId,handle,groupId",
3730+
"host": [
3731+
"{{URL}}"
3732+
],
3733+
"path": [
3734+
"members",
3735+
"denis",
3736+
"stats",
3737+
"history"
3738+
],
3739+
"query": [
3740+
{
3741+
"key": "groupIds",
3742+
"value": "10,20000001"
3743+
},
3744+
{
3745+
"key": "fields",
3746+
"value": "userId,handle,groupId"
3747+
}
3748+
]
3749+
}
3750+
},
3751+
"response": []
3752+
},
3753+
{
3754+
"name": "get member history private statistics - groupIds by member himself",
3755+
"event": [
3756+
{
3757+
"listen": "test",
3758+
"script": {
3759+
"exec": [
3760+
"pm.test(\"Status code is 200\", function () {",
3761+
" pm.response.to.have.status(200);",
3762+
"});"
3763+
],
3764+
"type": "text/javascript"
3765+
}
3766+
}
3767+
],
3768+
"request": {
3769+
"method": "GET",
3770+
"header": [
3771+
{
3772+
"key": "Accept",
3773+
"type": "text",
3774+
"value": "application/json"
3775+
},
3776+
{
3777+
"key": "Content-Type",
3778+
"type": "text",
3779+
"value": "application/json"
3780+
},
3781+
{
3782+
"key": "Authorization",
3783+
"value": "Bearer {{user_token}}",
3784+
"type": "text"
3785+
}
3786+
],
3787+
"url": {
3788+
"raw": "{{URL}}/members/denis/stats/history?groupIds=10,20000001&fields=userId,handle,groupId",
3789+
"host": [
3790+
"{{URL}}"
3791+
],
3792+
"path": [
3793+
"members",
3794+
"denis",
36773795
"stats",
36783796
"history"
36793797
],
36803798
"query": [
36813799
{
36823800
"key": "groupIds",
3683-
"value": "10,20000000"
3801+
"value": "10,20000001"
36843802
},
36853803
{
36863804
"key": "fields",
@@ -3721,13 +3839,13 @@
37213839
}
37223840
],
37233841
"url": {
3724-
"raw": "{{URL}}/members/standlove/stats/history?groupIds=10,20000000,20000010&fields=userId,handle,groupId",
3842+
"raw": "{{URL}}/members/denis/stats/history?groupIds=10,20000000,20000010&fields=userId,handle,groupId",
37253843
"host": [
37263844
"{{URL}}"
37273845
],
37283846
"path": [
37293847
"members",
3730-
"standlove",
3848+
"denis",
37313849
"stats",
37323850
"history"
37333851
],
@@ -4062,6 +4180,114 @@
40624180
},
40634181
"response": []
40644182
},
4183+
{
4184+
"name": "get member private statistics with admin token",
4185+
"event": [
4186+
{
4187+
"listen": "test",
4188+
"script": {
4189+
"exec": [
4190+
"pm.test(\"Status code is 200\", function () {",
4191+
" pm.response.to.have.status(200);",
4192+
"});"
4193+
],
4194+
"type": "text/javascript"
4195+
}
4196+
}
4197+
],
4198+
"request": {
4199+
"method": "GET",
4200+
"header": [
4201+
{
4202+
"key": "Accept",
4203+
"type": "text",
4204+
"value": "application/json"
4205+
},
4206+
{
4207+
"key": "Content-Type",
4208+
"type": "text",
4209+
"value": "application/json"
4210+
},
4211+
{
4212+
"key": "Authorization",
4213+
"value": "Bearer {{admin_token}}",
4214+
"type": "text"
4215+
}
4216+
],
4217+
"url": {
4218+
"raw": "{{URL}}/members/denis/stats?groupIds=10,d6bf6bb6-457c-461c-a4d6-0a6b1a87fde9",
4219+
"host": [
4220+
"{{URL}}"
4221+
],
4222+
"path": [
4223+
"members",
4224+
"denis",
4225+
"stats"
4226+
],
4227+
"query": [
4228+
{
4229+
"key": "groupIds",
4230+
"value": "10,d6bf6bb6-457c-461c-a4d6-0a6b1a87fde9"
4231+
}
4232+
]
4233+
}
4234+
},
4235+
"response": []
4236+
},
4237+
{
4238+
"name": "get member private statistics by user himself",
4239+
"event": [
4240+
{
4241+
"listen": "test",
4242+
"script": {
4243+
"exec": [
4244+
"pm.test(\"Status code is 200\", function () {",
4245+
" pm.response.to.have.status(200);",
4246+
"});"
4247+
],
4248+
"type": "text/javascript"
4249+
}
4250+
}
4251+
],
4252+
"request": {
4253+
"method": "GET",
4254+
"header": [
4255+
{
4256+
"key": "Accept",
4257+
"type": "text",
4258+
"value": "application/json"
4259+
},
4260+
{
4261+
"key": "Content-Type",
4262+
"type": "text",
4263+
"value": "application/json"
4264+
},
4265+
{
4266+
"key": "Authorization",
4267+
"value": "Bearer {{user_token}}",
4268+
"type": "text"
4269+
}
4270+
],
4271+
"url": {
4272+
"raw": "{{URL}}/members/denis/stats?groupIds=10,d6bf6bb6-457c-461c-a4d6-0a6b1a87fde9",
4273+
"host": [
4274+
"{{URL}}"
4275+
],
4276+
"path": [
4277+
"members",
4278+
"denis",
4279+
"stats"
4280+
],
4281+
"query": [
4282+
{
4283+
"key": "groupIds",
4284+
"value": "10,d6bf6bb6-457c-461c-a4d6-0a6b1a87fde9"
4285+
}
4286+
]
4287+
}
4288+
},
4289+
"response": []
4290+
},
40654291
{
40664292
"name": "get member private statistics - multiple group Ids",
40674293
"event": [
@@ -4115,6 +4341,64 @@
41154341
},
41164342
"response": []
41174343
},
4344+
{
4345+
"name": "get member private statistics - multiple group Ids with admin token",
4346+
"event": [
4347+
{
4348+
"listen": "test",
4349+
"script": {
4350+
"exec": [
4351+
"pm.test(\"Status code is 200\", function () {",
4352+
" pm.response.to.have.status(200);",
4353+
"});"
4354+
],
4355+
"type": "text/javascript"
4356+
}
4357+
}
4358+
],
4359+
"request": {
4360+
"method": "GET",
4361+
"header": [
4362+
{
4363+
"key": "Accept",
4364+
"type": "text",
4365+
"value": "application/json"
4366+
},
4367+
{
4368+
"key": "Content-Type",
4369+
"type": "text",
4370+
"value": "application/json"
4371+
},
4372+
{
4373+
"key": "Authorization",
4374+
"value": "Bearer {{admin_token}}",
4375+
"type": "text"
4376+
}
4377+
],
4378+
"url": {
4379+
"raw": "{{URL}}/members/denis/stats?groupIds=10,d6bf6bb6-457c-461c-a4d6-0a6b1a87fde9&fields=userId,handle,wins,groupId,challenges",
4380+
"host": [
4381+
"{{URL}}"
4382+
],
4383+
"path": [
4384+
"members",
4385+
"denis",
4386+
"stats"
4387+
],
4388+
"query": [
4389+
{
4390+
"key": "groupIds",
4391+
"value": "10,d6bf6bb6-457c-461c-a4d6-0a6b1a87fde9"
4392+
},
4393+
{
4394+
"key": "fields",
4395+
"value": "userId,handle,wins,groupId,challenges"
4396+
}
4397+
]
4398+
}
4399+
},
4400+
"response": []
4401+
},
41184402
{
41194403
"name": "get member statistics - userId,handle,wins,develop,design",
41204404
"event": [

0 commit comments

Comments
 (0)