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:
cheffe01
2026-05-25 14:11:02 +00:00
parent b8ba53598d
commit c5ca3ca992
44 changed files with 2554 additions and 34 deletions
+264
View File
@@ -16,6 +16,12 @@ tags:
description: Tool ratings
- name: analytics
description: Analytics and aggregated statistics
- name: auth
description: Authentication
- name: users
description: User management (admin only)
- name: audit
description: Audit log
paths:
/healthz:
get:
@@ -319,6 +325,44 @@ paths:
items:
type: string
/auth/mode:
get:
operationId: getAuthMode
tags: [auth]
summary: Get authentication mode (oidc or local)
responses:
"200":
description: Auth mode
content:
application/json:
schema:
$ref: "#/components/schemas/AuthMode"
/auth/login:
post:
operationId: localLogin
tags: [auth]
summary: Local username/password login
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/LocalLoginInput"
responses:
"200":
description: Logged in successfully
content:
application/json:
schema:
$ref: "#/components/schemas/AuthUser"
"401":
description: Invalid credentials
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
/auth/me:
get:
operationId: getMe
@@ -338,6 +382,137 @@ paths:
schema:
$ref: "#/components/schemas/ErrorResponse"
/users:
get:
operationId: listUsers
tags: [users]
summary: List all local users (admin only)
responses:
"200":
description: User list
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/User"
"401":
description: Not authenticated
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
"403":
description: Forbidden
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
post:
operationId: createUser
tags: [users]
summary: Create a new local user (admin only)
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/UserCreateInput"
responses:
"201":
description: Created user
content:
application/json:
schema:
$ref: "#/components/schemas/User"
"400":
description: Validation error
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
"409":
description: Username already exists
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
/users/{id}:
patch:
operationId: updateUser
tags: [users]
summary: Update user role (admin only)
parameters:
- name: id
in: path
required: true
schema:
type: integer
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/UserRoleUpdate"
responses:
"200":
description: Updated user
content:
application/json:
schema:
$ref: "#/components/schemas/User"
"404":
description: User not found
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
delete:
operationId: deleteUser
tags: [users]
summary: Delete a user (admin only)
parameters:
- name: id
in: path
required: true
schema:
type: integer
responses:
"204":
description: Deleted
/audit-logs:
get:
operationId: listAuditLogs
tags: [audit]
summary: List audit log entries (admin only)
parameters:
- name: entityType
in: query
required: false
schema:
type: string
- name: entityId
in: query
required: false
schema:
type: integer
- name: limit
in: query
required: false
schema:
type: integer
responses:
"200":
description: Audit log entries
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/AuditLog"
components:
schemas:
HealthStatus:
@@ -348,6 +523,86 @@ components:
required:
- status
AuthMode:
type: object
required: [mode]
properties:
mode:
type: string
enum: [oidc, local]
LocalLoginInput:
type: object
required: [username, password]
properties:
username:
type: string
password:
type: string
User:
type: object
required: [id, username, role, createdAt]
properties:
id:
type: integer
username:
type: string
email:
type: ["string", "null"]
role:
type: string
enum: [admin, user]
createdAt:
type: string
format: date-time
UserCreateInput:
type: object
required: [username, password]
properties:
username:
type: string
minLength: 2
password:
type: string
minLength: 6
email:
type: string
role:
type: string
enum: [admin, user]
UserRoleUpdate:
type: object
required: [role]
properties:
role:
type: string
enum: [admin, user]
AuditLog:
type: object
required: [id, entityType, action, userId, username, createdAt]
properties:
id:
type: integer
entityType:
type: string
entityId:
type: ["integer", "null"]
action:
type: string
userId:
type: string
username:
type: string
changes:
type: ["string", "null"]
createdAt:
type: string
format: date-time
Tool:
type: object
required: [id, name, description, category, createdAt, updatedAt]
@@ -364,6 +619,8 @@ components:
type: ["string", "null"]
iconUrl:
type: ["string", "null"]
createdBy:
type: ["string", "null"]
features:
type: array
items:
@@ -395,6 +652,8 @@ components:
type: ["string", "null"]
iconUrl:
type: ["string", "null"]
createdBy:
type: ["string", "null"]
features:
type: array
items:
@@ -587,6 +846,11 @@ components:
type: ["string", "null"]
preferredUsername:
type: ["string", "null"]
role:
type: string
enum: [admin, user]
isLocal:
type: boolean
ErrorResponse:
type: object