X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/09a2e88c51e5432e607f2a38466e55b4ba15e887..0f537bcaa60b8a1496010bc9d4a943484e69081c:/services/api/app/models/blob.rb diff --git a/services/api/app/models/blob.rb b/services/api/app/models/blob.rb index 00c2501865..9f9a20fe33 100644 --- a/services/api/app/models/blob.rb +++ b/services/api/app/models/blob.rb @@ -1,3 +1,9 @@ +# Copyright (C) The Arvados Authors. All rights reserved. +# +# SPDX-License-Identifier: AGPL-3.0 + +require 'request_error' + class Blob extend DbCurrentTime @@ -21,8 +27,8 @@ class Blob # locator_hash +A blob_signature @ timestamp # where the timestamp is a Unix time expressed as a hexadecimal value, # and the blob_signature is the signed locator_hash + API token + timestamp. - # - class InvalidSignatureError < StandardError + # + class InvalidSignatureError < RequestError end # Blob.sign_locator: return a signed and timestamped blob locator. @@ -45,15 +51,15 @@ class Blob timestamp = opts[:expire] else timestamp = db_current_time.to_i + - (opts[:ttl] || Rails.configuration.blob_signature_ttl) + (opts[:ttl] || Rails.configuration.Collections.BlobSigningTTL.to_i) end timestamp_hex = timestamp.to_s(16) # => "53163cb4" - blob_signature_ttl = Rails.configuration.blob_signature_ttl.to_s(16) + blob_signature_ttl = Rails.configuration.Collections.BlobSigningTTL.to_i.to_s(16) # Generate a signature. signature = - generate_signature((opts[:key] or Rails.configuration.blob_signing_key), + generate_signature((opts[:key] or Rails.configuration.Collections.BlobSigningKey), blob_hash, opts[:api_token], timestamp_hex, blob_signature_ttl) blob_locator + '+A' + signature + '@' + timestamp_hex @@ -97,10 +103,10 @@ class Blob if timestamp.to_i(16) < (opts[:now] or db_current_time.to_i) raise Blob::InvalidSignatureError.new 'Signature expiry time has passed.' end - blob_signature_ttl = Rails.configuration.blob_signature_ttl.to_s(16) + blob_signature_ttl = Rails.configuration.Collections.BlobSigningTTL.to_i.to_s(16) my_signature = - generate_signature((opts[:key] or Rails.configuration.blob_signing_key), + generate_signature((opts[:key] or Rails.configuration.Collections.BlobSigningKey), blob_hash, opts[:api_token], timestamp, blob_signature_ttl) if my_signature != given_signature