Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow draft asset access to be restricted to specific users #471

Merged

Conversation

@chrisroos
Copy link
Contributor

chrisroos commented Feb 12, 2018

Certain documents in Whitehall can be marked as access limited; which means that they're only accessible to users within the same organisation(s) that the document belongs to. Any attachments belonging to those documents should be subject to the same restrictions. This branch adds functionality to allow access to draft assets to be restricted to a subset of users. Setting the access_limited attribute to an array of users' UIDs will allow only those users to access the asset when its in draft.

This implementation is based on a cut-down version of the equivalent functionality in the Content Store; notably I'm not storing the auth_bypass_ids that it's possible to set on a ContentItem in the Content Store.

Note the additional duplication in the two media controllers. I imagine we'll DRY this up in future.

Note that I'm not emitting the access_limited data from the AssetPresenter. It doesn't feel quite right to emit this sensitive information.

@chrisroos chrisroos force-pushed the allow-draft-asset-access-to-be-restricted-to-specific-users branch from 24feb0e to 70422af Feb 13, 2018
@chrisroos chrisroos force-pushed the allow-draft-asset-access-to-be-restricted-to-specific-users branch 3 times, most recently from b9f12c0 to f33901b Feb 16, 2018
@chrisroos chrisroos changed the title WIP: Allow draft asset access to be restricted to specific users Allow draft asset access to be restricted to specific users Feb 20, 2018
@chrisroos chrisroos requested review from floehopper and chrislo Feb 20, 2018
@floehopper floehopper self-assigned this Feb 20, 2018
Copy link
Contributor

floehopper left a comment

This all looks good to me, but I think it would be good to explain a couple of things somewhere:

  1. Why we don't need to implement auth_bypass_ids. If this is to do with JWT, then I think the only app which uses JWT is Publisher. That app uses Asset Manager to create attachment assets and doesn't attempt to do any access-limiting of those attachment assets. Furthermore none of the mainstream publishing apps currently do this for attachments on draft documents.

  2. Explain why we use [] to mean that the asset is not access-limited. This feels counter-intuitive to me. Presumably the answer is that we're replicating how the Content Store works.

I'm happy for you to decide how to address these comments. Marking as approved. 👍

chrisroos added 3 commits Feb 12, 2018
We want to be able to restrict access to draft assets to a subset of
users. This is only a requirement for Whitehall assets in the short term
but I think that enabling it for all assets will make Asset Manager
easier to understand.

I'm basing this access limitation in Asset Manager on a cut-down version
of the equivalent functionality in the Content Store; notably I'm not
storing the `auth_bypass_ids` that it's possible to set on a
`ContentItem` in the Content Store. Whitehall doesn't appear to set any
`auth_bypass_ids` when publishing to the Content Store (in fact, it
might only be Publisher that does set them) so I don't think we need to
either.

The `access_limited` attribute should either by an empty array (meaning
that the asset is accessible to everyone) or an array of user UIDs
(meaning that the asset is only accessible to users whose UID appear in
the list). This mirrors the behaviour in the Content Store.
To encapsulate the logic from the MediaController.
This is essentially identical to the same functionality for mainstream
assets.
@chrisroos chrisroos force-pushed the allow-draft-asset-access-to-be-restricted-to-specific-users branch from f33901b to 6c77778 Feb 21, 2018
@chrisroos chrisroos force-pushed the allow-draft-asset-access-to-be-restricted-to-specific-users branch from 6c77778 to c28c933 Feb 21, 2018
@chrisroos

This comment has been minimized.

Copy link
Contributor Author

chrisroos commented Feb 21, 2018

Thanks for reviewing, @floehopper.

I've updated the commit note of the first commit to address your feedback about explaining the missing auth_bypass_ids and the use of an empty array to denote an asset being accessible to everyone.

@chrisroos chrisroos merged commit a1fad20 into master Feb 21, 2018
2 checks passed
2 checks passed
continuous-integration/jenkins/branch This commit looks good
Details
continuous-integration/jenkins/publishing-e2e-tests Publishing end-to-end tests succeeded on Jenkins
Details
@chrisroos chrisroos deleted the allow-draft-asset-access-to-be-restricted-to-specific-users branch Feb 21, 2018
floehopper added a commit that referenced this pull request Feb 22, 2018
In #481, although I added redirect_url to the base class Asset, I only
implemented the media controller behaviour for Whitehall assets. Having
seen that @chrisroos added access_limited behaviour to Asset Manager for
*all* asset types in #471, I've decided that it's confusing for the
redirect_url behaviour to only work for Whitehall assets.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.