persist model access policy to database
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@ import { createRouter } from '../../create-router';
|
||||
import { PI_CONFIG_DIR } from '../../data-path';
|
||||
import { invalidateModelCache } from '../pi/list-models';
|
||||
import { logger } from '../pi/logger';
|
||||
import { readConfigValue, writeConfigValue } from 'officerdb';
|
||||
|
||||
export const piMonoRouter = createRouter();
|
||||
|
||||
@@ -387,6 +388,20 @@ piMonoRouter.put('/api-keys', async (ctx) => {
|
||||
return ctx.json({ ok: true });
|
||||
});
|
||||
|
||||
type AccessPolicy = { allowedModels: string[] };
|
||||
const ACCESS_POLICY_KEY = 'pi-access-policy';
|
||||
|
||||
piMonoRouter.get('/access-policy', async (ctx) => {
|
||||
const policy = await readConfigValue<AccessPolicy>(ACCESS_POLICY_KEY, { allowedModels: [] });
|
||||
return ctx.json(policy);
|
||||
});
|
||||
|
||||
piMonoRouter.put('/access-policy', async (ctx) => {
|
||||
const body = await ctx.req.json<AccessPolicy>();
|
||||
await writeConfigValue(ACCESS_POLICY_KEY, body);
|
||||
return ctx.json(body);
|
||||
});
|
||||
|
||||
const REMOTE_HEALTH_CONFIG: Record<string, {
|
||||
url: string | ((key: string) => string);
|
||||
headers: (key: string) => Record<string, string>;
|
||||
|
||||
Reference in New Issue
Block a user