Move access permissions to access module

This commit is contained in:
2026-07-10 23:27:48 +02:00
parent a7c486788e
commit e32841077c
13 changed files with 1319 additions and 170 deletions

View File

@@ -92,6 +92,8 @@ export type UserAdminItem = {
last_login_at?: string | null;
groups: GroupSummary[];
roles: RoleSummary[];
function_assignment_ids: string[];
function_delegation_ids: string[];
effective_scopes: string[];
is_owner: boolean;
is_last_active_owner: boolean;
@@ -99,6 +101,63 @@ export type UserAdminItem = {
updated_at: string;
};
export type AccessRoleSourceType = "direct_role" | "group_role" | "legacy_function_role" | "idm_function_role" | "system_role";
export type AccessRoleSourceItem = {
source_type: AccessRoleSourceType;
role_id: string;
role_slug: string;
role_name: string;
permissions: string[];
tenant_id?: string | null;
group_id?: string | null;
group_name?: string | null;
function_assignment_id?: string | null;
function_id?: string | null;
function_name?: string | null;
organization_unit_id?: string | null;
organization_unit_name?: string | null;
identity_id?: string | null;
account_id?: string | null;
source_module?: string | null;
assignment_source?: string | null;
applies_to_subunits: boolean;
delegated_from_assignment_id?: string | null;
delegation_id?: string | null;
acting_for_account_id?: string | null;
};
export type AccessScopeExplanationItem = {
scope: string;
sources: AccessRoleSourceItem[];
};
export type FunctionFactExplanationItem = {
source_module: string;
assignment_id: string;
tenant_id: string;
identity_id?: string | null;
account_id?: string | null;
function_id: string;
function_name?: string | null;
organization_unit_id: string;
organization_unit_name?: string | null;
applies_to_subunits: boolean;
assignment_source: string;
status: string;
delegated_from_assignment_id?: string | null;
acting_for_account_id?: string | null;
role_ids: string[];
role_names: string[];
};
export type UserAccessExplanationResponse = {
user: UserAdminItem;
role_sources: AccessRoleSourceItem[];
scopes: AccessScopeExplanationItem[];
function_facts: FunctionFactExplanationItem[];
};
export type SystemAccountItem = {
account_id: string;
email: string;
@@ -400,6 +459,10 @@ export function updateUser(settings: ApiSettings, userId: string, payload: Parti
return apiFetch(settings, `/api/v1/admin/users/${userId}`, { method: "PATCH", body: JSON.stringify(payload) });
}
export function fetchUserAccessExplanation(settings: ApiSettings, userId: string): Promise<UserAccessExplanationResponse> {
return apiFetch(settings, `/api/v1/admin/users/${userId}/access-explanation`);
}
export async function fetchGroups(settings: ApiSettings): Promise<GroupSummary[]> {
const response = await apiFetch<{ groups: GroupSummary[] }>(settings, "/api/v1/admin/groups");
return response.groups;