@opengis/fastify-table 1.2.34 → 1.2.36
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/package.json
CHANGED
|
@@ -71,6 +71,9 @@ export default function checkPolicy(req, reply) {
|
|
|
71
71
|
|
|
72
72
|
/* === 0. policy: unauthorized access from admin URL === */
|
|
73
73
|
const validToken = (req.ip === '193.239.152.181' || req.ip === '127.0.0.1' || req.ip.startsWith('192.168.') || config.debug) && req.headers?.uid && req.headers?.token && config.auth?.tokens?.includes?.(headers.token);
|
|
74
|
+
if (validToken && !req?.user?.uid) {
|
|
75
|
+
req.user = { uid: req.headers?.uid };
|
|
76
|
+
}
|
|
74
77
|
if (!validToken && !user?.uid && !config.auth?.disable && isAdmin && !policy.includes('public') && !skipCheckPolicyRoutes.filter((el) => el).find(el => req.url.includes(el))) {
|
|
75
78
|
logger.file('policy/unauthorized', {
|
|
76
79
|
path, method, params, query, body, token: headers?.token, userId: headers?.uid, ip: req.ip, headers, message: 'unauthorized',
|
|
@@ -10,7 +10,7 @@ const components = {
|
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
const maxLimit = 100;
|
|
13
|
-
export default async function dataAPI(req) {
|
|
13
|
+
export default async function dataAPI(req, reply, called) {
|
|
14
14
|
const {
|
|
15
15
|
pg, params, query = {}, user = {},
|
|
16
16
|
} = req;
|
|
@@ -34,7 +34,7 @@ export default async function dataAPI(req) {
|
|
|
34
34
|
const id = tokenData?.id || hookData?.id || params?.id;
|
|
35
35
|
const { actions = [], query: accessQuery } = await getAccess({ table: tokenData?.table || hookData?.table || params.table, id, user }) || {};
|
|
36
36
|
|
|
37
|
-
if (!actions.includes('view') && !config?.local) {
|
|
37
|
+
if (!actions.includes('view') && !config?.local && !called) {
|
|
38
38
|
return { message: 'access restricted', status: 403 };
|
|
39
39
|
}
|
|
40
40
|
|