blacklight-access_controls 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +2 -0
- data/Rakefile +0 -12
- data/VERSION +1 -1
- data/blacklight-access_controls.gemspec +1 -0
- data/lib/blacklight/access_controls/enforcement.rb +4 -11
- data/solr_conf/conf/schema.xml +372 -1268
- data/solr_conf/conf/solrconfig.xml +132 -149
- data/spec/unit/enforcement_spec.rb +18 -18
- metadata +17 -3
@@ -17,11 +17,11 @@
|
|
17
17
|
-->
|
18
18
|
|
19
19
|
<!--
|
20
|
-
This is a stripped down config file used for a simple example...
|
21
|
-
It is *not* a good example to work from.
|
20
|
+
This is a stripped down config file used for a simple example...
|
21
|
+
It is *not* a good example to work from.
|
22
22
|
-->
|
23
23
|
<config>
|
24
|
-
|
24
|
+
|
25
25
|
<!-- Controls what version of Lucene various components of Solr
|
26
26
|
adhere to. Generally, you want to use the latest version to
|
27
27
|
get all bug fixes and improvements. It is highly recommended
|
@@ -29,15 +29,15 @@
|
|
29
29
|
affect both how text is indexed and queried.
|
30
30
|
-->
|
31
31
|
<luceneMatchVersion>5.0.0</luceneMatchVersion>
|
32
|
+
|
33
|
+
<lib dir="${solr.install.dir:../../../..}/contrib/analysis-extras/lib" />
|
34
|
+
<lib dir="${solr.install.dir:../../../..}/contrib/analysis-extras/lucene-libs" />
|
35
|
+
<lib dir="${solr.install.dir:../../../..}/contrib/extraction/lib" regex=".*\.jar" />
|
36
|
+
<lib dir="${solr.install.dir:../../../..}/dist/" regex="solr-cell-\d.*\.jar" />
|
32
37
|
|
33
|
-
<
|
34
|
-
|
35
|
-
<lib dir="${solr.install.dir:../../../..}/contrib/analysis-extras/lib"/>
|
36
|
-
<lib dir="${solr.install.dir:../../../..}/contrib/analysis-extras/lucene-libs"/>
|
37
|
-
|
38
|
-
<directoryFactory name="DirectoryFactory"
|
38
|
+
<directoryFactory name="DirectoryFactory"
|
39
39
|
class="${solr.directoryFactory:solr.NRTCachingDirectoryFactory}">
|
40
|
-
</directoryFactory>
|
40
|
+
</directoryFactory>
|
41
41
|
|
42
42
|
<codecFactory class="solr.SchemaCodecFactory"/>
|
43
43
|
|
@@ -45,23 +45,32 @@
|
|
45
45
|
|
46
46
|
|
47
47
|
<dataDir>${solr.blacklight-core.data.dir:}</dataDir>
|
48
|
-
|
48
|
+
|
49
49
|
<requestDispatcher handleSelect="true" >
|
50
|
-
<requestParsers enableRemoteStreaming="false" multipartUploadLimitInKB="
|
50
|
+
<requestParsers enableRemoteStreaming="false" multipartUploadLimitInKB="2048000" />
|
51
51
|
</requestDispatcher>
|
52
|
-
|
52
|
+
|
53
53
|
<requestHandler name="/analysis/field" startup="lazy" class="solr.FieldAnalysisRequestHandler" />
|
54
54
|
|
55
|
-
<!-- config for the admin interface -->
|
55
|
+
<!-- config for the admin interface -->
|
56
56
|
<admin>
|
57
57
|
<defaultQuery>*:*</defaultQuery>
|
58
58
|
</admin>
|
59
59
|
|
60
|
-
<
|
61
|
-
<
|
62
|
-
<str name="
|
63
|
-
</
|
64
|
-
|
60
|
+
<updateHandler class="solr.DirectUpdateHandler2">
|
61
|
+
<updateLog>
|
62
|
+
<str name="dir">${solr.ulog.dir:}</str>
|
63
|
+
</updateLog>
|
64
|
+
|
65
|
+
<autoCommit>
|
66
|
+
<maxTime>${solr.autoCommit.maxTime:15000}</maxTime>
|
67
|
+
<openSearcher>false</openSearcher>
|
68
|
+
</autoCommit>
|
69
|
+
|
70
|
+
<autoSoftCommit>
|
71
|
+
<maxTime>${solr.autoSoftCommit.maxTime:-1}</maxTime>
|
72
|
+
</autoSoftCommit>
|
73
|
+
</updateHandler>
|
65
74
|
|
66
75
|
<!-- SearchHandler
|
67
76
|
|
@@ -76,117 +85,98 @@
|
|
76
85
|
<!-- default values for query parameters can be specified, these
|
77
86
|
will be overridden by parameters in the request
|
78
87
|
-->
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
88
|
+
<lst name="defaults">
|
89
|
+
<str name="defType">edismax</str>
|
90
|
+
<str name="echoParams">explicit</str>
|
91
|
+
<str name="q.alt">*:*</str>
|
92
|
+
<str name="mm">2<-1 5<-2 6<90%</str>
|
93
|
+
<int name="qs">1</int>
|
94
|
+
<int name="ps">2</int>
|
95
|
+
<float name="tie">0.01</float>
|
96
|
+
<!-- this qf and pf are used by default, if not otherwise specified by
|
97
|
+
client. The default blacklight_config will use these for the
|
98
|
+
"keywords" search. See the author_qf/author_pf, title_qf, etc
|
99
|
+
below, which the default blacklight_config will specify for
|
100
|
+
those searches. You may also be interested in:
|
101
|
+
http://wiki.apache.org/solr/LocalParams
|
102
|
+
-->
|
103
|
+
<str name="qf">
|
104
|
+
id
|
105
|
+
active_fedora_model_ssi
|
106
|
+
title_tesim
|
107
|
+
author_tesim
|
108
|
+
subject_tesim
|
109
|
+
</str>
|
110
|
+
<str name="pf">
|
111
|
+
all_text_timv^10
|
112
|
+
</str>
|
113
|
+
|
114
|
+
<str name="author_qf">
|
115
|
+
author_tesim
|
116
|
+
</str>
|
117
|
+
<str name="author_pf">
|
118
|
+
</str>
|
119
|
+
<str name="title_qf">
|
120
|
+
title_tesim
|
121
|
+
</str>
|
122
|
+
<str name="title_pf">
|
123
|
+
</str>
|
124
|
+
<str name="subject_qf">
|
125
|
+
subject_tesim
|
126
|
+
</str>
|
127
|
+
<str name="subject_pf">
|
128
|
+
</str>
|
129
|
+
|
130
|
+
<str name="fl">
|
131
|
+
*,
|
132
|
+
score
|
133
|
+
</str>
|
134
|
+
|
135
|
+
<str name="facet">true</str>
|
136
|
+
<str name="facet.mincount">1</str>
|
137
|
+
|
138
|
+
<str name="spellcheck">true</str>
|
139
|
+
<str name="spellcheck.dictionary">default</str>
|
140
|
+
<str name="spellcheck.onlyMorePopular">true</str>
|
141
|
+
<str name="spellcheck.extendedResults">true</str>
|
142
|
+
<str name="spellcheck.collate">false</str>
|
143
|
+
<str name="spellcheck.count">5</str>
|
144
|
+
|
145
|
+
</lst>
|
146
|
+
<arr name="last-components">
|
147
|
+
<str>spellcheck</str>
|
148
|
+
</arr>
|
149
|
+
</requestHandler>
|
103
150
|
|
104
|
-
|
151
|
+
<requestHandler name="permissions" class="solr.SearchHandler" >
|
152
|
+
<lst name="defaults">
|
153
|
+
<str name="facet">off</str>
|
154
|
+
<str name="echoParams">all</str>
|
155
|
+
<str name="rows">1</str>
|
156
|
+
<str name="q">{!raw f=id v=$id}</str> <!-- use id=666 instead of q=id:666 -->
|
105
157
|
<str name="fl">
|
106
|
-
*,
|
107
|
-
score
|
108
|
-
</str>
|
109
|
-
<!--str name="fl">
|
110
158
|
id,
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
<str name="spellcheck">true</str>
|
126
|
-
<str name="spellcheck.dictionary">default</str>
|
127
|
-
<str name="spellcheck.onlyMorePopular">true</str>
|
128
|
-
<str name="spellcheck.extendedResults">true</str>
|
129
|
-
<str name="spellcheck.collate">false</str>
|
130
|
-
<str name="spellcheck.count">5</str>
|
131
|
-
|
159
|
+
access_ssim,
|
160
|
+
discover_access_group_ssim,discover_access_person_ssim,
|
161
|
+
read_access_group_ssim,read_access_person_ssim,
|
162
|
+
edit_access_group_ssim,edit_access_person_ssim,
|
163
|
+
download_access_group_ssim,download_access_person_ssim,
|
164
|
+
depositor_ti,
|
165
|
+
embargo_release_date_dtsi
|
166
|
+
inheritable_access_ssim,
|
167
|
+
inheritable_discover_access_group_ssim,inheritable_discover_access_person_ssim,
|
168
|
+
inheritable_read_access_group_ssim,inheritable_read_access_person_ssim,
|
169
|
+
inheritable_edit_access_group_ssim,inheritable_edit_access_person_ssim,
|
170
|
+
inheritable_embargo_release_date_dtsi
|
171
|
+
</str>
|
132
172
|
</lst>
|
133
|
-
|
134
|
-
to identify values which should be appended to the list of
|
135
|
-
multi-val params from the query (or the existing "defaults").
|
136
|
-
-->
|
137
|
-
<!-- In this example, the param "fq=instock:true" would be appended to
|
138
|
-
any query time fq params the user may specify, as a mechanism for
|
139
|
-
partitioning the index, independent of any user selected filtering
|
140
|
-
that may also be desired (perhaps as a result of faceted searching).
|
141
|
-
that may also be desired (perhaps as a result of faceted searching).
|
142
|
-
|
143
|
-
NOTE: there is *absolutely* nothing a client can do to prevent these
|
144
|
-
"appends" values from being used, so don't use this mechanism
|
145
|
-
unless you are sure you always want it.
|
146
|
-
-->
|
147
|
-
<!--
|
148
|
-
<lst name="appends">
|
149
|
-
<str name="fq">inStock:true</str>
|
150
|
-
</lst>
|
151
|
-
-->
|
152
|
-
<!-- "invariants" are a way of letting the Solr maintainer lock down
|
153
|
-
the options available to Solr clients. Any params values
|
154
|
-
specified here are used regardless of what values may be specified
|
155
|
-
in either the query, the "defaults", or the "appends" params.
|
156
|
-
|
157
|
-
In this example, the facet.field and facet.query params would
|
158
|
-
be fixed, limiting the facets clients can use. Faceting is
|
159
|
-
not turned on by default - but if the client does specify
|
160
|
-
facet=true in the request, these are the only facets they
|
161
|
-
will be able to see counts for; regardless of what other
|
162
|
-
facet.field or facet.query params they may specify.
|
163
|
-
|
164
|
-
NOTE: there is *absolutely* nothing a client can do to prevent these
|
165
|
-
"invariants" values from being used, so don't use this mechanism
|
166
|
-
unless you are sure you always want it.
|
167
|
-
-->
|
168
|
-
<!--
|
169
|
-
<lst name="invariants">
|
170
|
-
<str name="facet.field">cat</str>
|
171
|
-
<str name="facet.field">manu_exact</str>
|
172
|
-
<str name="facet.query">price:[* TO 500]</str>
|
173
|
-
<str name="facet.query">price:[500 TO *]</str>
|
174
|
-
</lst>
|
175
|
-
-->
|
176
|
-
<!-- If the default list of SearchComponents is not desired, that
|
177
|
-
list can either be overridden completely, or components can be
|
178
|
-
prepended or appended to the default list. (see below)
|
179
|
-
-->
|
180
|
-
<!--
|
181
|
-
<arr name="components">
|
182
|
-
<str>nameOfCustomComponent1</str>
|
183
|
-
<str>nameOfCustomComponent2</str>
|
184
|
-
</arr>
|
185
|
-
-->
|
186
|
-
<arr name="last-components">
|
187
|
-
<str>spellcheck</str>
|
188
|
-
</arr>
|
173
|
+
</requestHandler>
|
189
174
|
|
175
|
+
<requestHandler name="standard" class="solr.SearchHandler">
|
176
|
+
<lst name="defaults">
|
177
|
+
<str name="echoParams">explicit</str>
|
178
|
+
<str name="defType">lucene</str>
|
179
|
+
</lst>
|
190
180
|
</requestHandler>
|
191
181
|
|
192
182
|
<!-- for requests to get a single document; use id=666 instead of q=id:666 -->
|
@@ -199,13 +189,13 @@
|
|
199
189
|
</lst>
|
200
190
|
</requestHandler>
|
201
191
|
|
202
|
-
|
192
|
+
<!-- Spell Check
|
203
193
|
|
204
|
-
|
205
|
-
|
194
|
+
The spell check component can return a list of alternative spelling
|
195
|
+
suggestions.
|
206
196
|
|
207
|
-
|
208
|
-
|
197
|
+
http://wiki.apache.org/solr/SpellCheckComponent
|
198
|
+
-->
|
209
199
|
<searchComponent name="spellcheck" class="solr.SpellCheckComponent">
|
210
200
|
|
211
201
|
<str name="queryAnalyzerFieldType">textSpell</str>
|
@@ -257,7 +247,7 @@
|
|
257
247
|
</lst>
|
258
248
|
-->
|
259
249
|
|
260
|
-
<!-- a spellchecker that use an alternate comparator
|
250
|
+
<!-- a spellchecker that use an alternate comparator
|
261
251
|
|
262
252
|
comparatorClass be one of:
|
263
253
|
1. score (default)
|
@@ -306,25 +296,18 @@
|
|
306
296
|
</arr>
|
307
297
|
</requestHandler>
|
308
298
|
|
309
|
-
<requestHandler name="
|
299
|
+
<requestHandler name="/update/extract" class="org.apache.solr.handler.extraction.ExtractingRequestHandler">
|
310
300
|
<lst name="defaults">
|
311
|
-
<str name="
|
312
|
-
<str name="
|
313
|
-
<str name="rows">1</str>
|
314
|
-
<str name="q">{!raw f=id v=$id}</str> <!-- use id=666 instead of q=id:666 -->
|
315
|
-
<str name="fl">
|
316
|
-
id,
|
317
|
-
access_ssim,
|
318
|
-
discover_access_group_ssim,discover_access_person_ssim,
|
319
|
-
read_access_group_ssim,read_access_person_ssim,
|
320
|
-
download_access_group_ssim,download_access_person_ssim,
|
321
|
-
depositor_ti,
|
322
|
-
inheritable_access_ssim,
|
323
|
-
inheritable_discover_access_group_ssim,inheritable_discover_access_person_ssim,
|
324
|
-
inheritable_read_access_group_ssim,inheritable_read_access_person_ssim,
|
325
|
-
inheritable_download_access_group_ssim,inheritable_download_access_person_ssim,
|
326
|
-
</str>
|
301
|
+
<str name="fmap.Last-Modified">last_modified</str>
|
302
|
+
<str name="uprefix">ignored_</str>
|
327
303
|
</lst>
|
304
|
+
<!--Optional. Specify a path to a tika configuration file. See the Tika docs for details.-->
|
305
|
+
<!-- <str name="tika.config">/my/path/to/tika.config</str> -->
|
306
|
+
<!-- Optional. Specify one or more date formats to parse. See DateUtil.DEFAULT_DATE_FORMATS
|
307
|
+
for default date formats -->
|
308
|
+
<!-- <lst name="date.formats"> -->
|
309
|
+
<!-- <str>yyyy-MM-dd</str> -->
|
310
|
+
<!-- </lst> -->
|
328
311
|
</requestHandler>
|
329
|
-
|
330
312
|
</config>
|
313
|
+
|
@@ -12,6 +12,10 @@ describe Blacklight::AccessControls::Enforcement do
|
|
12
12
|
|
13
13
|
subject { search_builder }
|
14
14
|
|
15
|
+
before do
|
16
|
+
allow(controller).to receive(:current_ability).and_return(ability)
|
17
|
+
end
|
18
|
+
|
15
19
|
describe "When I am searching for content" do
|
16
20
|
before do
|
17
21
|
@solr_parameters = {}
|
@@ -19,7 +23,6 @@ describe Blacklight::AccessControls::Enforcement do
|
|
19
23
|
|
20
24
|
context "Given I am not logged in" do
|
21
25
|
before do
|
22
|
-
subject.current_ability = ability
|
23
26
|
subject.send(:apply_gated_discovery, @solr_parameters)
|
24
27
|
end
|
25
28
|
|
@@ -33,11 +36,13 @@ describe Blacklight::AccessControls::Enforcement do
|
|
33
36
|
end
|
34
37
|
|
35
38
|
context "Given I am a registered user" do
|
36
|
-
let(:user)
|
39
|
+
let(:user) do
|
40
|
+
create(:user).tap do |u|
|
41
|
+
allow(u).to receive(:groups) { ["faculty", "africana-faculty"] }
|
42
|
+
end
|
43
|
+
end
|
37
44
|
|
38
45
|
before do
|
39
|
-
allow(user).to receive(:groups) { ["faculty", "africana-faculty"] }
|
40
|
-
subject.current_ability = Ability.new(user)
|
41
46
|
subject.send(:apply_gated_discovery, @solr_parameters)
|
42
47
|
end
|
43
48
|
|
@@ -67,7 +72,6 @@ describe Blacklight::AccessControls::Enforcement do
|
|
67
72
|
describe "#except" do
|
68
73
|
let(:user) { build(:user) }
|
69
74
|
let(:ability) { Ability.new(user) }
|
70
|
-
before { search_builder.current_ability = ability }
|
71
75
|
subject { search_builder.except('foo') }
|
72
76
|
|
73
77
|
it "keeps the current_ability set" do
|
@@ -78,7 +82,6 @@ describe Blacklight::AccessControls::Enforcement do
|
|
78
82
|
describe "#append" do
|
79
83
|
let(:user) { build(:user) }
|
80
84
|
let(:ability) { Ability.new(user) }
|
81
|
-
before { search_builder.current_ability = ability }
|
82
85
|
subject { search_builder.append('foo') }
|
83
86
|
|
84
87
|
it "keeps the current_ability set" do
|
@@ -87,23 +90,25 @@ describe Blacklight::AccessControls::Enforcement do
|
|
87
90
|
end
|
88
91
|
|
89
92
|
describe "apply_gated_discovery" do
|
90
|
-
let(:user)
|
93
|
+
let(:user) do
|
94
|
+
create(:user).tap do |u|
|
95
|
+
allow(u).to receive(:groups) { groups }
|
96
|
+
end
|
97
|
+
end
|
91
98
|
let(:groups) { ["archivist","researcher"] }
|
92
99
|
|
93
100
|
before do
|
94
|
-
allow(user).to receive(:groups) { groups }
|
95
|
-
subject.current_ability = Ability.new(user)
|
96
101
|
@solr_parameters = {}
|
97
102
|
end
|
98
103
|
|
99
|
-
it "
|
104
|
+
it "sets query fields for the user id checking against the discover, read fields" do
|
100
105
|
subject.send(:apply_gated_discovery, @solr_parameters)
|
101
106
|
["discover","read"].each do |type|
|
102
107
|
expect(@solr_parameters[:fq].first).to match(/#{type}_access_person_ssim\:#{user.user_key}/)
|
103
108
|
end
|
104
109
|
end
|
105
110
|
|
106
|
-
it "
|
111
|
+
it "sets query fields for all roles the user is a member of checking against the discover, read fields" do
|
107
112
|
subject.send(:apply_gated_discovery, @solr_parameters)
|
108
113
|
["discover","read"].each do |type|
|
109
114
|
expect(@solr_parameters[:fq].first).to match(/#{type}_access_group_ssim\:archivist/)
|
@@ -150,21 +155,16 @@ describe Blacklight::AccessControls::Enforcement do
|
|
150
155
|
|
151
156
|
describe "apply_user_permissions" do
|
152
157
|
describe "when the user is a guest user (user key nil)" do
|
153
|
-
|
154
|
-
|
155
|
-
it "should not create filters" do
|
158
|
+
it "does not create filters" do
|
156
159
|
expect(subject.send(:apply_user_permissions, ["discover","read"])).to eq []
|
157
160
|
end
|
158
161
|
end
|
159
162
|
|
160
163
|
describe "when the user is a guest user (user key empty string)" do
|
161
164
|
let(:user) { User.new(email: '') }
|
162
|
-
|
163
|
-
|
164
|
-
it "should not create filters" do
|
165
|
+
it "does not create filters" do
|
165
166
|
expect(subject.send(:apply_user_permissions, ["discover","read"])).to eq []
|
166
167
|
end
|
167
168
|
end
|
168
169
|
end
|
169
|
-
|
170
170
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blacklight-access_controls
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Beer
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2016-
|
14
|
+
date: 2016-06-08 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: cancancan
|
@@ -41,6 +41,20 @@ dependencies:
|
|
41
41
|
- - "~>"
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
version: '6.0'
|
44
|
+
- !ruby/object:Gem::Dependency
|
45
|
+
name: deprecation
|
46
|
+
requirement: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - "~>"
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '1.0'
|
51
|
+
type: :runtime
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - "~>"
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '1.0'
|
44
58
|
- !ruby/object:Gem::Dependency
|
45
59
|
name: rake
|
46
60
|
requirement: !ruby/object:Gem::Requirement
|
@@ -250,7 +264,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
250
264
|
version: '0'
|
251
265
|
requirements: []
|
252
266
|
rubyforge_project:
|
253
|
-
rubygems_version: 2.
|
267
|
+
rubygems_version: 2.5.1
|
254
268
|
signing_key:
|
255
269
|
specification_version: 4
|
256
270
|
summary: Access controls for blacklight-based applications
|