Files
sso-manager-node/nodejs/utils/permission.js
T
wmantly e9b808d1c2 Add cross-app super admin group; rename Executive page to Overview
- app_super_admin is a new cross-app LDAP group (also recognized by proxy
  and jump-host) that grants full admin here regardless of app_sso_admin
  membership: bypassed centrally in utils/permission.js's byGroup, folded
  into GET /api/user/me's isAdmin flag, and added to nav/forceLogin gates
  alongside app_sso_admin.
- Renamed the Executive page to Overview (route, view, API path
  /api/metrics/overview, nav label, docs), keeping /executive as a 301
  redirect alongside the existing /admin, /notifications, /dashboard
  legacy redirects.
2026-07-30 11:56:58 -04:00

41 lines
963 B
JavaScript

'use strict';
const {Group} = require('../models/group_ldap');
const SUPER_ADMIN_GROUP = 'app_super_admin';
let byGroup = async function(user, groups, ownerOf){
try{
let superAdmin = await Group.get(SUPER_ADMIN_GROUP);
if(superAdmin.member.includes(user.dn)) return true
}catch(error){
// group not found, continue checking
}
for(let group of groups){
try{
group = await Group.get(group);
if(group.member.includes(user.dn)) return true
}catch(error){
// group not found, continue checking
}
}
for(let group of ownerOf || []){
try{
group = await Group.get(group);
if(group.owner.includes(user.dn)) return true
}catch(error){
// group not found, continue checking
}
}
let error = new Error('Insufficient Permission');
error.name = 'Insufficient Permission';
error.message = `You do not have permission to perform this action.`;
error.status = 401;
throw error;
}
module.exports = {byGroup, SUPER_ADMIN_GROUP};