Skip to content

Resolve instance tokens in LicenceGate through Instance::findByToken - #7

Merged
roncodes merged 3 commits into
release/v2.0.0from
feat/phase1-reconcile
Oct 24, 2026
Merged

roncodes merged 3 commits into
release/v2.0.0from
feat/phase1-reconcile

Conversation

@roncodes

Copy link
Copy Markdown
Member

Follow-up to the Phase 1 merge (9aa8443), so the package licence gate and the instance API share one instance-token check.

What changes

  • LicenceGate resolves flbi_ tokens through Instance::findByToken() instead of hashing and querying instances itself. Token hashing and the status = revoked check now live only on the Instance model.
  • Decision recorded in the README and the LicenceGate docblock: package downloads (/npm, /composer) check only that the caller's organization holds an active licence, not that the calling instance holds a seat.
    • Seats are claimed when an instance reports installing/installed to POST /v1/instances/me/installs, which returns 403 when no seat is free.
    • A personal install token from the same organization can already download the package, so a seat check at download time would block nothing. It would also break downloads from CI and developer machines, which have no instance.

Tests

New LicenceGateTest cases: a licensed instance with no activation can download (200), a revoked instance gets 401, an instance whose organization has no licence gets 403, and an unknown flbi_ token gets 401.

composer test: 234 passed. vendor/bin/pint --test: passed.

Notes

  • This was cherry-picked onto the current v2 (after the releases pipeline and the Semver/Compat consolidation). The only conflict was the routes/api.php import block, which v2 had already sorted, so v2's side was kept.
  • Migrations: the 2026_10_22_000001/000002 prefixes each appear twice (instance API and package endpoints). They change different tables and Laravel runs them in full-filename order; migrate:fresh --seed and rollback/re-migrate were checked on SQLite and MySQL 8. The files are not renamed because that would break dev databases that have already run them.

LicenceGate hashed and looked up flbi_ tokens itself; it now calls
Instance::findByToken() so hashing and the revoked status check live on
the model. Package downloads keep checking the organization's licence
only, not a seat on the calling instance; seats are claimed when the
instance reports the install. README records the decision and the
tests pin it (no activation needed, unlicensed instance gets 403).
@roncodes
roncodes changed the base branch from v2 to release/v2.0.0 October 23, 2026 05:30
@roncodes
roncodes merged commit bb09888 into release/v2.0.0 Oct 24, 2026
4 checks passed
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.

1 participant