mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
fix: complete RBAC implementation lost during merge
Several RBAC features from feat/rbac-permissions were silently lost during the merge into main. This restores and completes them: - Add permissions and teamName to login/session API responses - Export Permission and Role types from shared package - Filter settings tabs by user permissions in frontend - Extend useAuth hook with role, permissions, and hasPermission - Restrict teams listing to admin only - Add admin override for API keys, files, and pipelines listing - Add ownership scoping to file access, download, and delete routes - Register userFileRoutes in integration test server - Mock auth import in unit permissions test to avoid SQLite lock
This commit is contained in:
@@ -10,6 +10,21 @@ interface AuthState {
|
||||
permissions: string[];
|
||||
}
|
||||
|
||||
const ALL_PERMISSIONS = [
|
||||
"tools:use",
|
||||
"files:own",
|
||||
"files:all",
|
||||
"apikeys:own",
|
||||
"apikeys:all",
|
||||
"pipelines:own",
|
||||
"pipelines:all",
|
||||
"settings:read",
|
||||
"settings:write",
|
||||
"users:manage",
|
||||
"teams:manage",
|
||||
"branding:manage",
|
||||
];
|
||||
|
||||
export function useAuth() {
|
||||
const [state, setState] = useState<AuthState>({
|
||||
loading: true,
|
||||
@@ -34,20 +49,7 @@ export function useAuth() {
|
||||
isAuthenticated: true,
|
||||
mustChangePassword: false,
|
||||
role: "admin",
|
||||
permissions: [
|
||||
"tools:use",
|
||||
"files:own",
|
||||
"files:all",
|
||||
"apikeys:own",
|
||||
"apikeys:all",
|
||||
"pipelines:own",
|
||||
"pipelines:all",
|
||||
"settings:read",
|
||||
"settings:write",
|
||||
"users:manage",
|
||||
"teams:manage",
|
||||
"branding:manage",
|
||||
],
|
||||
permissions: ALL_PERMISSIONS,
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -100,20 +102,7 @@ export function useAuth() {
|
||||
isAuthenticated: true,
|
||||
mustChangePassword: false,
|
||||
role: "admin",
|
||||
permissions: [
|
||||
"tools:use",
|
||||
"files:own",
|
||||
"files:all",
|
||||
"apikeys:own",
|
||||
"apikeys:all",
|
||||
"pipelines:own",
|
||||
"pipelines:all",
|
||||
"settings:read",
|
||||
"settings:write",
|
||||
"users:manage",
|
||||
"teams:manage",
|
||||
"branding:manage",
|
||||
],
|
||||
permissions: ALL_PERMISSIONS,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user