mjordan / islandora_bagger

Tool for generating Bags for Islandora 8 content.
MIT License
4 stars 12 forks source link

Authorization, mostly #52

Closed ajstanley closed 3 years ago

ajstanley commented 4 years ago

I added a bunch of token authorizations to allow for locked-down fedoras (Sorry about all the format changes, PHPStorm has opinions about how code should look)

mjordan commented 4 years ago

Can you lay out how I can test this?

ajstanley commented 4 years ago

Try running a bag on a node with locked down access. Any file or node that an anonymous user won't be able to see. You should get baggage.

The changes in the islandora_bagger_integration module will pass the Auth token as --extra

mjordan commented 4 years ago

Sorry, I'm still not clear on how to test. What do I pass in? Where do I get an auth token?

Would you mind adding an example to the sample config file included in README.md explainsing what goes in the new auth config setting? Maybe just after the existing drupal_basic_auth setting, e.g.

# Required.
drupal_base_url: 'http://localhost:8000'
drupal_basic_auth: ['admin', 'islandora']

# Or, use an auth token. You can get this from ......
auth: xxxxxxxxxxx

# Required. How to name the Bag directory (or file if serialized). One of 'nid' or 'uuid'.
bag_name: nid
ajstanley commented 4 years ago

Sorry (I may have left out some details) The JWT comes from here - Then its read here. There's no need to touch the config - the JWT is volatile so it's not stored.

mjordan commented 4 years ago

Testing this now and have found a backwards compatibility issue. In your branch, running bagger without passing the token (./bin/console app:islandora_bagger:create_bag --settings=sample_config.yml --node=65), I am getting

 ./bin/console app:islandora_bagger:create_bag --settings=sample_config.yml --node=65

In AddMedia.php line 62:

  Warning: Illegal string offset 'field_media_use'  

I wonder if adding logic to test if $this->settings['auth'] is set and if so, adding it to the array we're passing into the Guzzle client would do the trick? Want me to try that locally and if it works, merge it in after I merge your PR?

mjordan commented 4 years ago

OK, my fix worked when running it from the command line. Can you open a PR against Bagger Integration to add the code at https://github.com/roblib/islandora_bagger_integration/blob/master/src/Plugin/Form/IslandoraBaggerLocalForm.php#L94-L98 and I'll test that too?

mjordan commented 4 years ago

Just noticed.... the code that adds the auth option is in a form called IslandoraBaggerLocalForm.php, but that doesn't exist in the master branch. Is there another PR against Bagger Integration that I missed?

ajstanley commented 4 years ago

There's a pull that went in yesterday.