Add local user authentication and admin capabilities
Implement local user authentication with password hashing, add admin roles for user management and audit log viewing, and introduce audit logging for critical actions. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 776963d0-f75d-42e2-a57b-cc36bdff8495 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: 832a44ff-12ae-4096-8a0d-666ec083d536 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/0683fb79-a27c-485c-9333-5f4b288c4567/776963d0-f75d-42e2-a57b-cc36bdff8495/1p7jhzu Replit-Helium-Checkpoint-Created: true
This commit is contained in:
@@ -33,6 +33,7 @@ export const ListToolsResponseItem = zod.object({
|
||||
"category": zod.string(),
|
||||
"websiteUrl": zod.string().nullish(),
|
||||
"iconUrl": zod.string().nullish(),
|
||||
"createdBy": zod.string().nullish(),
|
||||
"features": zod.array(zod.string()).optional(),
|
||||
"tags": zod.array(zod.string()).optional(),
|
||||
"createdAt": zod.coerce.date(),
|
||||
@@ -78,6 +79,7 @@ export const GetToolResponse = zod.object({
|
||||
"category": zod.string(),
|
||||
"websiteUrl": zod.string().nullish(),
|
||||
"iconUrl": zod.string().nullish(),
|
||||
"createdBy": zod.string().nullish(),
|
||||
"features": zod.array(zod.string()).optional(),
|
||||
"tags": zod.array(zod.string()).optional(),
|
||||
"createdAt": zod.coerce.date(),
|
||||
@@ -116,6 +118,7 @@ export const UpdateToolResponse = zod.object({
|
||||
"category": zod.string(),
|
||||
"websiteUrl": zod.string().nullish(),
|
||||
"iconUrl": zod.string().nullish(),
|
||||
"createdBy": zod.string().nullish(),
|
||||
"features": zod.array(zod.string()).optional(),
|
||||
"tags": zod.array(zod.string()).optional(),
|
||||
"createdAt": zod.coerce.date(),
|
||||
@@ -194,6 +197,7 @@ export const GetAnalyticsSummaryResponse = zod.object({
|
||||
"category": zod.string(),
|
||||
"websiteUrl": zod.string().nullish(),
|
||||
"iconUrl": zod.string().nullish(),
|
||||
"createdBy": zod.string().nullish(),
|
||||
"features": zod.array(zod.string()).optional(),
|
||||
"tags": zod.array(zod.string()).optional(),
|
||||
"createdAt": zod.coerce.date(),
|
||||
@@ -222,6 +226,7 @@ export const GetTopToolsResponseItem = zod.object({
|
||||
"category": zod.string(),
|
||||
"websiteUrl": zod.string().nullish(),
|
||||
"iconUrl": zod.string().nullish(),
|
||||
"createdBy": zod.string().nullish(),
|
||||
"features": zod.array(zod.string()).optional(),
|
||||
"tags": zod.array(zod.string()).optional(),
|
||||
"createdAt": zod.coerce.date(),
|
||||
@@ -283,6 +288,32 @@ export const ListAllFeaturesResponseItem = zod.string()
|
||||
export const ListAllFeaturesResponse = zod.array(ListAllFeaturesResponseItem)
|
||||
|
||||
|
||||
/**
|
||||
* @summary Get authentication mode (oidc or local)
|
||||
*/
|
||||
export const GetAuthModeResponse = zod.object({
|
||||
"mode": zod.enum(['oidc', 'local'])
|
||||
})
|
||||
|
||||
|
||||
/**
|
||||
* @summary Local username/password login
|
||||
*/
|
||||
export const LocalLoginBody = zod.object({
|
||||
"username": zod.string(),
|
||||
"password": zod.string()
|
||||
})
|
||||
|
||||
export const LocalLoginResponse = zod.object({
|
||||
"sub": zod.string(),
|
||||
"email": zod.string().nullish(),
|
||||
"name": zod.string().nullish(),
|
||||
"preferredUsername": zod.string().nullish(),
|
||||
"role": zod.enum(['admin', 'user']).optional(),
|
||||
"isLocal": zod.boolean().optional()
|
||||
})
|
||||
|
||||
|
||||
/**
|
||||
* @summary Get current authenticated user
|
||||
*/
|
||||
@@ -290,7 +321,89 @@ export const GetMeResponse = zod.object({
|
||||
"sub": zod.string(),
|
||||
"email": zod.string().nullish(),
|
||||
"name": zod.string().nullish(),
|
||||
"preferredUsername": zod.string().nullish()
|
||||
"preferredUsername": zod.string().nullish(),
|
||||
"role": zod.enum(['admin', 'user']).optional(),
|
||||
"isLocal": zod.boolean().optional()
|
||||
})
|
||||
|
||||
|
||||
/**
|
||||
* @summary List all local users (admin only)
|
||||
*/
|
||||
export const ListUsersResponseItem = zod.object({
|
||||
"id": zod.number(),
|
||||
"username": zod.string(),
|
||||
"email": zod.string().nullish(),
|
||||
"role": zod.enum(['admin', 'user']),
|
||||
"createdAt": zod.coerce.date()
|
||||
})
|
||||
export const ListUsersResponse = zod.array(ListUsersResponseItem)
|
||||
|
||||
|
||||
/**
|
||||
* @summary Create a new local user (admin only)
|
||||
*/
|
||||
export const createUserBodyUsernameMin = 2;
|
||||
|
||||
export const createUserBodyPasswordMin = 6;
|
||||
|
||||
|
||||
|
||||
export const CreateUserBody = zod.object({
|
||||
"username": zod.string().min(createUserBodyUsernameMin),
|
||||
"password": zod.string().min(createUserBodyPasswordMin),
|
||||
"email": zod.string().optional(),
|
||||
"role": zod.enum(['admin', 'user']).optional()
|
||||
})
|
||||
|
||||
|
||||
/**
|
||||
* @summary Update user role (admin only)
|
||||
*/
|
||||
export const UpdateUserParams = zod.object({
|
||||
"id": zod.coerce.number()
|
||||
})
|
||||
|
||||
export const UpdateUserBody = zod.object({
|
||||
"role": zod.enum(['admin', 'user'])
|
||||
})
|
||||
|
||||
export const UpdateUserResponse = zod.object({
|
||||
"id": zod.number(),
|
||||
"username": zod.string(),
|
||||
"email": zod.string().nullish(),
|
||||
"role": zod.enum(['admin', 'user']),
|
||||
"createdAt": zod.coerce.date()
|
||||
})
|
||||
|
||||
|
||||
/**
|
||||
* @summary Delete a user (admin only)
|
||||
*/
|
||||
export const DeleteUserParams = zod.object({
|
||||
"id": zod.coerce.number()
|
||||
})
|
||||
|
||||
|
||||
/**
|
||||
* @summary List audit log entries (admin only)
|
||||
*/
|
||||
export const ListAuditLogsQueryParams = zod.object({
|
||||
"entityType": zod.coerce.string().optional(),
|
||||
"entityId": zod.coerce.number().optional(),
|
||||
"limit": zod.coerce.number().optional()
|
||||
})
|
||||
|
||||
export const ListAuditLogsResponseItem = zod.object({
|
||||
"id": zod.number(),
|
||||
"entityType": zod.string(),
|
||||
"entityId": zod.number().nullish(),
|
||||
"action": zod.string(),
|
||||
"userId": zod.string(),
|
||||
"username": zod.string(),
|
||||
"changes": zod.string().nullish(),
|
||||
"createdAt": zod.coerce.date()
|
||||
})
|
||||
export const ListAuditLogsResponse = zod.array(ListAuditLogsResponseItem)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user