Skip to content

feat(auth): bind document identity and issue direct owner grants - #262

Open
marcus-pousette wants to merge 10 commits into
mainfrom
auth/document-identity-direct-grants
Open

marcus-pousette wants to merge 10 commits into
mainfrom
auth/document-identity-direct-grants

Conversation

@marcus-pousette

@marcus-pousette marcus-pousette commented Sep 21, 2026 •

Copy link
Copy Markdown
Collaborator

The auth umbrella (#38) aims to let a document be created locally, sync authenticated edits, and recover from a sealed authority backup plus retained history. This PR builds the document identity and direct owner grant used at the start of that flow. Recovery will reuse them: restore the same authority, create a fresh replica, and issue it a new grant for the same document.

Fixes #245. Implements direct grants from #255 and an in-memory key provider from #251.

Where this fits

flowchart TD
    subgraph current["This PR: document identity and direct grants"]
        A["Authority key"] -->|public key determines| D["Document ID"]
        A -->|signs| G["Direct owner grant<br/>Document + replica + expiry"]
        D -->|bound into| G
        R["Replica public key"] -->|authorized by| G
    end

    G -.-> P["Save keys and grant durably"]
    P -.-> S["Authenticate replica and sync signed edits"]
    S -.-> B["Recover from sealed authority backup<br/>and retained history"]
    B -.->|same authority, fresh replica, new grant| G
Loading

Dashed arrows show the remaining lifecycle work in #38. This PR can issue and verify grants in memory; it does not yet persist them, admit a sync connection, or export/restore a backup. The follow-ups are durable provisioning (#251, #249), authenticated sync (#244, the rest of #255, #243, #256, #89), and backup/recovery (#246, #249).

Contract

  • Document IDs use a versioned, domain-separated BLAKE3 digest of the authority public key.
  • Direct grants use canonical COSE/CWT, bind the document, authority, replica and expiry, and derive a 16-byte ID from the complete signed bytes. The format grants full-document ownership without a configurable role field. Verification checks the signature, expiry and expected document and replica, and rejects extra claims, unsigned headers and alternate encodings. Sync admission will also need replica proof of possession and revocation checks.
  • AuthorityKey and ReplicaKey are role-specific aliases over one opaque key-handle shape. The in-memory provider keeps non-extractable Web Crypto keys behind role-checked handles and exposes purpose-specific grant issuance. Deleting an authority also prevents an in-flight grant from being returned.

Delegation and revocation remain follow-ups too. The existing sync implementation stays buildable while #255 replaces the unreleased draft in slices. Keep the auth minor unreleased until that rewrite is complete.

@marcus-pousette
marcus-pousette marked this pull request as ready for review September 23, 2026 09:58
@marcus-pousette marcus-pousette mentioned this pull request Nov 3, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

auth: bind document IDs to document authority keys

1 participant