+
- {authOptions.map((option) => (
+ {disabled ? (
option.id === selectedAuthType)!}
+ isSelected={true}
+ disabled={true}
authSettings={toolset.authSettings}
- onChange={(authSettings) => onChange({ ...toolset, authSettings })}
+ {...props}
/>
- ))}
+ ) : (
+ authOptions.map((option) => (
+ onChange?.({ ...toolset, authSettings })}
+ {...props}
+ />
+ ))
+ )}
);
};
diff --git a/apps/ai-dial-admin/src/constants/i18n.ts b/apps/ai-dial-admin/src/constants/i18n.ts
index 1d6e485f0..d597b7d3a 100644
--- a/apps/ai-dial-admin/src/constants/i18n.ts
+++ b/apps/ai-dial-admin/src/constants/i18n.ts
@@ -789,7 +789,6 @@ export enum EntityPlaceholdersI18nKey {
Maintainer = 'EntityPlaceholders.Maintainer',
Type = 'EntityPlaceholders.Type',
Title = 'EntityPlaceholders.Title',
- Header = 'EntityPlaceholders.Header',
Tier = 'EntityPlaceholders.Tier',
Weight = 'EntityPlaceholders.Weight',
UpstreamEndpoint = 'EntityPlaceholders.UpstreamEndpoint',
@@ -818,12 +817,14 @@ export enum EntityPlaceholdersI18nKey {
ToolName = 'EntityPlaceholders.ToolName',
Hour = 'EntityPlaceholders.Hour',
Object = 'EntityPlaceholders.Object',
+ Header = 'EntityPlaceholders.Header',
}
export enum EntityFieldsI18nKey {
roleLimits = 'EntityFields.roleLimits',
isPublic = 'EntityFields.isPublic',
apiKeyHeader = 'EntityFields.apiKeyHeader',
+ apiKeyValue = 'EntityFields.apiKeyValue',
costLimit = 'EntityFields.costLimit',
defaultRoleLimit = 'EntityFields.defaultRoleLimit',
fieldsHashingOrder = 'EntityFields.fieldsHashingOrder',
diff --git a/apps/ai-dial-admin/src/locales/en.ts b/apps/ai-dial-admin/src/locales/en.ts
index ae3d5eef1..0da55217b 100644
--- a/apps/ai-dial-admin/src/locales/en.ts
+++ b/apps/ai-dial-admin/src/locales/en.ts
@@ -810,7 +810,8 @@ export default {
title: 'Title',
applicationTypeRoutes: 'App Routes',
routes: 'App Routes',
- apiKeyHeader: 'API key value',
+ apiKeyHeader: 'API key Header',
+ apiKeyValue: 'API key value',
costLimit: 'Cost limits',
applicationTypeCompletionEndpoint: 'Completion endpoint',
completionEndpoint: 'Completion endpoint',
diff --git a/apps/ai-dial-admin/src/models/dial/toolset.ts b/apps/ai-dial-admin/src/models/dial/toolset.ts
index 66f95536e..ef61238c6 100644
--- a/apps/ai-dial-admin/src/models/dial/toolset.ts
+++ b/apps/ai-dial-admin/src/models/dial/toolset.ts
@@ -22,6 +22,7 @@ export interface ToolsetAuthSettings {
clientSecret?: string;
redirectUri?: string;
authorizationEndpoint?: string;
+ codeChallenge?: string;
codeChallengeMethod?: ToolsetCodeChallengeMethod;
tokenEndpoint?: string;
scopesSupported?: string[];
diff --git a/apps/ai-dial-admin/src/server/entities/assets-api.ts b/apps/ai-dial-admin/src/server/entities/assets-api.ts
index 8fc2b68c2..bbff61f0c 100644
--- a/apps/ai-dial-admin/src/server/entities/assets-api.ts
+++ b/apps/ai-dial-admin/src/server/entities/assets-api.ts
@@ -221,14 +221,20 @@ export class AssetsApi extends BaseApi {
return this.post(url, { path: name }, token).then((res) => (res as { tools: Tool[] })?.tools || []);
}
- signInToolset(toolset: AssetToolset, type: ToolsetAuthCredentialLevel, token: JWT | null, authCode?: string) {
- const url = `${ResourceBasePaths[ResourceType.TOOLSET]}/signin`;
+ signInToolset(
+ toolset: AssetToolset,
+ type: ToolsetAuthCredentialLevel,
+ token: JWT | null,
+ apiKey?: string,
+ authCode?: string,
+ ) {
+ const url = `${ResourceBasePaths[ResourceType.TOOLSET]}/sign-in`;
- return this.postAction(url, getToolsetSignInBody(toolset, type, authCode), token);
+ return this.postAction(url, getToolsetSignInBody(toolset, type, apiKey, authCode), token);
}
signOutToolset(toolset: AssetToolset, type: ToolsetAuthCredentialLevel, token: JWT | null) {
- const url = `${ResourceBasePaths[ResourceType.TOOLSET]}/signout`;
+ const url = `${ResourceBasePaths[ResourceType.TOOLSET]}/sign-out`;
return this.postAction(url, getToolsetBasicBody(toolset, type), token);
}
diff --git a/apps/ai-dial-admin/src/utils/toolset/tests/toolset-auth.spec.ts b/apps/ai-dial-admin/src/utils/toolset/tests/toolset-auth.spec.ts
index f04b30fa0..e0caebda0 100644
--- a/apps/ai-dial-admin/src/utils/toolset/tests/toolset-auth.spec.ts
+++ b/apps/ai-dial-admin/src/utils/toolset/tests/toolset-auth.spec.ts
@@ -1,4 +1,4 @@
-import { ToolsetAuthStatus, ToolsetAuthType } from '@/src/models/dial/toolset';
+import { ToolsetAuthCredentialLevel, ToolsetAuthStatus, ToolsetAuthType } from '@/src/models/dial/toolset';
import { describe, expect, test } from 'vitest';
import {
encodeToolsetRedirectState,
@@ -10,28 +10,36 @@ import {
describe('toolset-auth utils', () => {
test('getToolsetSignInBody returns OAUTH body with code', () => {
const toolset = { authSettings: { authenticationType: ToolsetAuthType.OAUTH } } as any;
- const result = getToolsetSignInBody(toolset, 'admin', 'authcode');
+ const result = getToolsetSignInBody(toolset, ToolsetAuthCredentialLevel.APP, void 0, 'authcode');
expect(result).toMatchObject({
- credentials_level: 'admin',
+ credentialsLevel: ToolsetAuthCredentialLevel.APP,
authenticationType: ToolsetAuthType.OAUTH,
code: 'authcode',
});
});
test('getToolsetSignInBody returns APIKEY body with apiKeyHeader', () => {
- const toolset = { authSettings: { authenticationType: ToolsetAuthType.API_KEY, apiKeyHeader: 'X-API-KEY' } } as any;
- const result = getToolsetSignInBody(toolset, 'user');
+ const toolset = {
+ path: 'public/toolset1',
+ authSettings: { authenticationType: ToolsetAuthType.API_KEY, apiKeyHeader: 'X-API-KEY' },
+ } as any;
+ const result = getToolsetSignInBody(toolset, ToolsetAuthCredentialLevel.USER, 'value');
expect(result).toMatchObject({
- credentials_level: 'user',
+ url: 'toolsets/public/toolset1',
+ credentialsLevel: ToolsetAuthCredentialLevel.USER,
authenticationType: ToolsetAuthType.API_KEY,
- apiKeyHeader: 'X-API-KEY',
+ apiKey: 'value',
});
});
test('getToolsetBasicBody returns basic body', () => {
- const toolset = { authSettings: { authenticationType: ToolsetAuthType.API_KEY } } as any;
- const result = getToolsetBasicBody(toolset, 'user');
- expect(result).toMatchObject({ credentials_level: 'user', authenticationType: ToolsetAuthType.API_KEY });
+ const toolset = { path: 'public/toolset1', authSettings: { authenticationType: ToolsetAuthType.API_KEY } } as any;
+ const result = getToolsetBasicBody(toolset, ToolsetAuthCredentialLevel.USER);
+ expect(result).toMatchObject({
+ url: 'toolsets/public/toolset1',
+ credentialsLevel: ToolsetAuthCredentialLevel.USER,
+ authenticationType: ToolsetAuthType.API_KEY,
+ });
});
test('encodeToolsetRedirectState encodes state to base64url', () => {
diff --git a/apps/ai-dial-admin/src/utils/toolset/toolset-auth.ts b/apps/ai-dial-admin/src/utils/toolset/toolset-auth.ts
index 32eac6e36..ab4343947 100644
--- a/apps/ai-dial-admin/src/utils/toolset/toolset-auth.ts
+++ b/apps/ai-dial-admin/src/utils/toolset/toolset-auth.ts
@@ -1,26 +1,25 @@
import { AssetToolset } from '@/src/models/dial/deployment-asset';
import { ToolsetAuthCredentialLevel, ToolsetAuthStatus, ToolsetAuthType } from '@/src/models/dial/toolset';
-export const getToolsetSignInBody = (toolset: AssetToolset, level: ToolsetAuthCredentialLevel, authCode?: string) => {
+export const getToolsetSignInBody = (
+ toolset: AssetToolset,
+ level: ToolsetAuthCredentialLevel,
+ apiKey?: string,
+ authCode?: string,
+) => {
const body = { ...getToolsetBasicBody(toolset, level) };
if (toolset.authSettings?.authenticationType === ToolsetAuthType.OAUTH) {
- return {
- ...body,
- code: authCode,
- };
+ return { ...body, code: authCode };
}
- return {
- ...body,
- apiKeyHeader: toolset.authSettings?.apiKeyHeader,
- };
+ return { ...body, apiKey };
};
export const getToolsetBasicBody = (toolset: AssetToolset, level: ToolsetAuthCredentialLevel) => {
return {
- // url: 'toolsets/{bucket}/{path}', // TODO: ask BE
- credentials_level: level,
+ url: `toolsets/${toolset.path}`,
+ credentialsLevel: level,
authenticationType: toolset.authSettings?.authenticationType,
};
};