Conversation
The record key pattern now rule permissions for read, while write permissions still based on topic pattern.
Contributor
Author
|
Hi @lxsaah, plz check the PR. The large part of added code is test to cover different behaviors stem from decoupled record and topic. Btw I missed your collab invite, could you send again? |
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
Issue 215 pointed out the tangled up nature of record keys and topics. This PR decouples these two namespaces by adding distinct logics (paths are relative to
aimdb-websocket-connectioncrate by default). The core idea is to keep this logic clear: clients keep speaking topic, server speaks record key, and the two namespaces joined at outbound route:/src/server/auth::Permissionsnow hasread_patternsrenamed fromsubscribe_pattern. This indicates a change of authorization logic from topic to record key. Meanwhile,write_patternsremains with topic. This is followed by a change offn can_subscribe()tofn can_read(), which is naming change not logic change;/src/server/auth::RecordsBitsadded to encode per-client read permissions. Each bit decice whether the client having read access to a record. Bit indexes are the same as record indexes which are registration order (inAimDbInner.storage.RecordsBitsis built during ws upgrade process, and carried byClientInfo;/src/server/auth: several AuthHandler fn become obsolete due to this logic change and being removed, includingfn authorize_subscribe()(authorization is resolved at upgrade and enforced at delivery),fn authorize_query()(the filtering logic is now based on record permissions), andfn authorize_list();src/server/http: thefn ws_upgrade_handler()now build the per-client permission bitmask based on the server's registered records and configuredPermissions. The handler does not deny the upgrade even if the client has no grant (permission bitmask is empty or all bits are zero)./src/server/connector::SnapshotCacheis updated to carry record id logic. A snapshot is now identified by record id and associated topic, instead of just topic.trait SnapshotProvideroutput also changes accordingly;aimdb-core/src/builder::AimDb.collect_outbound_routes()now buildOutboundRoutewith extra key-value pair of "record_index"-"{record_id}" in.config: ConnectorConfigattr.ConnectorConfigcarries that pair till/src/server/connector::WsBusSink.publish()where the snapshot cache is built and message is broadcasted. It is theClientManagerdeciding which subscriptions/clients get the message;WsSession.subscribe(),/src/server/dispatch.rs;record.listreturns only records that the client has permissions for;record.querycould return a set of records smaller than what the name pattern asks for. If the asked name and grant bits do not overlap, the query is denied;Also, several tests added to ensure these behaviors hold.
Related Issue
Checklist
make check).