lsst-git-lfs-s3 0.3.1 → 0.3.2

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
  SHA1:
3
- metadata.gz: c281e6b4092827cee2ff392f15e5edfcd87e5a54
4
- data.tar.gz: b17910a8176a51e1be82853e7cf68dde2f145abc
3
+ metadata.gz: 87a60c4fc9a10e630a5dd87eb4a47bdb9d9b02e3
4
+ data.tar.gz: d784db052f045fd9285c0e9521f03d0c8e3be558
5
5
  SHA512:
6
- metadata.gz: ea4536a92be8d1a73173de01f92ac1efc0d95c08b6f035a8544902fca1895d76b1342bcd575f82cd8f49df0b5a079e852810d1e1aab0ca93c0f8c01dae268469
7
- data.tar.gz: a20908659964e73b8452aba86ff4afe0a43181c3f9547dc6e587594cc40d6a4ffb967c27c87bbd1a0f7b7e0023a3315ab3aabc8642976fe6d94fab25d9dc8716
6
+ metadata.gz: 2d31f5b993a19bb8ffbeee5ba0e8ca481485984a8e52ef6adc56088100bdf520f58f09ff2c206af3465f381062a6976146a383e045eeab999a143193c26db85c
7
+ data.tar.gz: 02cdb618456dec8c3a57d792b6ba6e05bd0c682580642975cd37a2142076e0c0a836efaa9659b4bfb14a4cf2f08675d12a5a41f714bc59310cde4f287eec92d1
@@ -176,7 +176,9 @@ module GitLfsS3
176
176
  params = indifferent_params(JSON.parse(request.body.read))
177
177
  logger.debug params
178
178
  if params[:operation] == 'download'
179
- lfs_resp(download(authenticated, params))
179
+ if settings.public_server
180
+ lfs_resp(download(authenticated, params))
181
+ end
180
182
  elsif params[:operation] == 'upload'
181
183
  if authenticated
182
184
  lfs_resp(upload(authenticated, params))
@@ -189,28 +191,30 @@ module GitLfsS3
189
191
  end
190
192
 
191
193
  get "/objects/:oid", provides: 'application/vnd.git-lfs+json' do
192
- object = object_data(params[:oid])
193
-
194
- if object.exists?
195
- status 200
196
- resp = {
197
- 'oid' => params[:oid],
198
- 'size' => object.size,
199
- '_links' => {
200
- 'self' => {
201
- 'href' => File.join(settings.server_url, 'objects', params[:oid])
202
- },
203
- 'download' => {
204
- # TODO: cloudfront support
205
- 'href' => object_data(params[:oid]).presigned_url(:get)
194
+ if settings.public_server
195
+ object = object_data(params[:oid])
196
+ if object.exists?
197
+ status 200
198
+ resp = {
199
+ 'oid' => params[:oid],
200
+ 'size' => object.size,
201
+ '_links' => {
202
+ 'self' => {
203
+ 'href' => File.join(settings.server_url, 'objects', params[:oid])
204
+ },
205
+ 'download' => {
206
+ 'href' => object_data(params[:oid]).presigned_url(:get)
207
+ }
206
208
  }
207
209
  }
208
- }
209
-
210
- body MultiJson.dump(resp)
210
+ body MultiJson.dump(resp)
211
+ else
212
+ status 404
213
+ body MultiJson.dump({message: 'Object not found'})
214
+ end
211
215
  else
212
- status 404
213
- body MultiJson.dump({message: 'Object not found'})
216
+ status 401
217
+ body MultiJson.dump({message: 'Invalid username or password'})
214
218
  end
215
219
  end
216
220
 
@@ -221,33 +225,38 @@ module GitLfsS3
221
225
  Aws::S3::Types::Grant.new(grantee: grantee, permission: "READ")
222
226
  end
223
227
 
224
- before do
225
- pass if request.safe? and settings.public_server
226
- protected!
227
- end
228
-
229
228
  post "/objects", provides: 'application/vnd.git-lfs+json' do
230
- logger.debug headers.inspect
231
- service = UploadService.service_for(request.body)
232
- logger.debug service.response
233
-
234
- status service.status
235
- body MultiJson.dump(service.response)
229
+ if authorized?
230
+ logger.debug headers.inspect
231
+ service = UploadService.service_for(request.body)
232
+ logger.debug service.response
233
+
234
+ status service.status
235
+ body MultiJson.dump(service.response)
236
+ else
237
+ status 401
238
+ body MultiJson.dump({message: 'Invalid username or password'})
239
+ end
236
240
  end
237
241
 
238
242
  post '/verify', provides: 'application/vnd.git-lfs+json' do
239
- data = MultiJson.load(request.body.tap { |b| b.rewind }.read)
240
- object = object_data(data['oid'])
241
- if not object.exists?
242
- status 404
243
- end
244
- if settings.public_server and settings.ceph_s3
245
- if not object.acl.grants.include?(public_read_grant)
246
- object.acl.put(acl: "public-read")
243
+ if authorized?
244
+ data = MultiJson.load(request.body.tap { |b| b.rewind }.read)
245
+ object = object_data(data['oid'])
246
+ if not object.exists?
247
+ status 404
247
248
  end
248
- end
249
- if object.size == data['size']
250
- status 200
249
+ if settings.public_server and settings.ceph_s3
250
+ if not object.acl.grants.include?(public_read_grant)
251
+ object.acl.put(acl: "public-read")
252
+ end
253
+ end
254
+ if object.size == data['size']
255
+ status 200
256
+ end
257
+ else
258
+ status 401
259
+ body MultiJson.dump({message: 'Invalid username or password'})
251
260
  end
252
261
  end
253
262
  end
@@ -1,3 +1,3 @@
1
1
  module GitLfsS3
2
- VERSION = '0.3.1'
2
+ VERSION = '0.3.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lsst-git-lfs-s3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan LeFevre
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-02-02 00:00:00.000000000 Z
12
+ date: 2017-02-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aws-sdk