If your front end uses a third-party SDK with a public key, anyone who opens your site can read that key. Without more protection, anyone can then call…
If your front end uses a third-party SDK with a public key, anyone who opens your site can read that key. Without more protection, anyone can then call identify("someone-else") and write to that person's profile, chat history and feedback. The fix is to have your server sign the user id, and have the SDK send the signature. This guide shows the steps in order, with code in five languages. I am building JustOneCX (disclosure), so the examples use its SDK.
The idea is the same in any tool that supports a signed identity. What problem does it solve? The public key identifies your workspace. It is meant to be public. It does not prove who the person is. So the SDK cannot tell a real signed-in user from someone typing in the browser console. Identity verification closes that gap. After a user signs in, your server signs their user id with a secret key.
The service checks the signature and ignores identify() calls without a valid one. What is the order of steps? The order matters. If you turn the requirement on before your site sends the signature, all your existing users count as unverified. Copy the secret key from Settings → Developers. It is shown in full only once. Store it on your server only, as JUSTONECX_SECRET_KEY. Add the empty name to .env.example. Sign the user id on your server after login.
Pass the signature to the SDK in the browser and deploy. Turn on Require identity verification. Sign in on your site and check that verified sign-ins arrive. How do you sign the user id? Use an HMAC with SHA-256 of the user id, keyed with the secret key. The result is a hex string.
import { createHmac } from "node:crypto"; .update(String(user.id)) .digest("hex"); # Python import hmac, hashlib, os user_hash = hmac.new( os.environ["JUSTONECX_SECRET_KEY"].encode(), str(user.id).encode(), hashlib.sha256 ).hexdigest() # Ruby require "openssl" user_hash = OpenSSL::HMAC.hexdigest("SHA256", ENV.fetch("JUSTONECX_SECRET_KEY"), user.id.to_s) $userHash = hash_hmac('sha256', (string) $user->id, getenv('JUSTONECX_SECRET_KEY')); import ( "crypto/hmac" "crypto/sha256" "encoding/hex" "os" ) func justonecxHash(userID string) string { mac := hmac. New(sha256. New, []byte(os.
This is a source-linked briefing. Read the original report from Dev Community .