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

Display restricted to staff #11302

Merged
merged 26 commits into from
Oct 29, 2024
Merged

Display restricted to staff #11302

merged 26 commits into from
Oct 29, 2024

Conversation

gestchild
Copy link
Contributor

@gestchild gestchild commented Oct 21, 2024

What does this change?

Makes restricted items viewable on the item page for users with a role of 'StaffWithRestricted'. For #5761

N.B. It does not deal with born digital things, which we list on the works page. - this needs further consideration.

Things to be aware of:

The IIIF Authorization Flow API 2.0 docs describe three interaction patterns external, kiosk and active. Kiosk is not relevant to us. Active is what we currently use for the clickthrough, but could be used to offer a login. External is the profile used for restricted items.

We use external for restricted items because we don't want to present most users with a login when they either don't have an account, or if they do, their account doesn't give them access to restricted items anyway. This is also the preferred behaviour if the iiif manifest were to be loaded into a third party viewer.

Ordinarily, with the external access service:

However, in our case there is an access service provided by the id of the external service and we need to use it because logging in via Auth0 is a separate system and doesn't provide the authorizing aspect we need.

How we handle restricted items using the external service

  • A user visits the items page to view the contents of a iiif presentation manifest that contains restricted items.
  • If the user is logged in and has a role of 'StaffWithRestricted' we use javascript to open a new window pointing to the id specified in the external service.
  • The first time this happens, the new page prompts the user to login again and provides them with the necessary authorizing cookie, before closing the window automatically (on localhost you also need to click a button because the site and services are running on different domains)
  • Subsequent views of the items page open and close the window automatically without user interaction as long as the login is still valid.
  • Once that is done, things work the same way as clickthroughs. We use the token service (with the authorizing cookie) to get an accessToken.

The IIIF Authorization Flow API 2.0 docs then states we should use query the Probe service with the access token to understand whether the user has access to the access-controlled resource for which the probe service is declared. Orignally I did this, but the probe service doesn't return anything other than a 200 status in our case, so it felt a bit redundant. Instead, I simply use the presence of the accessToken as the condition for trying to load the images.

Other things worth knowing

We can have v2 and v1 versions of the auth services in a manifest, but we don't always have v2. Furthermore, only the access service provided by the id of the v2 exteranl service works, the v1 version 404s.

We therefore always try to use the v2 service and fallback to the v1 service. We need to fallback because the presence of this service is what we use to determine whether to show the restricted message to users.

This means that if a user is logged in with a role of 'StaffWithRestricted' and visits an items page with restricted things but only v1 auth services in the manifest, the images won't load. There is a ticket to address this with modified messaging. Caveat if the user has already visited an item with v2 external services and authorized, then they will be able to see the images.

The iiif docs state that, "If more than one access service is available, the client should interact with them in the order external, kiosk, active." However, in our case we only want users with a role of "StaffWithRestricted" to use the external access service and only if the external access service is available as v2.

Because the external access service only works with v2 services, we fallback to the v1 active service (if we have a mix)
This means that, for items with a mix of external and active services, users with roles of "StaffWithRestricted" will still be able to see things that require a user interaction.

How to test

  1. Without logging in or logging in with a user that has a role !== 'StaffWithRestricted' visit the following pages:

The behaviour should be the same as the live site.

N.B. users should never end up in the above situations as we don't link to the items page from the work page under these circumstances.

  • Mix of restricted and clickthrough: http://localhost:3000/works/nvnknvs7/items - should be presented with a modal containing a content advisory warning. Click 'View the content' should make the first image viewable, but the second image should present a message telling you that it is restricted.
  1. Log in with a user that has a role === 'StaffWithRestricted' and visit the following pages:

N.B. on local a new window should open either with a login form or a submit button. Once the form is submitted or the button clicked the window should close.

N.B. Restricted PDFs should behave as audio/video do. However, according to Ashley all PDFs that are ingested are open, so we can't test them.

How can we measure success?

Staff with the correct permissions can view restricted material.

Have we considered potential risks?

Risks should be negligible as the only changes in behaviour should be for the limited number of people who have the role of 'StaffWithRestricted'. As long as e2e tests are passing and the above testing works, we should be good.

Copy link

github-actions bot commented Oct 21, 2024

Size Change: +2.77 kB (+0.28%)

Total Size: 973 kB

Filename Size Change
content/webapp/.next/static/chunks/7044-b6c14b7fdc5073c5.js 0 B -5.51 kB (removed) 🏆
content/webapp/.next/static/chunks/9042-da245b7540a5c643.js 0 B -5.21 kB (removed) 🏆
content/webapp/.next/static/chunks/9262-1efa3cbea792d043.js 0 B -21.2 kB (removed) 🏆
content/webapp/.next/static/chunks/pages/works/[workId]-bae28bdc5e974135.js 0 B -22.2 kB (removed) 🏆
content/webapp/.next/static/chunks/pages/works/[workId]/images-c7b515c70c18d093.js 0 B -696 B (removed) 🏆
content/webapp/.next/static/chunks/4133-d91fe1f8fc0e2368.js 3.76 kB +3.76 kB (new file) 🆕
content/webapp/.next/static/chunks/4769-8a82adb1709af6d7.js 4.82 kB +4.82 kB (new file) 🆕
content/webapp/.next/static/chunks/8069-d52fb298de38bc71.js 17.3 kB +17.3 kB (new file) 🆕
content/webapp/.next/static/chunks/9042-270443a3fb518096.js 5.33 kB +5.33 kB (new file) 🆕
content/webapp/.next/static/chunks/pages/works/[workId]-1a501da6e1162417.js 23.6 kB +23.6 kB (new file) 🆕
content/webapp/.next/static/chunks/pages/works/[workId]/images-8a8f2334078310e8.js 699 B +699 B (new file) 🆕
content/webapp/.next/static/chunks/pages/works/[workId]/items-55cc335245248060.js 2.4 kB +2.4 kB (new file) 🆕
ℹ️ View Unchanged
Filename Size Change
content/webapp/.next/static/chunks/00a8a139.976ae5fd9989bf10.js 59 kB 0 B
content/webapp/.next/static/chunks/132.1d7e9ae9baf2bf3e.js 4.82 kB 0 B
content/webapp/.next/static/chunks/1349.d2a91366cd45a4ca.js 1.13 kB 0 B
content/webapp/.next/static/chunks/1624.078f48c0e02f531b.js 269 B 0 B
content/webapp/.next/static/chunks/1747-5fd40caeb12f236d.js 6.96 kB 0 B
content/webapp/.next/static/chunks/2223.13e51946be4f0995.js 1.8 kB 0 B
content/webapp/.next/static/chunks/2224.bc68143081ea6316.js 1.36 kB 0 B
content/webapp/.next/static/chunks/2545.c2b990ec5d9479b8.js 1.36 kB 0 B
content/webapp/.next/static/chunks/2568.b1076f5e01039efd.js 802 B 0 B
content/webapp/.next/static/chunks/2630-4bf3a02ad19c8ede.js 4.46 kB 0 B
content/webapp/.next/static/chunks/267-d39fe4d3f0f27696.js 3.67 kB 0 B
content/webapp/.next/static/chunks/286.b066630328a98bd8.js 20.8 kB 0 B
content/webapp/.next/static/chunks/3.118acbbc2ae9c2bd.js 711 B 0 B
content/webapp/.next/static/chunks/3199.4ed9de84fa34a4be.js 439 B 0 B
content/webapp/.next/static/chunks/3419.35e7d06626e8c6d0.js 420 B 0 B
content/webapp/.next/static/chunks/3420-7e0cf6c9a569a227.js 3.87 kB 0 B
content/webapp/.next/static/chunks/3471-36aed1d4030cea1e.js 2.75 kB 0 B
content/webapp/.next/static/chunks/3627.3684abdbe8510420.js 1.77 kB 0 B
content/webapp/.next/static/chunks/382-ca57e688a4545109.js 3.07 kB 0 B
content/webapp/.next/static/chunks/4468.bdc27fdcaba7eeb6.js 6.42 kB 0 B
content/webapp/.next/static/chunks/4537-29080707bc0242bb.js 4.22 kB 0 B
content/webapp/.next/static/chunks/4825-4df3e43759acfe8c.js 7.76 kB 0 B
content/webapp/.next/static/chunks/4962-1a876f84ea228198.js 12.3 kB 0 B
content/webapp/.next/static/chunks/5006-e89ff8af75151368.js 7.15 kB 0 B
content/webapp/.next/static/chunks/5048.c1216d2909771efa.js 2.87 kB 0 B
content/webapp/.next/static/chunks/5286-bee6f4dcdeeae555.js 3.27 kB 0 B
content/webapp/.next/static/chunks/5292-b399898dfbbd0ba7.js 2.83 kB 0 B
content/webapp/.next/static/chunks/5389.d762d43fb2d0a421.js 1.7 kB 0 B
content/webapp/.next/static/chunks/5435-4268f265804ebf5e.js 4.6 kB 0 B
content/webapp/.next/static/chunks/5768-699dd21166035c67.js 3.18 kB 0 B
content/webapp/.next/static/chunks/5843-e7a3b6f6cdcea870.js 3.09 kB 0 B
content/webapp/.next/static/chunks/6207.faaccc5f80a44f7a.js 268 B 0 B
content/webapp/.next/static/chunks/6318.9b79dafa4a83ab14.js 2.29 kB 0 B
content/webapp/.next/static/chunks/6501.a4bbcf1ca03737bf.js 1.3 kB 0 B
content/webapp/.next/static/chunks/6577-effbaab7dae5448b.js 3.52 kB 0 B
content/webapp/.next/static/chunks/6862-7cf8b92070da46f4.js 4.43 kB 0 B
content/webapp/.next/static/chunks/6879.76da889a24c486ba.js 2.6 kB 0 B
content/webapp/.next/static/chunks/7107-eecda3d84c2ca297.js 34.1 kB 0 B
content/webapp/.next/static/chunks/722-f8a675b537266d7d.js 3.2 kB 0 B
content/webapp/.next/static/chunks/7414-03438ef5466cad65.js 6 kB 0 B
content/webapp/.next/static/chunks/7440.919417010418505e.js 2.85 kB 0 B
content/webapp/.next/static/chunks/7603-1256b678076a1b0c.js 3.27 kB 0 B
content/webapp/.next/static/chunks/7888.a02595574e302988.js 5.3 kB 0 B
content/webapp/.next/static/chunks/8189-461a5e1315036809.js 3.45 kB 0 B
content/webapp/.next/static/chunks/8348.7aa3dc55a5cec72b.js 1.26 kB 0 B
content/webapp/.next/static/chunks/9049-a63f6fa100834eba.js 3.63 kB 0 B
content/webapp/.next/static/chunks/908.c3283f73c6e55bbf.js 1.79 kB 0 B
content/webapp/.next/static/chunks/9519-17ece67700b23bb2.js 6.16 kB 0 B
content/webapp/.next/static/chunks/9590.2d7b95171d8d0866.js 579 B 0 B
content/webapp/.next/static/chunks/9680-68fd13189afcdb6c.js 3.07 kB 0 B
content/webapp/.next/static/chunks/9778-7a9dca488eda648b.js 3.06 kB 0 B
content/webapp/.next/static/chunks/9950.02e3834265565be8.js 1.13 kB 0 B
content/webapp/.next/static/chunks/framework-cd51c6317946e9aa.js 45.2 kB 0 B
content/webapp/.next/static/chunks/main-978dba4ddde48128.js 30.7 kB 0 B
content/webapp/.next/static/chunks/pages/_app-b2dd3c6e46ab02fc.js 111 kB 0 B
content/webapp/.next/static/chunks/pages/_error-4ae94352bfd58ed4.js 335 B 0 B
content/webapp/.next/static/chunks/pages/404-9b6af81752f83cf9.js 263 B 0 B
content/webapp/.next/static/chunks/pages/500-7bf98e2f0d70a0db.js 262 B 0 B
content/webapp/.next/static/chunks/pages/articles-c733c3a3a001cddf.js 2.94 kB 0 B
content/webapp/.next/static/chunks/pages/articles/[articleId]-04d54e858d8cb216.js 6.78 kB 0 B
content/webapp/.next/static/chunks/pages/books-7e54c2ecdf8262a9.js 2.97 kB 0 B
content/webapp/.next/static/chunks/pages/books/[bookId]-077d421bd1e84d05.js 4.2 kB 0 B
content/webapp/.next/static/chunks/pages/collections-63d66185252255d3.js 2.4 kB 0 B
content/webapp/.next/static/chunks/pages/concepts/[conceptId]-af7bff21125eb4c7.js 4.39 kB 0 B
content/webapp/.next/static/chunks/pages/cookie-policy-d38036ca95595d73.js 6.3 kB 0 B
content/webapp/.next/static/chunks/pages/event-series/[eventSeriesId]-10f4eff99691fdee.js 3.29 kB 0 B
content/webapp/.next/static/chunks/pages/events-312d32ae87d73ba1.js 3.07 kB 0 B
content/webapp/.next/static/chunks/pages/events/[eventId]-06da1af3e8113b77.js 9.11 kB 0 B
content/webapp/.next/static/chunks/pages/events/[eventId]/visual-stories-e361b663cc5ee385.js 304 B 0 B
content/webapp/.next/static/chunks/pages/exhibitions-aa8e051201efcff6.js 3.32 kB 0 B
content/webapp/.next/static/chunks/pages/exhibitions/[exhibitionId]-ebd86bfefdc80224.js 4.01 kB 0 B
content/webapp/.next/static/chunks/pages/exhibitions/[exhibitionId]/visual-stories-b0cfcf472928d278.js 304 B 0 B
content/webapp/.next/static/chunks/pages/guides/[guideId]-f15d8bf0f0b30f6f.js 2.29 kB 0 B
content/webapp/.next/static/chunks/pages/guides/exhibitions-cc37bb895fb8374c.js 3.55 kB 0 B
content/webapp/.next/static/chunks/pages/guides/exhibitions/[id]-01fa1c38a860e277.js 3.5 kB 0 B
content/webapp/.next/static/chunks/pages/guides/exhibitions/[id]/[type]-e20ea2f1870b9a00.js 7.31 kB 0 B
content/webapp/.next/static/chunks/pages/guides/exhibitions/[id]/[type]/[stop]-0a15eccf1f452b59.js 3.91 kB 0 B
content/webapp/.next/static/chunks/pages/index-f6c063ca853878cd.js 1.99 kB 0 B
content/webapp/.next/static/chunks/pages/newsletter-4ed6a4a888a857f4.js 2.38 kB 0 B
content/webapp/.next/static/chunks/pages/pages/[pageId]-02780a97a3f7acb0.js 1.94 kB 0 B
content/webapp/.next/static/chunks/pages/projects/[projectId]-7acc29f96e1d673f.js 2.27 kB 0 B
content/webapp/.next/static/chunks/pages/search-c6489169019b5970.js 5.34 kB 0 B
content/webapp/.next/static/chunks/pages/search/events-147e6a873dcee57a.js 1.52 kB 0 B
content/webapp/.next/static/chunks/pages/search/images-c368bfeff46d5e5c.js 2.16 kB 0 B
content/webapp/.next/static/chunks/pages/search/stories-5530ac75dd7f9fe6.js 3.27 kB 0 B
content/webapp/.next/static/chunks/pages/search/works-b4853ff80a576e18.js 4.4 kB 0 B
content/webapp/.next/static/chunks/pages/seasons/[seasonId]-005659ad17a2f569.js 3.94 kB 0 B
content/webapp/.next/static/chunks/pages/series/[seriesId]-58f8f6c9d908435d.js 5.55 kB 0 B
content/webapp/.next/static/chunks/pages/slice-simulator-29a0ef9211652363.js 8.48 kB 0 B
content/webapp/.next/static/chunks/pages/stories-a8381c684c611a74.js 3.62 kB 0 B
content/webapp/.next/static/chunks/pages/stories/[contentType]-a81d27a39789f841.js 2.99 kB 0 B
content/webapp/.next/static/chunks/pages/visit-us-ffb0bbde0fb39fdb.js 2.45 kB 0 B
content/webapp/.next/static/chunks/pages/visual-stories/[visualStoryId]-13d261b44455da8c.js 242 B 0 B
content/webapp/.next/static/chunks/pages/whats-on-425c28a6ef16454b.js 220 B 0 B
content/webapp/.next/static/chunks/pages/whats-on/[period]-52becb68c10c131c.js 288 B 0 B
content/webapp/.next/static/chunks/pages/works/[workId]/download-ccf37e6191bb73ec.js 3.06 kB 0 B
content/webapp/.next/static/chunks/pages/works/[workId]/items-6ffa22656f41d8b9.js 0 B -217 B (removed) 🏆
content/webapp/.next/static/chunks/polyfills-c67a75d1b6f99dc8.js 31.1 kB 0 B
content/webapp/.next/static/chunks/webpack-4ccaf26a72b7777c.js 2.34 kB 0 B
identity/webapp/.next/static/chunks/286.b94e91b70e38ea49.js 20.7 kB 0 B
identity/webapp/.next/static/chunks/374.94537fd117195c86.js 2.47 kB 0 B
identity/webapp/.next/static/chunks/432.fa29da5acdb8e0b1.js 744 B 0 B
identity/webapp/.next/static/chunks/442-f1af16c3993c320a.js 8.96 kB 0 B
identity/webapp/.next/static/chunks/644-2ca73088ad8338ab.js 16.4 kB 0 B
identity/webapp/.next/static/chunks/framework-b330de622121c9cc.js 45.2 kB 0 B
identity/webapp/.next/static/chunks/main-d973a3979032d64a.js 32.2 kB 0 B
identity/webapp/.next/static/chunks/pages/_app-3015a8681e165f62.js 104 kB 0 B
identity/webapp/.next/static/chunks/pages/_error-8e82953fa241027d.js 1.42 kB 0 B
identity/webapp/.next/static/chunks/pages/delete-requested-172ecc81cb6f0fa0.js 3.22 kB 0 B
identity/webapp/.next/static/chunks/pages/error-2784191c63901541.js 1.7 kB 0 B
identity/webapp/.next/static/chunks/pages/index-44b48653e661ac63.js 11.9 kB 0 B
identity/webapp/.next/static/chunks/pages/registration-518df86b53b49f22.js 4.12 kB 0 B
identity/webapp/.next/static/chunks/pages/success-bb0753aae1b76578.js 3.29 kB 0 B
identity/webapp/.next/static/chunks/pages/validated-6306e8aad1aae32a.js 3.37 kB 0 B
identity/webapp/.next/static/chunks/polyfills-c67a75d1b6f99dc8.js 31.1 kB 0 B
identity/webapp/.next/static/chunks/webpack-d9d97d637ba6ec7a.js 1.82 kB 0 B

compressed-size-action

@gestchild gestchild marked this pull request as ready for review October 22, 2024 14:49
@gestchild gestchild requested a review from a team as a code owner October 22, 2024 14:49
@@ -30,6 +30,7 @@ type Props = {
parentManifest: ParentManifest | undefined;
searchResults: SearchResults | null;
setSearchResults: (v) => void;
accessToken: string | undefined;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

np: below we use the prop?: string form, we could align? very much not a blocker or necessary.

const mainImageService = { '@id': currentCanvas.imageServiceId };
const urlTemplateMain = mainImageService['@id']
? iiifImageTemplate(mainImageService['@id'])
const { user } = useUser();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a real suggestion for this just a thought; was wondering if it was worth adding something like

const isStaffWithRestricted = user?.role === 'StaffWithRestricted'

in the useUser() context/hook. Since we do this check often!

@gestchild gestchild merged commit 889118a into main Oct 29, 2024
8 checks passed
@gestchild gestchild deleted the display-restricted-to-staff branch October 29, 2024 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants