Signed cursor

A signed cursor is a pagination cursor containing a version, an encoded position payload, and an HMAC authentication tag. The server verifies the tag before accepting the position, allowing it to reject cursors that clients have modified or forged. Signing prevents forgery but does not prevent replay of an older valid cursor.

Minimal example

go
payload := base64.RawURLEncoding.EncodeToString(data)
message := "v1." + payload
mac := hmac.New(sha256.New, secret)
mac.Write([]byte(message))
token := message + "." + base64.RawURLEncoding.EncodeToString(mac.Sum(nil))

Learn this concept

Lesson 2.21 · HMAC signing for cursors

Used in exercises

Exercise 2.22 · GET /v1/restaurants: signed cursors
Prerequisite conceptsKeyset paginationOpaque cursor