Les clés, jetons et noms sont des valeurs de test fictives (la clé est la clé d'essai publiée par la RFC 8032), jamais des vraies.
Une requête signée, octet par octet
Un appareil apparié avec une clé signe chaque requête qui porte son jeton. Le serveur reconstruit la base de signature à partir de la requête, et vérifie la signature avec la clé qu'il a liée au jeton.
La requête telle qu'envoyée
GET /api/lantern/v1/apps?page_size=50 HTTP/1.1
Host: shelf.example.org
Authorization: Bearer et_c8V1nQ0xYbExampleVectorToken0000000000
Signature-Input: lantern=("@method" "@target-uri" "authorization");created=1793345400;nonce="tQ0Vb3Yt7sXx2c1mZ8kq4A";keyid="If4x36FUomFia_hUBG_SJxt77UtqvkWqWId-9H-XIbk";alg="ed25519"
Signature: lantern=:M8AuwRfGqDSUYUefbsIOlmFKxvi+6HnHv0pvbD22n/lrJqHvPcvYThUUCqK+6C63s9nTQPThdrTfM9yFwt6aBA==:
La base de signature que l'appareil signe
"@method": GET
"@target-uri": https://shelf.example.org/api/lantern/v1/apps?page_size=50
"authorization": Bearer et_c8V1nQ0xYbExampleVectorToken0000000000
"@signature-params": ("@method" "@target-uri" "authorization");created=1793345400;nonce="tQ0Vb3Yt7sXx2c1mZ8kq4A";keyid="If4x36FUomFia_hUBG_SJxt77UtqvkWqWId-9H-XIbk";alg="ed25519"
La clé de l'appareil
private key (seed): 9d61b19deffd5a60ba844af492ec2cc44449c5697b326919703bac031cae7f60
public key: 11qYAYKxCrfVS/7TyWQHOg7hcvPapiMlrwIaaPcHURo=
keyid: If4x36FUomFia_hUBG_SJxt77UtqvkWqWId-9H-XIbk
short fingerprint: 21FE 31DF A154 A261
La même requête sans sa signature
Authorization: Bearer et_c8V1nQ0xYbExampleVectorToken0000000000
→ 401 · signature_required
Un appairage, du code au jeton
L'appareil demande un code et l'affiche ; son propriétaire approuve sur un autre appareil, connecté au serveur ; l'appareil interroge jusqu'à recevoir le jeton, une seule fois.
1. L'appareil demande à s'apparier
POST /api/lantern/v1/pairing HTTP/1.1 Host: shelf.example.org Content-Type: application/json { "schema": 1, "device": "Lea's Switch", "scopes": [ "library", "saves" ], "key": { "alg": "ed25519", "public_key": "11qYAYKxCrfVS/7TyWQHOg7hcvPapiMlrwIaaPcHURo=" } }2. Le serveur répond par un code
HTTP/1.1 200 OK Content-Type: application/json { "schema": 1, "code": "KQ4M-7TXD", "verify": "https://shelf.example.org/pair", "verify_complete": "https://shelf.example.org/pair?code=KQ4M-7TXD", "poll": "/api/lantern/v1/pairing/p_4Fh2", "interval": 5, "expires": 600 }3. Le propriétaire approuve ; l'appareil interroge
GET /api/lantern/v1/pairing/p_4Fh2 HTTP/1.1 Host: shelf.example.org Signature-Input: lantern=("@method" "@target-uri");created=…;nonce="…";keyid="…";alg="ed25519" Signature: lantern=:…:4. Le jeton, une seule fois
HTTP/1.1 200 OK Content-Type: application/json { "schema": 1, "token": "et_c8V1nQ0xYb", "scopes": [ "library", "saves" ], "bound": true, "rating_cap": { "system": "PEGI", "rating": "12" } }
Une autorisation, pour un pair
Le serveur signe une courte déclaration disant qu'un client peut lire un fichier ; un pair qui détient le fichier la vérifie avec la clé publique du serveur, sans interroger personne.
Ce que signe le serveur (JSON, clés dans cet ordre, sans espace)
{"exp":1793346000,"purpose":"lantern-grant-1","sha256":"3a7bd3e2b4c1f0a9e8d7c6b5a4938271605f4e3d2c1b0a9f8e7d6c5b4a392817","size":734003200,"uid":"6f1c2a8e-4b7d-4e2a-9c31-8d5e2f0a7b14"}
L'autorisation : la charge et sa signature, chacune en base64url
eyJleHAiOjE3OTMzNDYwMDAsInB1cnBvc2UiOiJsYW50ZXJuLWdyYW50LTEiLCJzaGEyNTYiOiIzYTdiZDNlMmI0YzFmMGE5ZThkN2M2YjVhNDkzODI3MTYwNWY0ZTNkMmMxYjBhOWY4ZTdkNmM1YjRhMzkyODE3Iiwic2l6ZSI6NzM0MDAzMjAwLCJ1aWQiOiI2ZjFjMmE4ZS00YjdkLTRlMmEtOWMzMS04ZDVlMmYwYTdiMTQifQ.-4SQt-G8QN_sjMzKfaBGDl7b7Z-tW2qHaeC8bSwe70tHH4lVsyhxnMVMrb3r4y3RVBzbhOTeWdP4d6jFjex5Bg
public key (peers.key): FkDVKwFG57y5KAWiHAahZeQ1pO2FxI5AehF/nZjLXq8=