Widget identity verification lets your server prove which signed-in visitor is using the embedded widget. Kommander.ai uses that verified identity before enabling customer-specific tools, customer data connectors, and ownership checks.

This page is the security companion to the widget identity setup guide. Use it when you need to understand the trust boundary and failure modes, not only how to paste the embed snippet.

HMAC In Plain Terms

HMAC means hash-based message authentication code. Your server and Kommander.ai share one secret. Your server combines that secret with the exact identity payload and timestamp, then produces a SHA-256 signature. Kommander.ai repeats the same calculation with its stored secret. If the signatures match, the identity payload came from a system that knows the secret and the payload was not changed in the browser.

HMAC does not encrypt the payload. Do not put access tokens, passwords, session cookies, or unnecessary personal data in signed identity. Treat the signature as proof of origin and integrity, not confidentiality.

Threat Model

The browser is not an identity authority. A visitor can edit JavaScript, URL parameters, local storage, chat text, and network requests. The model can also propose tool arguments that look like identity fields.

Kommander.ai treats only server-generated identity material as authoritative:

  • Your application authenticates the visitor.
  • Your server builds a compact identity payload.
  • Your server signs that payload with the widget identity secret.
  • The browser sends the payload and signature to the widget.
  • Kommander.ai verifies the signature before exposing identity-bound capabilities.

If verification fails, the widget can still support anonymous public chat, but customer-specific data tools stay hidden.

Signing Contract

Generate the signature on your server after the visitor has authenticated. Never place the widget identity secret in browser code, mobile app bundles, CMS snippets, tag managers, or model-visible content.

For signed-envelope integrations, sign this exact string:

{timestamp}.{payload}

Example verifier logic:

import crypto from 'node:crypto'; export function isValidIdentitySignature(input: { payload: string; timestamp: number; signature: string; secret: string; }) { const expected = crypto .createHmac('sha256', input.secret) .update(`${input.timestamp}.${input.payload}`, 'utf8') .digest(); const received = Buffer.from(input.signature, 'hex'); return received.length === expected.length && crypto.timingSafeEqual(received, expected); }

The signed identity should contain only fields needed for authorization and ownership checks:

FieldUse
idStable application user ID when your connector uses user IDs.
emailEmail address only when an upstream system requires it.
userHashPreferred opaque ownership key for customer data connectors.
metadataMinimal tenant or account attributes needed by your connector.
timestampFreshness check and replay-window enforcement.

Prefer userHash over directly identifying values. It should be stable for the same end user and not reversible by someone who sees widget traffic.

Verification Flow

The verified identity is attached server-side to the request context. Tool arguments generated by the model are not allowed to replace it.

Failure Handling

FailureResult
Missing signaturePublic chat may continue; identity-bound tools are not exposed.
Invalid signatureIdentity is rejected and customer data tools remain hidden.
Stale timestampIdentity is rejected to reduce replay risk.
Missing userHash for customer dataCustomer data tools remain hidden.
Model sends spoofed identity argumentsReserved identity arguments are stripped before execution.

Do not retry by falling back to unsigned id, email, or chat-provided identity. That turns a verification failure into an authorization bypass.

Secret Rotation

Rotate the widget identity secret from the identity verification settings when a secret may have been exposed, when staff access changes, or on your normal credential rotation schedule. Kommander.ai keeps the previous secret active during a grace period so production deployments can roll forward without immediately breaking signed-in widget sessions.

After rotation:

  1. Generate or rotate the secret in Kommander.ai.
  2. Deploy the new secret to every signing service.
  3. Confirm new signatures match the current secret.
  4. Monitor identity verification failures during the rollout.
  5. Remove the old secret from environment variables and secret stores before the grace period ends.

During the grace period, verification tries the current secret first and then the previous secret. Your application should emit signatures with the new secret as soon as the deployment reaches production.

Implementation Checklist

  • Sign only on trusted server infrastructure.
  • Keep the payload compact and deterministic.
  • Include a timestamp and reject stale signatures.
  • Use constant-time signature comparison in your signing service when comparing signatures.
  • Send customer-specific connector identifiers through signed identity, not chat text.
  • Treat id, email, userHash, metadata, verifiedUser, and signature fields from model tool arguments as untrusted.

Troubleshooting

SymptomLikely causeWhat to check
Every signed-in user is anonymousSecret mismatch or missing secret in Kommander.ai.Compare the widget client, environment variable name, and active secret.
Only some users lose customer-data toolsPayload missing userHash or userId.Log a redacted payload for a failing user and confirm required fields are non-empty strings.
Failures started after deployJSON serialization changed.Sign and send the exact same payload bytes; do not pretty-print in one place and compact in another.
Failures started after rotationSome servers still use the old secret or cache stale config.Restart signing workers and verify all environments read the new secret.
timestamp_too_old or timestamp_in_futureClock skew or browser-generated timestamps.Generate timestamps server-side and keep servers synchronized with NTP.
HMAC looks correct locally but fails in Kommander.aiEncoding mismatch.Confirm signatureEncoding is hex, base64, or base64url and matches the digest you send.