Allow adjuncts to be access controlled - #1310
JackLewis-digirati wants to merge 2 commits into
Conversation
How this worksAdjuncts don't have their own roles — they inherit access control from their parent Asset. This PR wires that inheritance through to request handling. Data flow:
Request handling (
Also:
|
donaldgray
left a comment
There was a problem hiding this comment.
I think this ticket is incomplete - it's missing call to adjunct specific verifyAccess endpoint, which will require a change to iiif-auth-v2.
IIIF-Auth-V2 /verifyAccess/* can handle request for Adjuncts.
| MediaType = firstAdjunct.MediaType, | ||
| Type = firstAdjunct.Type | ||
| Type = firstAdjunct.Type, | ||
| // Adjuncts don't have their own roles, they inherit those of the parent Asset |
There was a problem hiding this comment.
I wonder if it'd be possible to add Roles directly to the Adjunct here. .ApplicableRoles property maybe?
My thinking that this current implementation ties more to the "Adjunct inherits roles from Asset" (this is MVP only, we will be revisiting). If we just had a Roles/ApplicableRoles property on Adjuncts we could set that however we need to close to the source - downstream callers then only need to worry about consuming that property and not that it comes from the parent. Then it'd be easy to update the query to make allow Adjunct to have it's own Roles (e.g. to make it COALESCE("Adjuncts"."Roles", "Images"."Roles") as "Roles" rather than "Images"."Roles").
If the boundary is the creation of the OrchestrationAdjunct then it might not be worth it at this point.
| // TBD - AUTH | ||
| if (orchestrationAdjunct.RequiresAuth) | ||
| { | ||
| if (!await assetRequestProcessor.IsAuthenticated(adjunctRequest.GetAssetId(), orchestrationAdjunct.Roles, |
There was a problem hiding this comment.
I think we want to pass the adjunct id here, rather than just the asset id. Following this call chain ends up making a GET to /verifyAccess/1/2/foo but we want to call /verifyAccess/1/2/foo/mets.xml. This could be something like .GetDeliverableId() to make it generic.
This is covered by the following from the ticket:
IIIF-Auth-V2 /verifyAccess/* can handle request for Adjuncts.
| /// <param name="assetId">AssetId the roles belong to</param> | ||
| /// <param name="roles">Roles associated with the asset/adjunct being requested</param> | ||
| /// <param name="httpRequest">Current <see cref="HttpRequest"/>, used to determine auth mechanism + for logging</param> | ||
| public async Task<bool> IsAuthenticated(AssetId assetId, IReadOnlyList<string> roles, HttpRequest httpRequest) |
There was a problem hiding this comment.
See comment in AdjunctRequestHandler - can this be DeliverableId
What does this change?
Resolves #1302
This PR allows adjuncts to be access controlled, based on the role of the parent asset