diff --git a/workers/aibox_sophon_adapter/config.toml b/workers/aibox_sophon_adapter/config.toml index ed607ca..5ab29c0 100644 --- a/workers/aibox_sophon_adapter/config.toml +++ b/workers/aibox_sophon_adapter/config.toml @@ -109,6 +109,8 @@ enabled = false # 是否启用豆包 AI 分析告警图片 [workers.config.ip_sound_column] enabled = false # 是否开启IP音柱报警 +volume = 50 +tts = {} [workers.config.alarm_forward] # enabled = false # 是否启用告警转发到外部平台 diff --git a/workers/auth/login.toml b/workers/auth/login.toml deleted file mode 100644 index 27dd0ce..0000000 --- a/workers/auth/login.toml +++ /dev/null @@ -1,13 +0,0 @@ -[POST] -cacheable = false -auth_required = false -summary = "登录" -docstring = "根据用户名和密码进行登录,登录成功返回token,获取请求需带式token进行请求" -params = ["username: str", "password: str"] - -[POST.response_model] -result = {type = "str", required = true} -token = {type = "str", required = true} -message = {type = "str", required = true} -timestamp = {type = "float", required = false} - diff --git a/workers/auth_oauth/config.toml b/workers/auth_oauth/config.toml new file mode 100644 index 0000000..093cc1e --- /dev/null +++ b/workers/auth_oauth/config.toml @@ -0,0 +1,34 @@ +# ====== 插件注册信息(控制加载方式) ====== +[workers] +type = "auth_oauth" +module = "plugins.auth_oauth" +factory = "create_workers" +cleanup = "cleanup" +count = 1 +# 身份源插件持有签名密钥的使用方(issue_token),走 inline 与网关同信任域; +# external 部署前需先解决密钥下发问题(见插件 README 安全说明) +load_mode = "inline" + +[worker] +name = "auth_oauth" +version = "0.1.0" +description = "第三方授权登录示例(GitHub OAuth / 手机验证码)" +config_version = "1.0" +defaults = { method = "GET", ttl = 30, timeout = 10.0, auth_required = false, cacheable = false } + +[worker.registration] +router_prefix = "/auth/oauth" +tags = ["auth_oauth"] + +# ====== Worker 运行时配置 ====== +[workers.config] +data_dir = "./data" +# 演示模式:验证码随响应返回(无短信通道的本地演示)。生产必须置 false 并接真实短信通道 +return_otp_in_response = true + +# GitHub OAuth App 凭据(https://github.com/settings/developers 创建) +[workers.config.github] +client_id = "your-github-oauth-client-id" +client_secret = "your-github-oauth-client-secret" +redirect_uri = "http://localhost:5173/auth/oauth/github/callback" +scope = "read:user user:email" diff --git a/workers/auth_oauth/github_authorize.toml b/workers/auth_oauth/github_authorize.toml new file mode 100644 index 0000000..bb34167 --- /dev/null +++ b/workers/auth_oauth/github_authorize.toml @@ -0,0 +1,5 @@ +[GET] +summary = "GitHub 授权登录:生成授权跳转 URL" +docstring = "生成 GitHub OAuth 授权链接(含防 CSRF 的 state,存共享缓存 300s)。前端拿 authorize_url 自行跳转。" +auth_required = false +cacheable = false diff --git a/workers/auth_oauth/github_callback.toml b/workers/auth_oauth/github_callback.toml new file mode 100644 index 0000000..36dd428 --- /dev/null +++ b/workers/auth_oauth/github_callback.toml @@ -0,0 +1,12 @@ +[POST] +summary = "GitHub 授权回调:换取用户信息并签发平台 token" +docstring = "前端收到 GitHub 回跳的 code+state 后调用;校验 state(一次性)、换取用户信息、按绑定关系 find-or-create 账号,签发与内置登录同契约的平台 token。" +auth_required = false +cacheable = false +params = ["code: str", "state: str"] + +[POST.response_model] +result = { type = "str", required = true } +token = { type = "str", required = true } +message = { type = "str", required = true } +timestamp = { type = "float", required = false } diff --git a/workers/auth_oauth/phone_login.toml b/workers/auth_oauth/phone_login.toml new file mode 100644 index 0000000..367d5ef --- /dev/null +++ b/workers/auth_oauth/phone_login.toml @@ -0,0 +1,12 @@ +[POST] +summary = "手机验证码登录:校验验证码并签发平台 token" +docstring = "校验一次性验证码后,按手机号绑定关系 find-or-create 账号,签发与内置登录同契约的平台 token。" +auth_required = false +cacheable = false +params = ["phone: str", "code: str"] + +[POST.response_model] +result = { type = "str", required = true } +token = { type = "str", required = true } +message = { type = "str", required = true } +timestamp = { type = "float", required = false } diff --git a/workers/auth_oauth/phone_send_code.toml b/workers/auth_oauth/phone_send_code.toml new file mode 100644 index 0000000..2da823d --- /dev/null +++ b/workers/auth_oauth/phone_send_code.toml @@ -0,0 +1,12 @@ +[POST] +summary = "手机验证码登录:下发验证码" +docstring = "生成 6 位验证码存共享缓存(300s)。演示模式随响应返回 dev_code,生产接短信通道后返回 dev_code=null。" +auth_required = false +cacheable = false +params = ["phone: str"] + +[POST.response_model] +result = { type = "str", required = true } +message = { type = "str", required = true } +expires_in = { type = "int", required = false, default = 300 } +dev_code = { type = "str", required = false } diff --git a/workers/example/add.toml b/workers/example/add.toml index 68484e3..0807539 100644 --- a/workers/example/add.toml +++ b/workers/example/add.toml @@ -7,6 +7,7 @@ summary = "Add two numbers" docstring = "Add two numbers via GET query params" params = ["a: float", "b: float"] auth_required = false +validate = false [GET.response_model] result = { type = "float", required = true }