@opengis/fastify-table 1.2.21 → 1.2.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -78,5 +78,6 @@ async function plugin(fastify, opt) {
78
78
  propertiesRoutes(fastify, opt);
79
79
  tableRoutes(fastify, opt);
80
80
  utilRoutes(fastify, opt);
81
+ fastify.get('/api/test-proxy', {}, (req) => req.headers);
81
82
  }
82
83
  export default fp(plugin);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/fastify-table",
3
- "version": "1.2.21",
3
+ "version": "1.2.22",
4
4
  "type": "module",
5
5
  "description": "core-plugins",
6
6
  "keywords": [
@@ -70,9 +70,11 @@ export default function checkPolicy(req, reply) {
70
70
  }
71
71
 
72
72
  /* === 0. policy: unauthorized access from admin URL === */
73
- if (!user?.uid && !config.auth?.disable && isAdmin && !policy.includes('public') && !skipCheckPolicyRoutes.filter((el) => el).find(el => req.url.includes(el))) {
73
+ const refererHost = headers?.referer?.match?.(/(https?:\/\/[^\/]+)/g)?.[0];
74
+ const validToken = headers?.token && refererHost && config.auth?.tokens?.[refererHost] === headers.token;
75
+ if (!validToken && !user?.uid && !config.auth?.disable && isAdmin && !policy.includes('public') && !skipCheckPolicyRoutes.filter((el) => el).find(el => req.url.includes(el))) {
74
76
  logger.file('policy/unauthorized', {
75
- path, method, params, query, body, message: 'unauthorized',
77
+ path, method, params, query, body, referer: refererHost, token: headers?.token, headers, message: 'unauthorized',
76
78
  });
77
79
  return reply.status(401).send('unauthorized');
78
80
  }