定制 helfentalk/laravel-plugin 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

helfentalk/laravel-plugin

Composer 安装命令:

composer require helfentalk/laravel-plugin

包简介

HeflenTalk Connect plugin for Laravel tenants — securely expose role-scoped data to HeflenTalk over a signed internal endpoint. Data never leaves your server.

README 文档

README

helfentalk/laravel-plugin lets a HeflenTalk tenant securely expose their own data to their chatbot without the data ever leaving their server. HeflenTalk calls a single signed endpoint inside your app; the plugin verifies the request, applies role rules, queries only whitelisted tables, and returns role-scoped rows.

Install

composer require helfentalk/laravel-plugin
php artisan vendor:publish --tag=helfentalk-config

Then set your Connect secret (from the HeflenTalk dashboard → API Keys / Connect) in .env:

HELFENTALK_KEY=htc_xxxxxxxxxxxxxxxxxxxxxxxxxxxx

Configure

config/helfentalk.php:

return [
    'api_key'        => env('HELFENTALK_KEY'),
    'allowed_tables' => ['employees', 'leaves', 'payslips'],
    'role_rules'     => [
        'employee' => ['own_data_only' => true],
        'manager'  => ['scope' => 'team'],
        'admin'    => ['scope' => 'all'],
    ],
    'user_column'    => 'user_id',
    'team_column'    => 'team_id',
];
  • allowed_tables — the only tables the plugin will ever read. Schema/columns are auto-discovered; you never register endpoints per table.
  • role_rules — maps the user's role to a data scope (own / team / all).

Finally, give HeflenTalk your endpoint URL (Bot settings → Connect):

https://your-app.com/helfentalk/connect

How it works

HeflenTalk-be  ──(HMAC-signed POST)──▶  /helfentalk/connect
                                              │ verify signature (HELFENTALK_KEY)
                                              │ resolve scope from role_rules
                                              │ query allowed_tables, scoped by role
                                              ▼
                                        { "data": { ...rows... } }  ──▶ HeflenTalk
                                              injects into the AI prompt

The signature covers "{timestamp}.{rawBody}" with HMAC-SHA256 using your HELFENTALK_KEY. The same secret is what you use to sign the user-context JWT on your side, so the user identity HeflenTalk forwards is trustworthy.

Request (from HeflenTalk → plugin)

POST /helfentalk/connect
X-HeflenTalk-Timestamp: 1700000000
X-HeflenTalk-Signature: <hmac-sha256>
Content-Type: application/json

{ "message": "Berapa baki cuti saya?",
  "scope": "own",
  "user_context": { "user_id": 123, "name": "Ahmad", "role": "employee" } }

Response

{ "data": { "leaves": [{ "user_id": 123, "balance_days": 12 }] },
  "scope": "own", "user_id": 123 }

Security

  • Every request is HMAC-verified before any DB access; missing, stale (> tolerance), or invalid signatures are rejected with 401.
  • The allowed_tables whitelist is enforced strictly — the plugin never touches a table outside it.
  • Rows are always scoped by role: own filters by user_column = user_id, team by team_column = team_id; an unknown role falls back to own (never leaks everything).
  • The plugin recomputes the scope from its own role_rules and never trusts the scope field HeflenTalk sends.

Test

composer install
composer test

Sibling plugins for other stacks: helfentalk-express (Node) and helfentalk-django (Python) follow the same signed-request contract.

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固