File tree Expand file tree Collapse file tree 1 file changed +26
-1
lines changed
Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,31 @@ function acceptedIpAddress(ipAddress) {
99 ) ;
1010}
1111
12+ function accessToken ( req ) {
13+ const valid_token = process . env . METRICS_ACCESS_TOKEN ;
14+ let token ;
15+ if ( req . headers && req . headers . authorization ) {
16+ var parts = req . headers . authorization . split ( " " ) ;
17+
18+ if ( parts . length === 2 ) {
19+ var scheme = parts [ 0 ] ;
20+ var credentials = parts [ 1 ] ;
21+
22+ if ( / ^ B e a r e r $ / i. test ( scheme ) ) {
23+ token = credentials ;
24+ }
25+ }
26+ }
27+ if ( ! token && req . query && req . query . access_token ) {
28+ token = req . query . access_token ;
29+ }
30+ return (
31+ token !== undefined &&
32+ valid_token !== undefined &&
33+ token == valid_token
34+ ) ;
35+ }
36+
1237const getBoardTitleWithMostActivities = ( dateWithXdaysAgo , nbLimit ) => {
1338 return Promise . await (
1439 Activities . rawCollection ( )
@@ -49,7 +74,7 @@ Meteor.startup(() => {
4974 // }
5075
5176 // List of trusted ip adress will be found in environment variable "METRICS_ACCEPTED_IP_ADDRESS" (separeted with commas)
52- if ( acceptedIpAddress ( ipAddress ) ) {
77+ if ( acceptedIpAddress ( ipAddress ) || ( accessToken ( req ) ) {
5378 let metricsRes = '' ;
5479 let resCount = 0 ;
5580 //connected users
You can’t perform that action at this time.
0 commit comments