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

Adding JWT token to Openseadragon requests #40

Open
wants to merge 1 commit into
base: 2.x
Choose a base branch
from

Conversation

dannylamb
Copy link
Contributor

GitHub Issue: Islandora/documentation#2011

  • Other Relevant Links (Google Groups discussion, related pull requests,
    Release pull requests, etc.)

What does this Pull Request do?

Adds credentials to Openseadragon AJAX requests

What's new?

Jammin' in a JWT in the preprocess hooks

How should this be tested?

Once you pull in this PR, visit a page with the openseadragon viewer on it and check out the request in your developer console. You should see the AJAX request from Openseadragon with an Authorization header.

image

Interested parties

@Islandora/8-x-committers

@dannylamb
Copy link
Contributor Author

Second PR I've got going getting blocked by this 🤕

@@ -79,6 +79,9 @@ function template_preprocess_openseadragon_formatter(&$variables) {
'id' => $openseadragon_viewer_id,
'prefixUrl' => 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/2.4.2/images/',
'tileSources' => $tile_sources,
'loadTilesWithAjax' => TRUE,
'ajaxWithCredentials' => TRUE,
'ajaxHeaders' => ["Authorization" => "Bearer " . \Drupal::service('jwt.authentication.jwt')->generateToken()],
Copy link
Contributor

@adam-vessey adam-vessey Dec 16, 2021

Choose a reason for hiding this comment

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

Cache tags/contexts would have to be added for this to avoid using the results for all users and/or living beyond their expiry... and does it make sense to be generating tokens for anonymous users, if it's going to trash the cache?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch @adam-vessey . I'll give it the caching treatment for users.

If anonymous having a token breaks caching, I can tell it not to add a token for anon and then adjust the custom delegate appropriately.

@seth-shaw-unlv
Copy link
Contributor

@dannylamb can you include @whikloj 's github action mysql fix to your PR: https://islandora.slack.com/archives/CM5PPAV28/p1639679529204300? More specifically, add this line https://github.com/whikloj/islandora/blob/2.x/.github/workflows/build-2.x.yml#L122 to our github workflows config?

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.

3 participants