How is the policy feature meant to be used? #278
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
orinoco/dump-things-service#278
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I am trying to wrap my head around how the new user/policy mapping feature can be used. The targeted purpose is clear to me. I am describing it here nevertheless to establish a shared understanding.
Previously, users were forced to create an additional collection whenever a single record (or record part) required a different target audience constraint. This exploded workflow complexity for users and curators. Now a single collection will be enough for most use cases. The primary reason for another collection is the need for a different schema.
The handling of write access is handled very differently. Any user with write access to a collection can write any information to the collection, but only (ever) to their personal inbox. Write access only enables the submission of "candidate updates". The inclusion into a collection is subject to a curator's decision to access and/or rewrite it.
The label policy could be misunderstood for something like an ODLR policy. But this is not the case. It is a literal tag. While this tag can in fact be an ODLR policy identifier, the service makes not attempt to interpret it in any way. The literal string
SECRETis a suitable "policy". It has per se no meaning. Its meaning comes from the service using it as a literal tag that is matched against a set of "approved" tags for user requesting a record (for read).The service needs to look up whether a particular requesting user is approved for a particular policy that a specific record may be tagged with. This mapping is independent and outside the record itself.
The term "token" is used in the documentation in many ways. However, a "token" always refers to a user identity. This identity may not be specific to a particular user (e.g., a collection can declare a "default token", which refers to a pre-crafted identity with arbitrary permissions that is assigned to unauthenticated requests), or may not be a 1:1 mapping (e.g., any number of forgejo access tokens can refer to a single forgejo user, and all uniformly evaluate to a single forgejo-defined permission setup for that user).
Now for my question/concerns/thoughts/.... going through scenarios that the documentation is presently not explicit about.
This is a useful feature. Even though it is presently optional for a collection, it should be considered standard/enabled in the long-run for any collection -- because the first access-level differentiation will trigger it. Therefore I am considering policy-enforcement to be enabled for any collection for all of the following.
Mechanics of an "opt-out read" collection
Such a collection is, for example, a collection that has a "default token" with
READ_CURATEDpermissions. If it has a record that may not be read by a non-authenticated user (or only be a specific authenticated user), that record need to get a policy tag.policy_annotation_taghas to be set (to a single value).default_policymust not be set to keep the "default token" permissions effective.User/policy mapping management is only needed for the "opt-out" records.
Mechanics of an "opt-in read" collection
Such a collection is, for example, a collection that has a "default token" with
NOTHINGpermissions. Any record can only be read by an authenticated user. Records can now use policy tags to establish additional conditions for authenticated users to match, before they gain access.policy_annotation_taghas to be set (to a single value).default_policycan be set to cover a "most users" scenario.default policyor explicitlyUser/policy mapping management is required for every user.
User/policy mapping management mechanics
It is unclear to me, where this is supposed to be located in dumpthing's role concepts. As expressed in #275, the effectively placed into the hands of an individual collections curator. This is different from the overall permission setup of a collection, which can only be done by an administrator. This feels fuzzy to me.
Access policies are the feature to reflect legal constraints. Whether or not a particular person has signed a specific DUA, or is part of a specific group/organization will often be information globally associated with a requester, and not specific to a particular collection.
Dumpthings places the user/policy mapping into the scope of an individual collection. And it places the responsibility for its maintenance (and congruence with record tags) into the hands of a collection curator.
This makes sense, because a curator has ultimate reign over a record, and they can effectively determine the conditions with which information becomes available.
However, a collection curator deals with metadata records, and with (abstract) conditions that determine access, but they do not generally know who fulfills these conditions, when, and for how long.
Moreover, dumpthings wants a mapping from user identity to approved policy tags. This makes sense, because that is ultimately the mapping that is required to decide whether or not to show a particular record.
However, this is unlikely to be the way this information is (or becomes) available. I suspect that real-life applications will have a mix of structural sources (e.g., membership in a particular organization/unit), and case-by-case properties (e.g., signed a particular DUA). These will be provided by different sources and update at different frequencies.
It feels clunky and fragile to require this information to be merged into a single mapping with an external mechanism and on top of that to require a curator to choose an appropriate timing to apply it (routinely).
Musings
I am writing this before having had any feedback on the above, so I might be missing the mark by quite a margin...
However, I do wonder whether it is necessary or even useful to invent more mechanisms like
policy_mappingand policy mapping reloading endpoints with special permissions....This appears to be really just a metadata query problem like any other that dumpthings is built to serve. Why not have a simple schema for a "built in" collection where records represent "policies" and their properties carry all essential information, including a mapping to "approved users".
If that is the underlying mechanism, we would have all standard features available to attach existing workflows and agents to this process. Certain people can have certain permissions for this collection. Curators can apply appropriate levels of scrutiny to incoming information from individual sources, and automatically (machine-)accept others.
This would change the nature of the mapping from user->policy to policy->user -- but it would arguable reflect the "source" nature of the problem space more adequately. Internally, an implementation can reverse the mapping whenever it makes sense.
Thanks @mih for the writeup.
Generally, most of the described concepts and functionality exists exactly as described in the in the issue.
This is supported
Yes, write access is not affected by policies
Yes (since 6.5.1)
Yes
Opt-out and opt-in
If I understand the description of opt-out and opt-in correctly, they can be implemented via the default_policy-property.
Opt-out
Opt-out functionality:
Opt-in
Opt-in functionality:
Implementation
Because the token check precedes the policy check, both scenarios require a token-based READ_CURATED permission.
The difference between opt-out and opt-in is determined by the default policy.
Opt-out:
Opt-in:
In both cases: user/policy mapping management is required for every user that should read one of the specific records. In the opt-out case, "specific record" refers to a record that should not be readable by all users. In the opt-in case, "specific record" refers to a record that should only be readable by specific users.
I think you are right, it is a little fuzzy. My reasoning for putting the management of the visibility of records in the curator role was (I also commented on #275):
token-container in the config file, which does not neatly fit into the container-view).[...]
I see your point. I am not sure yet how to address it. I think there are a number of possible strategries, which come with their own tradeoffs. But I definitely have to look a little more into the aspects of policy-creation, policy-determination, and policy-management. One thing to keep in mind is: user IDs are collection-specific, due to collection-specific authentication sources and token-assignments.
It crossed my mind to use such an implementation, but did not pursue it further yet. Thinking of it, enabling standard tools would require a mechanism to identify the "policy collection" that should be connected to a collection. It might be a one-to-one mapping where every collection has a policy collection with a canonical name. It might also be a many-to-one mapping where multiple collections refer to a shared policy collection. Although in the latter case there might be problems with information leakage, e.g., about user IDs and policies that apply to user IDs.
I see your point that a policy->user mapping might be more natural. It certainly fits the opt-in and opt-out use case better where records and policies are the elements that are primarily considered.
One observation: in order to support the curation-workflow in its current state a curator has to have full access to all records, i.e., his access should not be governed by policies.