Skip to content

Commit 913bdf8

Browse files
authored
Merge pull request #20 from loveyana/main
feat(cloud): add OAuth2/JWT authentication support for CloudStrategy
2 parents bdb24a9 + 44f19ff commit 913bdf8

File tree

6 files changed

+246
-23
lines changed

6 files changed

+246
-23
lines changed

agentkit/toolkit/config/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
from .utils import is_valid_config, is_invalid_config, merge_runtime_envs
4545
from .constants import (
4646
AUTO_CREATE_VE,
47+
AUTH_TYPE_KEY_AUTH,
48+
AUTH_TYPE_CUSTOM_JWT,
4749
GLOBAL_CONFIG_FILE_PERMISSIONS,
4850
GLOBAL_CONFIG_FILE,
4951
GLOBAL_CONFIG_DIR,
@@ -70,6 +72,8 @@
7072
"CRGlobalConfig",
7173
"TOSGlobalConfig",
7274
"AUTO_CREATE_VE",
75+
"AUTH_TYPE_KEY_AUTH",
76+
"AUTH_TYPE_CUSTOM_JWT",
7377
"DEFAULT_WORKSPACE_NAME",
7478
"DEFAULT_CR_NAMESPACE",
7579
"DEFAULT_CR_INSTANCE_TEMPLATE_NAME",

agentkit/toolkit/config/constants.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,6 @@
3636
GLOBAL_CONFIG_DIR = Path.home() / ".agentkit"
3737
GLOBAL_CONFIG_FILE = GLOBAL_CONFIG_DIR / "config.yaml"
3838
GLOBAL_CONFIG_FILE_PERMISSIONS = 0o600 # Owner read/write only
39+
40+
AUTH_TYPE_KEY_AUTH = "key_auth"
41+
AUTH_TYPE_CUSTOM_JWT = "custom_jwt"

agentkit/toolkit/config/strategy_configs.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
from typing import Dict, List
33
from .dataclass_utils import AutoSerializableMixin
44
from .constants import (
5+
AUTH_TYPE_CUSTOM_JWT,
6+
AUTH_TYPE_KEY_AUTH,
57
AUTO_CREATE_VE,
68
DEFAULT_CR_NAMESPACE,
79
DEFAULT_IMAGE_TAG,
@@ -207,6 +209,20 @@ class HybridStrategyConfig(AutoSerializableMixin):
207209
"aliases": ["ve_runtime_role_name"],
208210
},
209211
)
212+
runtime_auth_type: str = field(
213+
default=AUTH_TYPE_KEY_AUTH,
214+
metadata={
215+
"description": "Runtime authentication type",
216+
"icon": "🔑",
217+
"choices": [
218+
{"value": AUTH_TYPE_KEY_AUTH, "description": "API Key authentication"},
219+
{
220+
"value": AUTH_TYPE_CUSTOM_JWT,
221+
"description": "OAuth2/JWT authentication",
222+
},
223+
],
224+
},
225+
)
210226
runtime_apikey_name: str = field(
211227
default=AUTO_CREATE_VE,
212228
metadata={
@@ -223,6 +239,20 @@ class HybridStrategyConfig(AutoSerializableMixin):
223239
"aliases": ["ve_runtime_apikey"],
224240
},
225241
)
242+
runtime_jwt_discovery_url: str = field(
243+
default="",
244+
metadata={
245+
"description": "OIDC Discovery URL for JWT validation (required when auth_type is custom_jwt)",
246+
"examples": "https://userpool-xxx.userpool.auth.id.cn-beijing.volces.com/.well-known/openid-configuration",
247+
},
248+
)
249+
runtime_jwt_allowed_clients: List[str] = field(
250+
default_factory=list,
251+
metadata={
252+
"description": "Allowed OAuth2 client IDs (required when auth_type is custom_jwt)",
253+
"examples": "['fa99ec54-8a1c-49b2-9a9e-3f3ba31d9a33']",
254+
},
255+
)
226256
runtime_endpoint: str = field(
227257
default="",
228258
metadata={
@@ -403,6 +433,20 @@ class CloudStrategyConfig(AutoSerializableMixin):
403433
"aliases": ["ve_runtime_role_name"],
404434
},
405435
)
436+
runtime_auth_type: str = field(
437+
default=AUTH_TYPE_KEY_AUTH,
438+
metadata={
439+
"description": "Runtime authentication type",
440+
"icon": "🔑",
441+
"choices": [
442+
{"value": AUTH_TYPE_KEY_AUTH, "description": "API Key authentication"},
443+
{
444+
"value": AUTH_TYPE_CUSTOM_JWT,
445+
"description": "OAuth2/JWT authentication",
446+
},
447+
],
448+
},
449+
)
406450
runtime_apikey_name: str = field(
407451
default=AUTO_CREATE_VE,
408452
metadata={
@@ -419,6 +463,20 @@ class CloudStrategyConfig(AutoSerializableMixin):
419463
"aliases": ["ve_runtime_apikey"],
420464
},
421465
)
466+
runtime_jwt_discovery_url: str = field(
467+
default="",
468+
metadata={
469+
"description": "OIDC Discovery URL for JWT validation (required when auth_type is custom_jwt)",
470+
"examples": "https://userpool-xxx.userpool.auth.id.cn-beijing.volces.com/.well-known/openid-configuration",
471+
},
472+
)
473+
runtime_jwt_allowed_clients: List[str] = field(
474+
default_factory=list,
475+
metadata={
476+
"description": "Allowed OAuth2 client IDs (required when auth_type is custom_jwt)",
477+
"examples": "['fa99ec54-8a1c-49b2-9a9e-3f3ba31d9a33']",
478+
},
479+
)
422480
runtime_endpoint: str = field(
423481
default="",
424482
metadata={

0 commit comments

Comments
 (0)