Repository navigation
feat(tenancy): resolve devices within trusted scope - #28
Merged
Merged
Conversation
Add _id-, project-, organisation-, and legacy-owner-scoped device selection. Permit the same non-secret key outside the trusted scope while rejecting ambiguity within it, and deprecate key-only lookup for new ingress paths.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Resolve owner-only device user_id deterministically as organisationId = projectId = ownerUserId. Preserve stable sub-user-to-master resolution and never infer a secondary organisation from ownership.
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.
Description
This change introduces trusted, scope-aware device resolution for tenancy handling. Device keys are no longer treated as globally unique identifiers, which allows the same non-secret key to safely exist across different projects without creating ambiguous lookups.
The new
LoadScopedDeviceflow requires trusted server-side context such as organisation, project, or persisted device identity before resolving a device. This improves isolation between tenants, prevents cross-project collisions, and ensures duplicate keys are only rejected within the same trusted scope. Key-only lookups are now explicitly deprecated because they cannot safely distinguish devices in multi-project environments.The update also simplifies legacy ownership resolution. Legacy owner IDs now deterministically map to the owner’s default organisation instead of attempting to infer secondary organisations. This removes ambiguous ownership behavior, avoids unnecessary organisation queries, and aligns runtime resolution with the identities generated by bootstrap migrations.
Extensive test coverage was added to validate scoped lookups, duplicate handling, fallback behavior for legacy devices, and failure cases when trusted scope information is missing.