Skip to content

feat: add authorization to stats endpoint #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
PORT: process.env.PORT || 3000,
API_VERSION: process.env.API_VERSION || 'v5',
AUTH_SECRET: process.env.AUTH_SECRET || 'mysecret',
VALID_ISSUERS: process.env.VALID_ISSUERS || '["https://api.topcoder-dev.com", "https://api.topcoder.com", "https://topcoder-dev.auth0.com/"]',
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/"]',

// used to get M2M token
AUTH0_URL: process.env.AUTH0_URL,
Expand All @@ -27,7 +27,7 @@ module.exports = {
TAGS_API_VERSION: process.env.TAGS_API_VERSION || '/v3',
TAGS_FILTER: process.env.TAGS_FILTER || '/tags/?filter=domain%3DSKILLS%26status%3DAPPROVED&limit=1000'
},
GROUPS_API_URL: process.env.GROUPS_API_URL, //|| 'https://api.topcoder-dev.com/v5/groups',
GROUPS_API_URL: process.env.GROUPS_API_URL, // || 'https://api.topcoder-dev.com/v5/groups',
// aws config params
AMAZON: {
AWS_ACCESS_KEY_ID: process.env.AWS_ACCESS_KEY_ID,
Expand Down Expand Up @@ -111,5 +111,10 @@ module.exports = {
// Member Statistics identifiable info fields, only admin, M2M, or member himself can fetch these fields
STATISTICS_SECURE_FIELDS: process.env.STATISTICS_SECURE_FIELDS
? process.env.STATISTICS_SECURE_FIELDS.split(',')
: ['createdBy', 'updatedBy']
: ['createdBy', 'updatedBy'],

// Public group id
PUBLIC_GROUP_ID: process.env.PUBLIC_GROUP_ID || '10',
// Private group ids will be excluded from results for non-admin users.
PRIVATE_GROUP_IDS: JSON.parse(process.env.PRIVATE_GROUP_IDS || '["20000000"]')
}
300 changes: 292 additions & 8 deletions docs/member-api.postman_collection.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"info": {
"_postman_id": "03129edd-111f-4875-924d-2ffd2c0c18eb",
"_postman_id": "2e554101-d99e-4522-8ce5-39ff8e6cca0e",
"name": "member-api",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
Expand Down Expand Up @@ -3617,13 +3617,13 @@
}
],
"url": {
"raw": "{{URL}}/members/standlove/stats/history?fields=userId,handle,DATA_SCIENCE,DEVELOP,createdBy",
"raw": "{{URL}}/members/denis/stats/history?fields=userId,handle,DATA_SCIENCE,DEVELOP,createdBy",
"host": [
"{{URL}}"
],
"path": [
"members",
"standlove",
"denis",
"stats",
"history"
],
Expand Down Expand Up @@ -3667,20 +3667,138 @@
}
],
"url": {
"raw": "{{URL}}/members/standlove/stats/history?groupIds=10,20000000&fields=userId,handle,groupId",
"raw": "{{URL}}/members/denis/stats/history?groupIds=10,20000001&fields=userId,handle,groupId",
"host": [
"{{URL}}"
],
"path": [
"members",
"standlove",
"denis",
"stats",
"history"
],
"query": [
{
"key": "groupIds",
"value": "10,20000001"
},
{
"key": "fields",
"value": "userId,handle,groupId"
}
]
}
},
"response": []
},
{
"name": "get member history private statistics - groupIds by admin",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"type": "text",
"value": "application/json"
},
{
"key": "Content-Type",
"type": "text",
"value": "application/json"
},
{
"key": "Authorization",
"value": "Bearer {{admin_token}}",
"type": "text"
}
],
"url": {
"raw": "{{URL}}/members/denis/stats/history?groupIds=10,20000001&fields=userId,handle,groupId",
"host": [
"{{URL}}"
],
"path": [
"members",
"denis",
"stats",
"history"
],
"query": [
{
"key": "groupIds",
"value": "10,20000001"
},
{
"key": "fields",
"value": "userId,handle,groupId"
}
]
}
},
"response": []
},
{
"name": "get member history private statistics - groupIds by member himself",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"type": "text",
"value": "application/json"
},
{
"key": "Content-Type",
"type": "text",
"value": "application/json"
},
{
"key": "Authorization",
"value": "Bearer {{user_token}}",
"type": "text"
}
],
"url": {
"raw": "{{URL}}/members/denis/stats/history?groupIds=10,20000001&fields=userId,handle,groupId",
"host": [
"{{URL}}"
],
"path": [
"members",
"denis",
"stats",
"history"
],
"query": [
{
"key": "groupIds",
"value": "10,20000000"
"value": "10,20000001"
},
{
"key": "fields",
Expand Down Expand Up @@ -3721,13 +3839,13 @@
}
],
"url": {
"raw": "{{URL}}/members/standlove/stats/history?groupIds=10,20000000,20000010&fields=userId,handle,groupId",
"raw": "{{URL}}/members/denis/stats/history?groupIds=10,20000000,20000010&fields=userId,handle,groupId",
"host": [
"{{URL}}"
],
"path": [
"members",
"standlove",
"denis",
"stats",
"history"
],
Expand Down Expand Up @@ -4062,6 +4180,114 @@
},
"response": []
},
{
"name": "get member private statistics with admin token",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"type": "text",
"value": "application/json"
},
{
"key": "Content-Type",
"type": "text",
"value": "application/json"
},
{
"key": "Authorization",
"value": "Bearer {{admin_token}}",
"type": "text"
}
],
"url": {
"raw": "{{URL}}/members/denis/stats?groupIds=10,d6bf6bb6-457c-461c-a4d6-0a6b1a87fde9",
"host": [
"{{URL}}"
],
"path": [
"members",
"denis",
"stats"
],
"query": [
{
"key": "groupIds",
"value": "10,d6bf6bb6-457c-461c-a4d6-0a6b1a87fde9"
}
]
}
},
"response": []
},
{
"name": "get member private statistics by user himself",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"type": "text",
"value": "application/json"
},
{
"key": "Content-Type",
"type": "text",
"value": "application/json"
},
{
"key": "Authorization",
"value": "Bearer {{user_token}}",
"type": "text"
}
],
"url": {
"raw": "{{URL}}/members/denis/stats?groupIds=10,d6bf6bb6-457c-461c-a4d6-0a6b1a87fde9",
"host": [
"{{URL}}"
],
"path": [
"members",
"denis",
"stats"
],
"query": [
{
"key": "groupIds",
"value": "10,d6bf6bb6-457c-461c-a4d6-0a6b1a87fde9"
}
]
}
},
"response": []
},
{
"name": "get member private statistics - multiple group Ids",
"event": [
Expand Down Expand Up @@ -4115,6 +4341,64 @@
},
"response": []
},
{
"name": "get member private statistics - multiple group Ids with admin token",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"type": "text",
"value": "application/json"
},
{
"key": "Content-Type",
"type": "text",
"value": "application/json"
},
{
"key": "Authorization",
"value": "Bearer {{admin_token}}",
"type": "text"
}
],
"url": {
"raw": "{{URL}}/members/denis/stats?groupIds=10,d6bf6bb6-457c-461c-a4d6-0a6b1a87fde9&fields=userId,handle,wins,groupId,challenges",
"host": [
"{{URL}}"
],
"path": [
"members",
"denis",
"stats"
],
"query": [
{
"key": "groupIds",
"value": "10,d6bf6bb6-457c-461c-a4d6-0a6b1a87fde9"
},
{
"key": "fields",
"value": "userId,handle,wins,groupId,challenges"
}
]
}
},
"response": []
},
{
"name": "get member statistics - userId,handle,wins,develop,design",
"event": [
Expand Down
Loading