feat(models): persist explicitly saved credentials with user-scoped DPAPI
This commit is contained in:
+3
-1
@@ -138,16 +138,18 @@ return async (request, response) => {
|
||||
const hub = provider.modelHub(store);
|
||||
const importer = () => hub.importer ??= new ConfigImporter(hub);
|
||||
if (method === 'GET' && route === '/api/model-center') return json(response, hub.view());
|
||||
if (method === 'GET' && route === '/api/model-center/credentials') return json(response, hub.vault().view(hub));
|
||||
if (method === 'GET' && route === '/api/model-center/imports') return json(response, importer().discover());
|
||||
if (method === 'POST') {
|
||||
const input = await body(request);
|
||||
if (route === '/api/model-center/toggle') return json(response, hub.toggle(input.id, input.enabled));
|
||||
if (runtime.hasActivity()) throw Object.assign(new Error('请先停止正在运行的任务,再修改或测试模型配置。'), { status: 409 });
|
||||
if (route === '/api/model-center/credentials') return json(response, hub.manageCredential(input));
|
||||
if (route === '/api/model-center/connections') return json(response, hub.upsert(input), 201);
|
||||
if (route === '/api/model-center/pools') return json(response, hub.pool(input), 201);
|
||||
if (route === '/api/model-center/select') return json(response, { center: hub.select(input), config: { ...store.config, hasKey: provider.hasKey() } });
|
||||
if (route === '/api/model-center/import-preview') return json(response, importer().preview(input.source, String(input.path ?? '')));
|
||||
if (route === '/api/model-center/import-apply') return json(response, importer().apply(input.previewId, input.autoSync));
|
||||
if (route === '/api/model-center/import-apply') return json(response, importer().apply(input.previewId, input.autoSync, input.persistCredentials));
|
||||
if (route === '/api/model-center/import-toggle') return json(response, importer().toggle(input.id, input.enabled));
|
||||
if (route === '/api/model-center/import-sync') return json(response, { results: importer().sync(), center: hub.view() });
|
||||
if (route === '/api/model-center/probe') {
|
||||
|
||||
Reference in New Issue
Block a user