universalviewer icon indicating copy to clipboard operation
universalviewer copied to clipboard

send an http header to the image server when loading the manifest

Open atomotic opened this issue 7 years ago • 4 comments

given this scenario: universalviewer is embedded into a page where the user has been logged and authenticated, and a json web token is available to the user session.

i'm wondering if this behaviour is correct (i've not fully understand if iiiif authentication cover this use case): when loading the iiif manifest from a remote image server also send an http header with the jwt token.

the iiif server could validate the jwt token and respond with different content (probably watermark) depending on some content of the jwt payload. this could be easily done with cantaloupe delegation script: https://medusa-project.github.io/cantaloupe/manual/4.0/access-control.html#Authorization

so the question: how to embed universalviewer and send an http header when loading the manifest?

post edit: i see that this request duplicates https://github.com/UniversalViewer/universalviewer/issues/624 https://github.com/IIIF/api/issues/1732

atomotic avatar Nov 26 '18 20:11 atomotic

I have another use case for an http header to send to requests made by the viewer: UV will be embedded in a website where users will choose language preferences. From these language preferences we will generate a string that can go into a Accept-Language http header (or maybe a X-BDRC-Accept-Language if we can't encode some subtleties). We would like to pass this header to requests made to the iiif presentation api, so that our server can encode the labels of the various property values it returns. This could be as simple as a configuration like

createUV('#uv', {
    iiifResourceUri: 'http://wellcomelibrary.org/iiif/b18035723/manifest',
    configUri: 'uv-config.json',
    additionalHeaders: {
        'Accept-Language': "bo-x-ewts"
    }
}, new UV.URLDataProvider());

or a more generic

createUV('#uv', {
    iiifResourceUri: 'http://wellcomelibrary.org/iiif/b18035723/manifest',
    configUri: 'uv-config.json',
    additionalHeadersHook: function() {
       return {
           'Accept-Language': "bo-x-ewts"
       }
   }
}, new UV.URLDataProvider());

Does it seem reasonable?

eroux avatar Feb 26 '19 11:02 eroux

At the moment I believe internally jQuery is used to make the calls, so it may be possible to use $.ajaxSetup to get custom headers sent, although this doesn't fall under the IIIF Auth specification itself.

stephenwf avatar Feb 26 '19 11:02 stephenwf

I can't see an issue with adding extra request headers - although we definitely want to move away from jquery at some point: https://github.com/IIIF-Commons/manifold/blob/master/src/ExternalResource.ts#L278

edsilv avatar Feb 26 '19 11:02 edsilv

excellent, thanks a lot!

eroux avatar Feb 26 '19 12:02 eroux

All issues will be triaged for further investigation or closure by the 28 September 2023. If your issue is still relevant and would like for it be investigated further please comment by 14 September 2023.

LlGC-szw avatar Aug 25 '23 11:08 LlGC-szw

Closing due to inactivity (and possible resolution).

demiankatz avatar Nov 02 '23 17:11 demiankatz