Repository navigation
Resolve instance tokens in LicenceGate through Instance::findByToken - #7
Merged
Merged
Conversation
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).
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.
Follow-up to the Phase 1 merge (
9aa8443), so the package licence gate and the instance API share one instance-token check.What changes
LicenceGateresolvesflbi_tokens throughInstance::findByToken()instead of hashing and queryinginstancesitself. Token hashing and thestatus = revokedcheck now live only on theInstancemodel.LicenceGatedocblock: package downloads (/npm,/composer) check only that the caller's organization holds an active licence, not that the calling instance holds a seat.installing/installedtoPOST /v1/instances/me/installs, which returns 403 when no seat is free.installtoken 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
LicenceGateTestcases: 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 unknownflbi_token gets 401.composer test: 234 passed.vendor/bin/pint --test: passed.Notes
v2(after the releases pipeline and the Semver/Compat consolidation). The only conflict was theroutes/api.phpimport block, whichv2had already sorted, sov2's side was kept.2026_10_22_000001/000002prefixes each appear twice (instance API and package endpoints). They change different tables and Laravel runs them in full-filename order;migrate:fresh --seedand 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.