projectblacklight / blacklight-access_controls

Provides access controls for Blacklight-based Rails applications.
2 stars 3 forks source link

Support for Blacklight 7 #56

Open awead opened 5 years ago

awead commented 5 years ago

Does BL-AC support BL 7? From what I can tell, it's being testing, but adding to an existing app doesn't seem to quite work. This still needs to be done:

https://github.com/projectblacklight/blacklight-access_controls/blob/master/lib/blacklight/access_controls/catalog.rb#L19

I might have some time to dedicate to this if anyone can give a status update in terms of what needs to be done, and suggestions as to how to solve those. Do we need separate generators for the different versions?

jcoyne commented 5 years ago

Yes, I think you're right Adam, it doesn't look done. I think you want to set the search_service_class on the CatalogController (see https://github.com/projectblacklight/blacklight/blob/037633c43975feadd02605cae08f15abc474e98d/app/controllers/concerns/blacklight/searchable.rb#L4-L6). That class can use this search builder.

See also: https://github.com/projectblacklight/blacklight/blob/3a04827dfa46fc8dbfd582575bf96ff9b88255de/app/controllers/concerns/blacklight/controller.rb#L37 https://github.com/projectblacklight/blacklight/blob/3a04827dfa46fc8dbfd582575bf96ff9b88255de/app/services/blacklight/search_service.rb

jcoyne commented 5 years ago

Alternatively, you could do something like: Blacklight::SearchService.search_builder_class = Blacklight::AccessControls::SearchBuilder, but I think I prefer BAC to provide it's own SearchService.

e.g.:

class Blacklight::AccessControls::SearchService < Blacklight::SearchService
...
end

CatalogController.search_service_class = Blacklight::AccessControls::SearchService 
jrochkind commented 5 years ago

If you have a fixed SearchService class you use like:

CatalogController.search_service_class = Blacklight::AccessControls::SearchService 

Then the Blacklight::AccessControls SearchService customization is the only one you can easily have in your app. What if you need other ones too? (I have done a local one myself)

So recommend maybe additionally providing an AS::Concern you can mix into your own local SearchService class to get blacklight-access_controls behavior, which can be in addition to other search service customizations, local or from other gems?

CatalogController.search_service_class = MySearchService 

class MySearchService < Blacklight::SearchService
   include Blacklight::AccessControls::SearchServiceBehavior
   include Whatever::SomethingElse
end

I can't think of any other way to allow search service customizations from both b-ac and maybe other places?

Possibly useful things I discovered for context:

https://bibwild.wordpress.com/2019/04/30/blacklight-7-current_user-or-other-request-context-in-searchbuilder-solr-query-builder/

dgcliff commented 5 years ago

That seems a reasonable approach to take with a generator

awead commented 5 years ago

Incidentally, these were the only changes I had to make to get this working in BL7:

https://github.com/psu-libraries/cho/pull/986/commits/331b95fd0aa560fb0bbe587a63c4a18c0c99dca7#diff-a3a81055b647b2fd690ac3b4d2939899R239 https://github.com/psu-libraries/cho/commit/331b95fd0aa560fb0bbe587a63c4a18c0c99dca7#diff-a3a81055b647b2fd690ac3b4d2939899R239

Enforcing restrictions on show actions works as-is.