mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-17 11:25:48 +02:00
Let API clients resolve user ids to names (#1894)
Archives, the queue and statistics report ownership as a numeric created_by_id, and statistics accept it as a filter, but nothing let an API key discover whose id was whose -- the only user listing returns emails, roles, group membership and full permission sets, so it is administrative and rejects keys. Add GET /users/slim returning id + username only, gated on a new users:read_slim permission mapped to can_read_status. That grants no data a key could not already reach: for API-keyed requests the permission deps return None as current_user, so the stats:filter_by_user guard short-circuits and ?created_by_id=N is already honoured for every N. What was missing was the ability to address the filter, not permission to use it. The full listing stays unmapped = admin-only. Also fix /auth/me, which answered an API key with a synthetic administrator: id 0, role admin, is_admin true and every permission in the enum. A key cannot reach an administrative route at all, so clients building their UI from that response rendered actions that 403 on use. It now reports the key owner's identity, is_admin false, and the permissions the key's scopes actually admit. Ownerless legacy keys keep id 0 but no longer claim admin. --- Source user names from the slim listing where only names are needed (#1894) Stats filter-by-user, the Archives print log filter, the File Manager username autocomplete, the camera-token owner column and the Finance member picker all render nothing but a username, but all of them read the full user listing, which is gated on the admin-level users:read. An operator granted stats:filter_by_user but not users:read got an empty filter with no indication why. Point them at /users/slim under a separate react-query key, since the full listing shares the 'users' key and the two shapes would clobber each other in the cache.
This commit is contained in:
@@ -3783,7 +3783,7 @@ export type Permission =
|
||||
| 'cloud:auth' | 'orca_cloud:auth'
|
||||
| 'makerworld:view' | 'makerworld:import'
|
||||
| 'api_keys:read' | 'api_keys:create' | 'api_keys:update' | 'api_keys:delete'
|
||||
| 'users:read' | 'users:create' | 'users:update' | 'users:delete'
|
||||
| 'users:read' | 'users:read_slim' | 'users:create' | 'users:update' | 'users:delete'
|
||||
| 'groups:read' | 'groups:create' | 'groups:update' | 'groups:delete'
|
||||
| 'pipelines:read' | 'pipelines:write' | 'pipelines:run'
|
||||
| 'websocket:connect';
|
||||
@@ -3873,6 +3873,17 @@ export interface UserResponse {
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Just enough to label an owner id (#1894). Backed by GET /users/slim, which
|
||||
* is readable with `users:read_slim` as well as the admin-level `users:read`
|
||||
* -- use it anywhere a screen only needs to turn a `created_by_id` into a
|
||||
* name, so operators are not forced into the full listing to get one.
|
||||
*/
|
||||
export interface UserSlim {
|
||||
id: number;
|
||||
username: string;
|
||||
}
|
||||
|
||||
export interface UserCreate {
|
||||
username: string;
|
||||
password?: string; // Optional when advanced auth is enabled
|
||||
@@ -4264,6 +4275,7 @@ export const api = {
|
||||
|
||||
// Users
|
||||
getUsers: () => request<UserResponse[]>('/users/'),
|
||||
getUsersSlim: () => request<UserSlim[]>('/users/slim'),
|
||||
getUser: (id: number) => request<UserResponse>(`/users/${id}`),
|
||||
createUser: (data: UserCreate) =>
|
||||
request<UserResponse>('/users/', {
|
||||
|
||||
Reference in New Issue
Block a user