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
@@ -9,6 +9,82 @@ export interface HealthStatus {
status: string;
}
export type AuthModeMode = typeof AuthModeMode[keyof typeof AuthModeMode];
export const AuthModeMode = {
oidc: 'oidc',
local: 'local',
} as const;
export interface AuthMode {
mode: AuthModeMode;
}
export interface LocalLoginInput {
username: string;
password: string;
}
export type UserRole = typeof UserRole[keyof typeof UserRole];
export const UserRole = {
admin: 'admin',
user: 'user',
} as const;
export interface User {
id: number;
username: string;
/** @nullable */
email?: string | null;
role: UserRole;
createdAt: string;
}
export type UserCreateInputRole = typeof UserCreateInputRole[keyof typeof UserCreateInputRole];
export const UserCreateInputRole = {
admin: 'admin',
user: 'user',
} as const;
export interface UserCreateInput {
/** @minLength 2 */
username: string;
/** @minLength 6 */
password: string;
email?: string;
role?: UserCreateInputRole;
}
export type UserRoleUpdateRole = typeof UserRoleUpdateRole[keyof typeof UserRoleUpdateRole];
export const UserRoleUpdateRole = {
admin: 'admin',
user: 'user',
} as const;
export interface UserRoleUpdate {
role: UserRoleUpdateRole;
}
export interface AuditLog {
id: number;
entityType: string;
/** @nullable */
entityId?: number | null;
action: string;
userId: string;
username: string;
/** @nullable */
changes?: string | null;
createdAt: string;
}
export interface Tool {
id: number;
name: string;
@@ -18,6 +94,8 @@ export interface Tool {
websiteUrl?: string | null;
/** @nullable */
iconUrl?: string | null;
/** @nullable */
createdBy?: string | null;
features?: string[];
tags?: string[];
createdAt: string;
@@ -33,6 +111,8 @@ export interface ToolWithStats {
websiteUrl?: string | null;
/** @nullable */
iconUrl?: string | null;
/** @nullable */
createdBy?: string | null;
features?: string[];
tags?: string[];
createdAt: string;
@@ -144,6 +224,14 @@ export interface RatingDistribution {
usability: ScoreBucket[];
}
export type AuthUserRole = typeof AuthUserRole[keyof typeof AuthUserRole];
export const AuthUserRole = {
admin: 'admin',
user: 'user',
} as const;
export interface AuthUser {
sub: string;
/** @nullable */
@@ -152,6 +240,8 @@ export interface AuthUser {
name?: string | null;
/** @nullable */
preferredUsername?: string | null;
role?: AuthUserRole;
isLocal?: boolean;
}
export interface ErrorResponse {
@@ -191,3 +281,9 @@ export type GetRatingDistributionParams = {
toolId?: number;
};
export type ListAuditLogsParams = {
entityType?: string;
entityId?: number;
limit?: number;
};