Access systems
A building’s access system (an office, gym or school door system) can use allme as the identity only. The person’s phone proves its share code at the door reader, and your system checks that proof on its own side — with no allme API call per tap — and decides access with its own rules.
What the phone presents
The person’s own Share Code card shows a signed link:
https://{share host}/connect/{CODE}?t={t}&s={signature}
{share host}isallme.fyion live andstaging.allme.fyion staging;{CODE}is the person’s share code;{t}is the signing time in unix seconds;{signature}is the signature, base64url without padding.- The card is re-signed every 30 seconds while it is shown, and only while the person’s keys are unlocked on the phone. Without keys the card shows the bare code, which proves nothing.
- QR code: every phone can show the card as a QR code your reader scans.
- NFC: an Android phone can also present the same signed link over NFC (Tap to share); that link is signed once when the person arms it and is good for the arm’s 60 seconds. An iPhone presents the QR code only.
Verify it locally
The signed message is the UTF-8 text allme-age-check:v1:{CODE}:{t}, signed with the person’s own private key using RSA-PSS with SHA-256, MGF1-SHA-256 and a 32-byte salt. To verify it you need the person’s public key, which allme gives you once.
- Fetch the person’s public key once with
GET /api/keys/{shareCode}and keep it. It answers{"public_key": "…"}, the key as base64 SPKI. The call is made on your service’s data client, to theapi_urlits token response returned (Regions); its endpoint whitelist holds/api/keys/*. A person’s keypair is never replaced, so the key you fetched stays valid for the life of the account and later taps need no allme call. - Accept only the canonical spelling of the signature. Decode the base64url text, encode the bytes again without padding, and reject the signature unless the result equals the text exactly. Several spellings decode to the same bytes; one of them is accepted.
- Verify the RSA-PSS signature over
allme-age-check:v1:{CODE}:{t}with the stored key. - Accept a
twithin 60 seconds of the reader’s clock, in either direction. - Accept each signature once. Remember every accepted signature for 120 seconds from the moment you accepted it, in your own store, and refuse a repeat. A signature timestamped up to 60 seconds ahead of your clock stays acceptable for up to 120 seconds, so a shorter memory would let it in a second time. A signature proves possession of the private key at
t; only your memory stops a photographed code from being replayed within the window.
These are the same rules allme applies when it checks the same signature itself.
A worked example per language
Each example uses the language’s standard RSA-PSS verify; none needs an SDK. seen is your replay memory, kept for 120 seconds per entry. A signature is added to it only after it verifies.
import base64, time
from cryptography.exceptions import InvalidSignature
from cryptography.hazmat.primitives import hashes, serialization
from cryptography.hazmat.primitives.asymmetric import padding
def verify_share_code(public_key_b64, code, t, sig, seen):
raw = base64.urlsafe_b64decode(sig + "=" * (-len(sig) % 4))
if base64.urlsafe_b64encode(raw).rstrip(b"=").decode() != sig:
return False # not the canonical spelling
if abs(time.time() - t) > 60 or sig in seen:
return False
key = serialization.load_der_public_key(base64.b64decode(public_key_b64))
try:
key.verify(raw, f"allme-age-check:v1:{code}:{t}".encode(),
padding.PSS(mgf=padding.MGF1(hashes.SHA256()), salt_length=32),
hashes.SHA256())
except InvalidSignature:
return False
seen.add(sig)
return Trueimport { constants, createPublicKey, verify } from "node:crypto";
export function verifyShareCode(
publicKeyB64: string, code: string, t: number, sig: string, seen: Set<string>,
): boolean {
const raw = Buffer.from(sig, "base64url");
if (raw.toString("base64url") !== sig) return false; // not the canonical spelling
if (Math.abs(Date.now() / 1000 - t) > 60 || seen.has(sig)) return false;
const key = createPublicKey({ key: Buffer.from(publicKeyB64, "base64"), format: "der", type: "spki" });
const ok = verify(
"sha256",
Buffer.from(`allme-age-check:v1:${code}:${t}`),
{ key, padding: constants.RSA_PKCS1_PSS_PADDING, saltLength: 32 },
raw,
);
if (ok) seen.add(sig);
return ok;
}import (
"crypto"
"crypto/rsa"
"crypto/sha256"
"crypto/x509"
"encoding/base64"
"fmt"
"time"
)
func VerifyShareCode(publicKeyB64, code string, t int64, sig string, seen map[string]bool) bool {
raw, err := base64.RawURLEncoding.DecodeString(sig)
if err != nil || base64.RawURLEncoding.EncodeToString(raw) != sig {
return false // not the canonical spelling
}
if d := time.Now().Unix() - t; d > 60 || d < -60 || seen[sig] {
return false
}
der, err := base64.StdEncoding.DecodeString(publicKeyB64)
if err != nil {
return false
}
parsed, err := x509.ParsePKIXPublicKey(der)
key, ok := parsed.(*rsa.PublicKey)
if err != nil || !ok {
return false
}
digest := sha256.Sum256([]byte(fmt.Sprintf("allme-age-check:v1:%s:%d", code, t)))
if rsa.VerifyPSS(key, crypto.SHA256, digest[:], raw, &rsa.PSSOptions{SaltLength: 32}) != nil {
return false
}
seen[sig] = true
return true
}using System.Security.Cryptography;
using System.Text;
static bool VerifyShareCode(string publicKeyB64, string code, long t, string sig, HashSet<string> seen)
{
var padded = sig.Replace('-', '+').Replace('_', '/');
padded += new string('=', (4 - padded.Length % 4) % 4);
byte[] raw;
try { raw = Convert.FromBase64String(padded); } catch (FormatException) { return false; }
var canonical = Convert.ToBase64String(raw).TrimEnd('=').Replace('+', '-').Replace('/', '_');
if (canonical != sig) return false; // not the canonical spelling
if (Math.Abs(DateTimeOffset.UtcNow.ToUnixTimeSeconds() - t) > 60 || seen.Contains(sig)) return false;
using var rsa = RSA.Create();
rsa.ImportSubjectPublicKeyInfo(Convert.FromBase64String(publicKeyB64), out _);
// RSASignaturePadding.Pss uses a salt as long as the hash: 32 bytes for SHA-256.
var ok = rsa.VerifyData(Encoding.UTF8.GetBytes($"allme-age-check:v1:{code}:{t}"), raw,
HashAlgorithmName.SHA256, RSASignaturePadding.Pss);
if (ok) seen.Add(sig);
return ok;
}import java.nio.charset.StandardCharsets;
import java.security.*;
import java.security.spec.*;
import java.util.Base64;
import java.util.Set;
static boolean verifyShareCode(String publicKeyB64, String code, long t, String sig, Set<String> seen)
throws GeneralSecurityException {
byte[] raw;
try { raw = Base64.getUrlDecoder().decode(sig); } catch (IllegalArgumentException e) { return false; }
if (!Base64.getUrlEncoder().withoutPadding().encodeToString(raw).equals(sig)) return false; // not canonical
if (Math.abs(System.currentTimeMillis() / 1000 - t) > 60 || seen.contains(sig)) return false;
PublicKey key = KeyFactory.getInstance("RSA")
.generatePublic(new X509EncodedKeySpec(Base64.getDecoder().decode(publicKeyB64)));
Signature s = Signature.getInstance("RSASSA-PSS");
s.setParameter(new PSSParameterSpec("SHA-256", "MGF1", MGF1ParameterSpec.SHA256, 32, 1));
s.initVerify(key);
s.update(("allme-age-check:v1:" + code + ":" + t).getBytes(StandardCharsets.UTF_8));
if (!s.verify(raw)) return false;
seen.add(sig);
return true;
}// composer require phpseclib/phpseclib:^3 (PHP's openssl extension has no RSA-PSS verify)
use phpseclib3\Crypt\PublicKeyLoader;
use phpseclib3\Crypt\RSA;
function verifyShareCode(string $publicKeyB64, string $code, int $t, string $sig, array &$seen): bool
{
$raw = base64_decode(strtr($sig, '-_', '+/') . str_repeat('=', (4 - strlen($sig) % 4) % 4), true);
if ($raw === false || rtrim(strtr(base64_encode($raw), '+/', '-_'), '=') !== $sig) {
return false; // not the canonical spelling
}
if (abs(time() - $t) > 60 || isset($seen[$sig])) {
return false;
}
$pem = "-----BEGIN PUBLIC KEY-----\n" . chunk_split($publicKeyB64, 64, "\n") . "-----END PUBLIC KEY-----\n";
$key = PublicKeyLoader::loadPublicKey($pem)
->withPadding(RSA::SIGNATURE_PSS)->withHash('sha256')->withMGFHash('sha256')->withSaltLength(32);
if (!$key->verify("allme-age-check:v1:{$code}:{$t}", $raw)) {
return false;
}
$seen[$sig] = true;
return true;
}Keeping your own list of connected people
If your system keeps its own list of people who may be admitted, the list needs no allme call to be checked at the door — but it should hear when a person leaves. Your service’s webhook and pull change feed carry connection_deleted (no slot, no value; it names the person by person_user_id and share_code) in both of these cases:
- the person disconnects from your service, or your service ends the connection;
- the person deletes their allme account — every service the person was connected to receives one.
Treat it as the end of that person’s identity with you and remove them from your list. Verifying a signature locally says nothing about whether the account still exists: your own access rules, applied when connection_deleted arrives, are what end a person’s access.