feat(licence): verify activation JWT ES256 signature before trusting payload#30
Draft
revelri wants to merge 2 commits into
Draft
feat(licence): verify activation JWT ES256 signature before trusting payload#30revelri wants to merge 2 commits into
revelri wants to merge 2 commits into
Conversation
…payload Add `licence::verify::verify_es256` (p256 + JOSE r||s decoding) and wire it into `routes::licence::persist_and_reply` so every backend token is checked before being written to the cache. The production P-256 public key is held in the `ACTIVATION_VERIFYING_KEY_B64` constant in `src/licence/verify.rs` (currently "PLACEHOLDER") and can be overridden at runtime via `STRIVO_LICENCE_PUBKEY`. When the key is absent or equals "PLACEHOLDER", verification is skipped with a WARN log so dev and local-trial flows remain functional. Unit tests generate a fresh ephemeral P-256 keypair, sign a real JWT, and assert accept on a valid token, reject on a tampered payload, and reject on a signature from a different key. New deps: p256 0.13 (ecdsa feature), base64 0.22 (already workspace-present in strivo-web; now also a direct dep of strivo-core).
revelri
force-pushed
the
revoy/str-licence-es256-verify
branch
from
July 4, 2026 05:22
d7b763a to
85fe12e
Compare
Collaborator
Author
|
The ES256 verification itself is sound (real p256/ECDSA verification, correct JOSE r||s handling, SPKI DER key parsing). Holding merge on two blockers:
Follow-on (not blocking this PR): the verified claim's |
Split key resolution out of the crypto: verify_es256_with_key(token, key_b64) holds the verification body and takes the verifying key as a parameter; verify_es256 stays a thin wrapper that resolves STRIVO_LICENCE_PUBKEY env -> ACTIVATION_VERIFYING_KEY_B64 const (unchanged precedence/skip/warn semantics). Tests now pass the key directly instead of mutating the process-global STRIVO_LICENCE_PUBKEY env var, making them parallel-safe by construction under cargo's default multi-threaded runner. Drops the with_key helper and every set_var/remove_var, and corrects the wrong 'sequential by default' comment. Also applies rustfmt to the file.
Collaborator
Author
|
Addresses the two REVISION blockers on this PR (loop pass, independently verified):
Verification: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds client-side ES256 JWT signature verification to the licence activation path.
src/licence/verify.rs:verify_es256(p256 ECDSA + JOSE r||s signature decoding), embedded P-256 verifying-key constant (ACTIVATION_VERIFYING_KEY_B64, currentlyPLACEHOLDER), runtime override viaSTRIVO_LICENCE_PUBKEY. When the key is absent/PLACEHOLDER, verification is skipped with a WARN so dev/local-trial flows still work.routes::licenceso every backend token is checked before being written to the cache.p256 0.13(ecdsa),base64 0.22;Cargo.lockregenerated accordingly.Addresses the ROADMAP HIGH item: "Verify Licence JWT ES256 signature (TODO(licence-verify)) before any Creator Edition commercial launch."
Verification
cargo test -p strivo-core --lib licence-> 12 tests pass, 0 failed, includingaccepts_valid_token,rejects_tampered_payload,rejects_signature_from_different_key,placeholder_key_skips_verification_and_returns_claims(tests generate an ephemeral P-256 keypair and sign a real JWT).cargo build -p strivo-web-> clean (licence route wiring compiles).origin/main(resolved asha2version + new-dep manifest conflict, keeping origin'ssha2 = 0.11.0); diff is 7 intended files;Cargo.lockcarries the new p256/base64 entries.Draft: review surface for the auditor; CI gates the merge.