feat(php): signed-in users through the dewee identity session exchange (parity with the TypeScript handler)

Đang mở
#5 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
25/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
github, php, typescript
Lĩnh vực
api, authentication, backend

Hướng nghiên cứu

Read php/dewee-webchat.php, the TypeScript handler, docs/http-contract.md, and test/php-parity.test.ts; then compare the signed-in user sections in packages/dewee-webchat/README.md and the isolation tests in packages/dewee-webchat/test/. Implementing this scope spans signing, session exchange, chat/history binding, links, and error handling. Done means PHP lint passes and parity and isolation checks match the stated acceptance criteria.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

ai-handle enhancement

Context

The Node/Workers handler can sign users in through a Dewee identity session exchange (identity option, see the "Signed-in users" sections of packages/dewee-webchat/README.md and docs/http-contract.md). The single-file PHP backend (php/dewee-webchat.php) does not support it yet: the exchange needs a signed partner assertion (a compact JWS, HS256 for hmac applications and RS256/ES256/EdDSA for jwks ones), and the PHP adapter has no JWS signing.

Surface parity: php/dewee-webchat.php N/A in the first PR because identity exchange needs JWS signing not yet in the PHP adapter.

Parent: nextlevelbuilder/dewee#1450 (Trusted User Context + Dewee Connect).

Scope

Bring the PHP backend to parity with the TypeScript handler for signed-in users, without new Composer dependencies:

  1. An identity option: authenticate callable, appId, issuer, audience (optional check, dewee:<appId>), and exactly one of assertionSecret or privateKeyJwk (+ algorithm), agent, required, sessionTtlSeconds.
  2. Assertion signing: HS256 with hash_hmac over the UTF-8 secret exactly as issued; ES256/RS256 with openssl_sign (ES256 converted from DER to the 64-byte JOSE form). Header typ: dewee-session+jwt, claims iss, aud, sub, iat, exp (at most 300 s), fresh jti. Refuse a sub containing @.
  3. POST /session: POST {gateway}/v1/identity/sessions/exchange, visitor token claims ids and ida, exp = min(session expiry, visitor expiry), verified: true, visitor id derived from the principal (HMAC of the visitor secret over dewee-webchat:visitor:principal:<id>, first 16 bytes, base64url).
  4. /chat and /history: connect with identity_session and no user_id; bind the request to ida; forward the seven identity codes as {error:{message, code, remediation}} with the statuses in docs/http-contract.md.
  5. POST /link: POST {gateway}/v1/identity/links with X-Dewee-Identity-Session, answer {proofCode, expiresAt, deepLinks}.
  6. Fail closed exactly like the TypeScript handler: no anonymous fallback for a signed-in user whose exchange fails; anonymous only when not required; refuse identity combined with client credentials; never echo the gateway token, assertion secret or private key.

Acceptance

  • php -l php/dewee-webchat.php passes.
  • A parity test (like test/php-parity.test.ts) shows the PHP and TypeScript backends produce the same visitor-id derivation, claim shape and error envelopes, and that a PHP-signed assertion verifies with the same checks the gateway applies.
  • The isolation cases of packages/dewee-webchat/test/identity.test.ts hold for the PHP backend (different users get different sessions, a replayed token keeps its user, a tampered token is 401, secrets never appear in a response).
Ngôn ngữ chính
TypeScript
Star
7
Fork
1
Merge trung bình
1 ngày 3 giờ
Pull request đã merge (30 ngày)
8

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của nextlevelbuilder/dewee-webchat

Tất cả issue của nextlevelbuilder/dewee-webchat

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.