mumuki-bibliotheca 7.0.0 → 7.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0a62a41ccc466635f65a59f922897532792a11eb2211398ae421380da55a833d
4
- data.tar.gz: f6a09743749b10ff195df298ad6f49a7b959234325bcea012a4caa97e174d06a
3
+ metadata.gz: e35d3a87a2d214fdf4e8fed498cbc1db596483a12f268aed2d2efc3c57818de3
4
+ data.tar.gz: baed6fc210b41f298f3bbb1caaed7f2cf5713ae5b247b059a9a388674e059353
5
5
  SHA512:
6
- metadata.gz: d6ffc3539d2b88703b6bc4c87677306ef70a8431b22f7e24b51c57f186ec10bb9010c551bfe18861554824bea48cad0ae4a38993ae955b4b0c62b17307c52aca
7
- data.tar.gz: a954340293fcc9f01ac5f1423adb2b9af46691a347eec0dc075a1e0ec41ff2b252cadd377195d0216723f1b62ed3bdfe52230e1ec270c7c8c64e778924348b09
6
+ metadata.gz: 730a390c254515e9cfa6ded72ac16115636a4a801f19f350e7bf3bfd9f251acca827a32ff55f9ba8c3c1069d116f1060bae205a29edfc7fa7474e2933dd35e50
7
+ data.tar.gz: 429d7d7b7f631a3097db22a961ad45e73a1fb611800db2283f738ed8a218a6665f765a91af982f35e36e1eadec1e938efcca02512c10b75952f3eeb54c75b6d3
@@ -94,6 +94,10 @@ HTML
94
94
  halt 400
95
95
  end
96
96
 
97
+ error Mumuki::Domain::ForbiddenError do
98
+ halt 403
99
+ end
100
+
97
101
  options '*' do
98
102
  response.headers['Allow'] = settings.allow_methods.map { |it| it.to_s.upcase }.join(',')
99
103
  response.headers['Access-Control-Allow-Headers'] = 'X-Mumuki-Auth-Token, X-Requested-With, X-HTTP-Method-Override, Content-Type, Cache-Control, Accept, Authorization'
@@ -165,7 +169,7 @@ HTML
165
169
  end
166
170
 
167
171
  def permissions
168
- current_user.permissions
172
+ current_user&.permissions
169
173
  end
170
174
 
171
175
  def organizations_for(item)
@@ -174,6 +178,10 @@ HTML
174
178
  .accessible_as(current_user, :student)
175
179
  .map { |it| it.as_json(only: [:name]) }
176
180
  end
181
+
182
+ def validate_accessible!(subject)
183
+ authorize! :writer if subject.private?
184
+ end
177
185
  end
178
186
 
179
187
  post '/markdown' do
@@ -10,7 +10,7 @@ class Mumuki::Bibliotheca::App < Sinatra::Application
10
10
  end
11
11
 
12
12
  get '/books' do
13
- list_books Book.all
13
+ list_books Book.visible(permissions)
14
14
  end
15
15
 
16
16
  get '/books/writable' do
@@ -18,10 +18,12 @@ class Mumuki::Bibliotheca::App < Sinatra::Application
18
18
  end
19
19
 
20
20
  get '/books/:organization/:repository' do
21
+ validate_accessible! book
21
22
  book.to_resource_h
22
23
  end
23
24
 
24
25
  get '/books/:organization/:repository/organizations' do
26
+ validate_accessible! book
25
27
  organizations_for book
26
28
  end
27
29
 
@@ -14,11 +14,11 @@ class Mumuki::Bibliotheca::App < Sinatra::Application
14
14
  end
15
15
 
16
16
  get '/guides' do
17
- list_guides Guide.visible(current_user&.permissions)
17
+ list_guides Guide.visible(permissions)
18
18
  end
19
19
 
20
20
  get '/guides/writable' do
21
- list_guides Guide.allowed(current_user&.permissions)
21
+ list_guides Guide.allowed(permissions)
22
22
  end
23
23
 
24
24
  delete '/guides/:organization/:repository' do
@@ -26,14 +26,17 @@ class Mumuki::Bibliotheca::App < Sinatra::Application
26
26
  end
27
27
 
28
28
  get '/guides/:organization/:repository/markdown' do
29
+ validate_accessible! guide
29
30
  slice_guide_resource_h_for_api guide.to_markdownified_resource_h
30
31
  end
31
32
 
32
33
  get '/guides/:organization/:repository' do
34
+ validate_accessible! guide
33
35
  slice_guide_resource_h_for_api guide.to_resource_h
34
36
  end
35
37
 
36
38
  get '/guides/:organization/:repository/organizations' do
39
+ validate_accessible! guide
37
40
  organizations_for guide
38
41
  end
39
42
 
@@ -50,6 +53,7 @@ class Mumuki::Bibliotheca::App < Sinatra::Application
50
53
  end
51
54
 
52
55
  post '/guides/:organization/:repository/assets' do
56
+ authorize! :writer
53
57
  Mumuki::Bibliotheca.upload_asset! slug, json_body['filename'], json_body['content']
54
58
  end
55
59
 
@@ -10,7 +10,7 @@ class Mumuki::Bibliotheca::App < Sinatra::Application
10
10
  end
11
11
 
12
12
  get '/topics' do
13
- list_topics Topic.all
13
+ list_topics Topic.visible(permissions)
14
14
  end
15
15
 
16
16
  get '/topics/writable' do
@@ -18,10 +18,12 @@ class Mumuki::Bibliotheca::App < Sinatra::Application
18
18
  end
19
19
 
20
20
  get '/topics/:organization/:repository' do
21
+ validate_accessible! topic
21
22
  topic.to_resource_h
22
23
  end
23
24
 
24
25
  get '/topics/:organization/:repository/organizations' do
26
+ validate_accessible! topic
25
27
  organizations_for topic
26
28
  end
27
29
 
@@ -1,5 +1,5 @@
1
1
  module Mumuki
2
2
  module Bibliotheca
3
- VERSION = '7.0.0'
3
+ VERSION = '7.5.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mumuki-bibliotheca
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.0
4
+ version: 7.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Franco Bulgarelli
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-25 00:00:00.000000000 Z
11
+ date: 2020-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 7.0.0
75
+ version: 7.5.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 7.0.0
82
+ version: 7.5.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: mumukit-login
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '1.0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: sprockets
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '3.7'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '3.7'
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: rack
127
141
  requirement: !ruby/object:Gem::Requirement