@opengis/admin 0.2.70 → 0.2.71
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
@@ -0,0 +1,34 @@
|
|
1
|
+
import { pgClients, metaFormat } from '@opengis/fastify-table/utils.js';
|
2
|
+
import { getAdminAccess } from '../../../../utils.js';
|
3
|
+
|
4
|
+
const q = `select a.route_id as id, coalesce(b.user_uid, d.user_uid) as user_uid, coalesce(d.actions, b.actions, array['view']) as actions, b.scope, c.role_id
|
5
|
+
from admin.routes a
|
6
|
+
left join admin.role_access b on
|
7
|
+
a.route_id=b.route_id
|
8
|
+
left join admin.roles c on
|
9
|
+
b.role_id=c.role_id
|
10
|
+
and c.enabled
|
11
|
+
left join admin.user_roles d on
|
12
|
+
c.role_id=d.role_id
|
13
|
+
and ( case when
|
14
|
+
d.expiration is not null
|
15
|
+
then d.expiration > CURRENT_DATE
|
16
|
+
else 1=1
|
17
|
+
end )
|
18
|
+
where $1 in (a.route_id, a.alias, a.table_name) and coalesce(b.user_uid, d.user_uid) is not null`;
|
19
|
+
|
20
|
+
export default async function accessInterface(req) {
|
21
|
+
const { pg = pgClients.client, params = {}, user = {} } = req;
|
22
|
+
|
23
|
+
// restrict access - admin only
|
24
|
+
const check = await getAdminAccess({
|
25
|
+
id: params.name, user,
|
26
|
+
});
|
27
|
+
if (check) return check;
|
28
|
+
|
29
|
+
const { rows = [] } = await pg.query(q, [params.name]);
|
30
|
+
|
31
|
+
const cls = { user_uid: 'core.user_uid', actions: 'core.actions', role_id: 'core.roles' };
|
32
|
+
await metaFormat({ rows, cls, sufix: false });
|
33
|
+
return { rows };
|
34
|
+
}
|
@@ -1,8 +1,11 @@
|
|
1
1
|
import accessGroup from "./controllers/access.group.js";
|
2
2
|
import accessGroupPost from "./controllers/access.group.post.js";
|
3
|
-
import
|
3
|
+
import accessInterface from "./controllers/access.interface.js";
|
4
|
+
|
5
|
+
import { accessGroupPostSchema, accessGroupSchema, accessInterfaceSchema } from "./schema.mjs";
|
4
6
|
|
5
7
|
export default async function route(fastify) {
|
6
8
|
fastify.get('/access-group/:id', { schema: accessGroupSchema }, accessGroup);
|
7
9
|
fastify.post('/access-group/:id', { schema: accessGroupPostSchema }, accessGroupPost);
|
10
|
+
fastify.get('/access-interface/:name', { schema: accessInterfaceSchema }, accessInterface);
|
8
11
|
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
export default null;
|
2
|
-
export { accessGroupSchema, accessGroupPostSchema }
|
2
|
+
export { accessGroupSchema, accessGroupPostSchema, accessInterfaceSchema }
|
3
3
|
|
4
4
|
const accessGroupSchema = {
|
5
5
|
params: {
|
@@ -11,6 +11,16 @@ const accessGroupSchema = {
|
|
11
11
|
},
|
12
12
|
};
|
13
13
|
|
14
|
+
const accessInterfaceSchema = {
|
15
|
+
params: {
|
16
|
+
type: 'object',
|
17
|
+
properties: {
|
18
|
+
name: { type: 'string', pattern: '^([\\d\\w._-]+)$' },
|
19
|
+
},
|
20
|
+
required: ['name'],
|
21
|
+
},
|
22
|
+
};
|
23
|
+
|
14
24
|
const accessGroupPostSchema = {
|
15
25
|
params: {
|
16
26
|
type: 'object',
|