Problem/Motivation
In this issue #2676584: Add way to view unpublished or protected source content we decided to move this feature from tmgmt_thebigword to tmgmt_content
We should provide a view protected with a key like we do for the previews, for the unpublished content and also for that content that is protected by permissions.
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | interdiff-add_way_to_view-2679361-7-11.txt | 4.47 KB | edurenye |
| #11 | add_way_to_view-2679361-11.patch | 10.39 KB | edurenye |
| #7 | interdiff-add_way_to_view-2679361-2-7.txt | 12.26 KB | edurenye |
| #7 | add_way_to_view-2679361-7.patch | 9.76 KB | edurenye |
| #2 | add_way_to_view-2679361-2.patch | 9.5 KB | edurenye |
Comments
Comment #2
edurenye commentedFirst approach, I'm not sure if this should be the default option, but I don't think so.
Comment #3
miro_dietikerHm, if we pass this URL to a TSP, the client that will access this URL will not be the getClientIP, because initially this is the service interacting and later just the user browser. Does this still work?
We might want to have some client with different IP in test? (Simpletest might be a bit limited here.) Or some other thing accessing that still gets a 403 if still possible.
You are just testing the API. Yeah the default preview link seems to be fine without this access.
Important followup: Offer an item preview link in local translator!
Comment #4
edurenye commentedHaving this line or not, does not change anything, I tried removing it and the tests still pass.
Created the followup #2680119: Let translators view unpublished or protected source content
Comment #5
miro_dietikerNeeds consideration or even discussion with Berdir.
Comment #6
berdirNot sure where you have this snippet from, UserSession doesn't have a hostname (anymore). And all other values are the default anyway.
Also, there's an AnonymousUserSession object, which doesn't actually do anything special. But you can should still use it. $anonymous = new AnonymousUserSession();
I'm not sure we need $anonymous_access. I'd just implement it so that we always return the key. It doesn't hurt anyone if it's there as well for logged in users....
Uh. Except when it isn't. I'm wondering if it's a feature or a (security) bug when reviewers can see unpublished content. It's not just this, they can see the data anyway.
Don't create a new url object, just use setOption('query', ...).
Also note that this will conflict with #2668378: Fatal error with a content entity source without canonical link template
drupalGet() accepts url objects, just give it what getSourceUrl() returns.
cacheability is tricky here.
If the node is publicly cached and *then* we access it, this might not work because everyhting is cached.
On the other hand, disabling caching completely just because we have a key also isn't an option.
Instead, what you should do is *always* (even if you don't have a key right now) add a cache context for url.query_args:key. Then it will be cached differently based on the value of the key argument. As long as it doesn't exist, that doesn't hurt anyone.
Comment #7
edurenye commentedDone, as discussed for the point 2 I added a setting to control it.
Comment #9
berdirthe description needs a bit work.
It's not just about anonymous users, everyone will then have access:
Enabling this will give translators and anyone with access to jobs access to view all content, including unpublished and other protected content.
Comment #10
berdirAlso, there's one more access/caching thing that we should check for.
After you check access successfully, abort the job (we could also accept to close it, but that would update/save the node and invalidate caches anyway). Then check the same URL again. It should now fail, since the job item is no longer active.
That will probably not work yet. To fix it, add the job item as a cacheable dependency (->addCacheableDependency($job_item).
Oh, and you should also check config *if* there is a key query argument and call that method for $config too. Not sure if we really need a test for that, but it wouldn't hurt (check that access works, then disable the setting, then it shouldn't, then enable again, then it should again, then abort the job and it shouldn't anymore).
Comment #11
edurenye commentedDone.
Comment #13
berdirLooks good now, thanks, committed.