feat: add authentication, user management, and admin features
Added comprehensive authentication and authorization system:
Authentication System:
- Better Auth integration with session management
- Login/logout pages and API routes
- Middleware for route protection
- Auth utilities and client libraries
User Management:
- User list, detail, and invite pages
- User API endpoints (CRUD operations)
- Session management for users
- Profile settings page
Role-Based Access Control:
- Role management pages (list, create, edit)
- Permission system with granular controls
- Role assignment to users
- Role API endpoints
Admin Features:
- Audit log page for tracking system events
- Admin settings page
- Audit service for logging user actions
Additional Features:
- Quotes management pages and components
- SalesBldr API integration
- Email service for notifications
Configuration & Documentation:
- Updated docker-compose.yml
- MCP server configuration (mcp.json)
- CVE-2025-55182 security review documentation
- Standards guide and PRD documents
- Re-enabling authentication documentation
Database Migrations:
- 012: Auth tables (users, sessions, accounts, verifications)
- 013: Role tables (roles, permissions, role_permissions, user_roles)
- 014: Admin settings table
UI Updates:
- Updated dashboard layout
- Enhanced app layout with auth integration
2026-01-31 12:43:14 -05:00
|
|
|
import { createAccessControl } from "better-auth/plugins/access";
|
|
|
|
|
|
|
|
|
|
// Define all available permissions for resources
|
|
|
|
|
export const statement = {
|
|
|
|
|
// Ticket management
|
|
|
|
|
tickets: ["create", "read", "update", "delete"],
|
|
|
|
|
|
|
|
|
|
// Configuration items
|
|
|
|
|
configItems: ["create", "read", "update", "delete"],
|
|
|
|
|
|
|
|
|
|
// Admin panel access
|
|
|
|
|
admin: ["access"],
|
|
|
|
|
|
|
|
|
|
// User management
|
|
|
|
|
users: ["create", "read", "update", "delete", "invite", "ban"],
|
|
|
|
|
|
|
|
|
|
// Role management
|
|
|
|
|
roles: ["create", "read", "update", "delete"],
|
|
|
|
|
|
|
|
|
|
// Audit log access
|
|
|
|
|
auditLog: ["read"],
|
|
|
|
|
|
|
|
|
|
// Settings management
|
|
|
|
|
settings: ["read", "update"],
|
feat: RMM Overshell, IT Glue audit/write-back, LogLift, link-aware bundles, dashboard overhaul
- RMM Overshell (migration 077): admin page, dispatch UI, executor/worker, target
resolver, script registry (AD/DHCP/DNS/event-log/services/software/network/loglift)
- LogLift evidence pipeline (migration 078): upload webhook, B2 storage client,
receiver/matcher, EventLogCollector PowerShell script
- IT Glue audit + write-back (migrations 075, 076): asset-audit runner, ticket
xrefs, applications/configurations browse pages + apply/revert/audit endpoints
- Link-aware analyzer bundles (migration 073) + provider toggle (migration 074):
link-discovery service, OpenRouter LLM provider, related-tickets/itglue-suggestion
panels, analyze-bundle endpoint
- Endpoint data model + device-link reconciliation (migrations 079, 080): conflicts
admin page, reconciler service, resolve endpoints
- Dashboard overhaul: integration-health service + alerts, overview/health endpoints
- Permissions: add itglue + rmm scopes; middleware: public /api/rmm/loglift route
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 07:13:18 -04:00
|
|
|
|
|
|
|
|
// IT Glue documentation read/write (Phase 4 — asset audit + write-back)
|
|
|
|
|
itglue: ["read", "write"],
|
|
|
|
|
|
|
|
|
|
// Datto RMM Overshell evidence (Phase 4.2 — read jobs / execute scripts)
|
|
|
|
|
rmm: ["read", "execute"],
|
2026-07-15 19:23:09 -04:00
|
|
|
|
2026-07-16 10:43:18 -04:00
|
|
|
// Phishing triage campaigns/reports (Phase 18 — D-05: full vocabulary)
|
2026-07-15 19:23:09 -04:00
|
|
|
phishing: ["read", "analyze", "approve", "remediate"],
|
feat: add authentication, user management, and admin features
Added comprehensive authentication and authorization system:
Authentication System:
- Better Auth integration with session management
- Login/logout pages and API routes
- Middleware for route protection
- Auth utilities and client libraries
User Management:
- User list, detail, and invite pages
- User API endpoints (CRUD operations)
- Session management for users
- Profile settings page
Role-Based Access Control:
- Role management pages (list, create, edit)
- Permission system with granular controls
- Role assignment to users
- Role API endpoints
Admin Features:
- Audit log page for tracking system events
- Admin settings page
- Audit service for logging user actions
Additional Features:
- Quotes management pages and components
- SalesBldr API integration
- Email service for notifications
Configuration & Documentation:
- Updated docker-compose.yml
- MCP server configuration (mcp.json)
- CVE-2025-55182 security review documentation
- Standards guide and PRD documents
- Re-enabling authentication documentation
Database Migrations:
- 012: Auth tables (users, sessions, accounts, verifications)
- 013: Role tables (roles, permissions, role_permissions, user_roles)
- 014: Admin settings table
UI Updates:
- Updated dashboard layout
- Enhanced app layout with auth integration
2026-01-31 12:43:14 -05:00
|
|
|
} as const;
|
|
|
|
|
|
|
|
|
|
// Create access control instance
|
|
|
|
|
export const ac = createAccessControl(statement);
|
|
|
|
|
|
|
|
|
|
// Super Admin role - full access to everything
|
|
|
|
|
export const superAdminRole = ac.newRole({
|
|
|
|
|
tickets: ["create", "read", "update", "delete"],
|
|
|
|
|
configItems: ["create", "read", "update", "delete"],
|
|
|
|
|
admin: ["access"],
|
|
|
|
|
users: ["create", "read", "update", "delete", "invite", "ban"],
|
|
|
|
|
roles: ["create", "read", "update", "delete"],
|
|
|
|
|
auditLog: ["read"],
|
|
|
|
|
settings: ["read", "update"],
|
feat: RMM Overshell, IT Glue audit/write-back, LogLift, link-aware bundles, dashboard overhaul
- RMM Overshell (migration 077): admin page, dispatch UI, executor/worker, target
resolver, script registry (AD/DHCP/DNS/event-log/services/software/network/loglift)
- LogLift evidence pipeline (migration 078): upload webhook, B2 storage client,
receiver/matcher, EventLogCollector PowerShell script
- IT Glue audit + write-back (migrations 075, 076): asset-audit runner, ticket
xrefs, applications/configurations browse pages + apply/revert/audit endpoints
- Link-aware analyzer bundles (migration 073) + provider toggle (migration 074):
link-discovery service, OpenRouter LLM provider, related-tickets/itglue-suggestion
panels, analyze-bundle endpoint
- Endpoint data model + device-link reconciliation (migrations 079, 080): conflicts
admin page, reconciler service, resolve endpoints
- Dashboard overhaul: integration-health service + alerts, overview/health endpoints
- Permissions: add itglue + rmm scopes; middleware: public /api/rmm/loglift route
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 07:13:18 -04:00
|
|
|
itglue: ["read", "write"],
|
|
|
|
|
rmm: ["read", "execute"],
|
2026-07-16 10:43:18 -04:00
|
|
|
phishing: ["read", "analyze", "approve", "remediate"],
|
feat: add authentication, user management, and admin features
Added comprehensive authentication and authorization system:
Authentication System:
- Better Auth integration with session management
- Login/logout pages and API routes
- Middleware for route protection
- Auth utilities and client libraries
User Management:
- User list, detail, and invite pages
- User API endpoints (CRUD operations)
- Session management for users
- Profile settings page
Role-Based Access Control:
- Role management pages (list, create, edit)
- Permission system with granular controls
- Role assignment to users
- Role API endpoints
Admin Features:
- Audit log page for tracking system events
- Admin settings page
- Audit service for logging user actions
Additional Features:
- Quotes management pages and components
- SalesBldr API integration
- Email service for notifications
Configuration & Documentation:
- Updated docker-compose.yml
- MCP server configuration (mcp.json)
- CVE-2025-55182 security review documentation
- Standards guide and PRD documents
- Re-enabling authentication documentation
Database Migrations:
- 012: Auth tables (users, sessions, accounts, verifications)
- 013: Role tables (roles, permissions, role_permissions, user_roles)
- 014: Admin settings table
UI Updates:
- Updated dashboard layout
- Enhanced app layout with auth integration
2026-01-31 12:43:14 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Admin role - access to admin panel and user management, but not role management
|
|
|
|
|
export const adminRole = ac.newRole({
|
|
|
|
|
tickets: ["create", "read", "update", "delete"],
|
|
|
|
|
configItems: ["create", "read", "update", "delete"],
|
|
|
|
|
admin: ["access"],
|
|
|
|
|
users: ["create", "read", "update", "invite"],
|
|
|
|
|
roles: ["read"],
|
|
|
|
|
auditLog: ["read"],
|
|
|
|
|
settings: ["read"],
|
feat: RMM Overshell, IT Glue audit/write-back, LogLift, link-aware bundles, dashboard overhaul
- RMM Overshell (migration 077): admin page, dispatch UI, executor/worker, target
resolver, script registry (AD/DHCP/DNS/event-log/services/software/network/loglift)
- LogLift evidence pipeline (migration 078): upload webhook, B2 storage client,
receiver/matcher, EventLogCollector PowerShell script
- IT Glue audit + write-back (migrations 075, 076): asset-audit runner, ticket
xrefs, applications/configurations browse pages + apply/revert/audit endpoints
- Link-aware analyzer bundles (migration 073) + provider toggle (migration 074):
link-discovery service, OpenRouter LLM provider, related-tickets/itglue-suggestion
panels, analyze-bundle endpoint
- Endpoint data model + device-link reconciliation (migrations 079, 080): conflicts
admin page, reconciler service, resolve endpoints
- Dashboard overhaul: integration-health service + alerts, overview/health endpoints
- Permissions: add itglue + rmm scopes; middleware: public /api/rmm/loglift route
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 07:13:18 -04:00
|
|
|
itglue: ["read", "write"],
|
|
|
|
|
rmm: ["read", "execute"],
|
2026-07-16 10:43:18 -04:00
|
|
|
phishing: ["read", "analyze", "approve", "remediate"],
|
feat: add authentication, user management, and admin features
Added comprehensive authentication and authorization system:
Authentication System:
- Better Auth integration with session management
- Login/logout pages and API routes
- Middleware for route protection
- Auth utilities and client libraries
User Management:
- User list, detail, and invite pages
- User API endpoints (CRUD operations)
- Session management for users
- Profile settings page
Role-Based Access Control:
- Role management pages (list, create, edit)
- Permission system with granular controls
- Role assignment to users
- Role API endpoints
Admin Features:
- Audit log page for tracking system events
- Admin settings page
- Audit service for logging user actions
Additional Features:
- Quotes management pages and components
- SalesBldr API integration
- Email service for notifications
Configuration & Documentation:
- Updated docker-compose.yml
- MCP server configuration (mcp.json)
- CVE-2025-55182 security review documentation
- Standards guide and PRD documents
- Re-enabling authentication documentation
Database Migrations:
- 012: Auth tables (users, sessions, accounts, verifications)
- 013: Role tables (roles, permissions, role_permissions, user_roles)
- 014: Admin settings table
UI Updates:
- Updated dashboard layout
- Enhanced app layout with auth integration
2026-01-31 12:43:14 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// User role - basic access
|
|
|
|
|
export const userRole = ac.newRole({
|
|
|
|
|
tickets: ["create", "read", "update"],
|
|
|
|
|
configItems: ["read"],
|
|
|
|
|
admin: [],
|
|
|
|
|
users: [],
|
|
|
|
|
roles: [],
|
|
|
|
|
auditLog: [],
|
|
|
|
|
settings: [],
|
feat: RMM Overshell, IT Glue audit/write-back, LogLift, link-aware bundles, dashboard overhaul
- RMM Overshell (migration 077): admin page, dispatch UI, executor/worker, target
resolver, script registry (AD/DHCP/DNS/event-log/services/software/network/loglift)
- LogLift evidence pipeline (migration 078): upload webhook, B2 storage client,
receiver/matcher, EventLogCollector PowerShell script
- IT Glue audit + write-back (migrations 075, 076): asset-audit runner, ticket
xrefs, applications/configurations browse pages + apply/revert/audit endpoints
- Link-aware analyzer bundles (migration 073) + provider toggle (migration 074):
link-discovery service, OpenRouter LLM provider, related-tickets/itglue-suggestion
panels, analyze-bundle endpoint
- Endpoint data model + device-link reconciliation (migrations 079, 080): conflicts
admin page, reconciler service, resolve endpoints
- Dashboard overhaul: integration-health service + alerts, overview/health endpoints
- Permissions: add itglue + rmm scopes; middleware: public /api/rmm/loglift route
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 07:13:18 -04:00
|
|
|
itglue: ["read"],
|
|
|
|
|
rmm: ["read"],
|
2026-07-15 19:23:09 -04:00
|
|
|
phishing: ["read"], // cannot trigger /analyze
|
feat: add authentication, user management, and admin features
Added comprehensive authentication and authorization system:
Authentication System:
- Better Auth integration with session management
- Login/logout pages and API routes
- Middleware for route protection
- Auth utilities and client libraries
User Management:
- User list, detail, and invite pages
- User API endpoints (CRUD operations)
- Session management for users
- Profile settings page
Role-Based Access Control:
- Role management pages (list, create, edit)
- Permission system with granular controls
- Role assignment to users
- Role API endpoints
Admin Features:
- Audit log page for tracking system events
- Admin settings page
- Audit service for logging user actions
Additional Features:
- Quotes management pages and components
- SalesBldr API integration
- Email service for notifications
Configuration & Documentation:
- Updated docker-compose.yml
- MCP server configuration (mcp.json)
- CVE-2025-55182 security review documentation
- Standards guide and PRD documents
- Re-enabling authentication documentation
Database Migrations:
- 012: Auth tables (users, sessions, accounts, verifications)
- 013: Role tables (roles, permissions, role_permissions, user_roles)
- 014: Admin settings table
UI Updates:
- Updated dashboard layout
- Enhanced app layout with auth integration
2026-01-31 12:43:14 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Helper function to check if a user has a specific permission
|
|
|
|
|
export function hasPermission(
|
2026-07-12 18:20:36 -04:00
|
|
|
roleName: string,
|
feat: add authentication, user management, and admin features
Added comprehensive authentication and authorization system:
Authentication System:
- Better Auth integration with session management
- Login/logout pages and API routes
- Middleware for route protection
- Auth utilities and client libraries
User Management:
- User list, detail, and invite pages
- User API endpoints (CRUD operations)
- Session management for users
- Profile settings page
Role-Based Access Control:
- Role management pages (list, create, edit)
- Permission system with granular controls
- Role assignment to users
- Role API endpoints
Admin Features:
- Audit log page for tracking system events
- Admin settings page
- Audit service for logging user actions
Additional Features:
- Quotes management pages and components
- SalesBldr API integration
- Email service for notifications
Configuration & Documentation:
- Updated docker-compose.yml
- MCP server configuration (mcp.json)
- CVE-2025-55182 security review documentation
- Standards guide and PRD documents
- Re-enabling authentication documentation
Database Migrations:
- 012: Auth tables (users, sessions, accounts, verifications)
- 013: Role tables (roles, permissions, role_permissions, user_roles)
- 014: Admin settings table
UI Updates:
- Updated dashboard layout
- Enhanced app layout with auth integration
2026-01-31 12:43:14 -05:00
|
|
|
resource: keyof typeof statement,
|
|
|
|
|
action: string
|
|
|
|
|
): boolean {
|
|
|
|
|
const roles: Record<string, ReturnType<typeof ac.newRole>> = {
|
|
|
|
|
"super-admin": superAdminRole,
|
|
|
|
|
admin: adminRole,
|
2026-07-12 18:20:36 -04:00
|
|
|
user: userRole,
|
feat: add authentication, user management, and admin features
Added comprehensive authentication and authorization system:
Authentication System:
- Better Auth integration with session management
- Login/logout pages and API routes
- Middleware for route protection
- Auth utilities and client libraries
User Management:
- User list, detail, and invite pages
- User API endpoints (CRUD operations)
- Session management for users
- Profile settings page
Role-Based Access Control:
- Role management pages (list, create, edit)
- Permission system with granular controls
- Role assignment to users
- Role API endpoints
Admin Features:
- Audit log page for tracking system events
- Admin settings page
- Audit service for logging user actions
Additional Features:
- Quotes management pages and components
- SalesBldr API integration
- Email service for notifications
Configuration & Documentation:
- Updated docker-compose.yml
- MCP server configuration (mcp.json)
- CVE-2025-55182 security review documentation
- Standards guide and PRD documents
- Re-enabling authentication documentation
Database Migrations:
- 012: Auth tables (users, sessions, accounts, verifications)
- 013: Role tables (roles, permissions, role_permissions, user_roles)
- 014: Admin settings table
UI Updates:
- Updated dashboard layout
- Enhanced app layout with auth integration
2026-01-31 12:43:14 -05:00
|
|
|
};
|
|
|
|
|
|
2026-07-12 18:20:36 -04:00
|
|
|
const role = roles[roleName];
|
feat: add authentication, user management, and admin features
Added comprehensive authentication and authorization system:
Authentication System:
- Better Auth integration with session management
- Login/logout pages and API routes
- Middleware for route protection
- Auth utilities and client libraries
User Management:
- User list, detail, and invite pages
- User API endpoints (CRUD operations)
- Session management for users
- Profile settings page
Role-Based Access Control:
- Role management pages (list, create, edit)
- Permission system with granular controls
- Role assignment to users
- Role API endpoints
Admin Features:
- Audit log page for tracking system events
- Admin settings page
- Audit service for logging user actions
Additional Features:
- Quotes management pages and components
- SalesBldr API integration
- Email service for notifications
Configuration & Documentation:
- Updated docker-compose.yml
- MCP server configuration (mcp.json)
- CVE-2025-55182 security review documentation
- Standards guide and PRD documents
- Re-enabling authentication documentation
Database Migrations:
- 012: Auth tables (users, sessions, accounts, verifications)
- 013: Role tables (roles, permissions, role_permissions, user_roles)
- 014: Admin settings table
UI Updates:
- Updated dashboard layout
- Enhanced app layout with auth integration
2026-01-31 12:43:14 -05:00
|
|
|
if (!role) return false;
|
|
|
|
|
|
|
|
|
|
// Check if the role has the permission
|
|
|
|
|
const permissions = role.statements[resource];
|
|
|
|
|
if (!permissions) return false;
|
|
|
|
|
|
|
|
|
|
return (permissions as readonly string[]).includes(action);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Type for permission check
|
|
|
|
|
export type Permission = {
|
|
|
|
|
resource: keyof typeof statement;
|
|
|
|
|
action: string;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Check multiple permissions
|
|
|
|
|
export function hasPermissions(
|
|
|
|
|
userRole: string,
|
|
|
|
|
permissions: Permission[]
|
|
|
|
|
): boolean {
|
|
|
|
|
return permissions.every((p) => hasPermission(userRole, p.resource, p.action));
|
|
|
|
|
}
|