gcs-signer 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/gcs_signer.rb +6 -3
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a74dad977177130c33d5b0ba0ca0ead47b5c3a82
|
4
|
+
data.tar.gz: 7926bd9cb2d5d2f48af827afb5f1392555f6e4e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5188880d7e0d8abc3a7ae068714256a235f96f659be957866e3938dacfa9e7be20b0b7899b7aa717fdfa4b92566655c40c8eea706c1820bd5f0868e3dd856f8c
|
7
|
+
data.tar.gz: 975ee1df451b55e8a774a9cab6e7ffff22348310be3febca46db623fa5c390230681a86e4230c2b4276ecdde4948d252beaf4d807eec566e72ece403e4d1cd4b
|
data/lib/gcs_signer.rb
CHANGED
@@ -10,21 +10,24 @@ require "json"
|
|
10
10
|
# signer.sign "your-bucket", "object/name"
|
11
11
|
# # => "https://storage.googleapis.com/your-bucket/object/name?..."
|
12
12
|
class GcsSigner
|
13
|
-
VERSION = "0.1
|
13
|
+
VERSION = "0.2.1"
|
14
14
|
|
15
15
|
# gcs-signer requires credential that can access to GCS.
|
16
16
|
# [path] the path of the service_account json file.
|
17
17
|
# [json_string] ...or the content of the service_account json file.
|
18
|
+
# [gcs_host] Custom GCS host when signing a url.
|
18
19
|
#
|
19
20
|
# or if you also use \+google-cloud+ gem. you can authenticate
|
20
21
|
# using environment variable that uses.
|
21
|
-
def initialize(path: nil, json_string: nil)
|
22
|
+
def initialize(path: nil, json_string: nil, gcs_host: nil)
|
22
23
|
json_string ||= File.read(path) unless path.nil?
|
23
24
|
json_string = look_for_environment_variables if json_string.nil?
|
24
25
|
|
25
26
|
fail AuthError, "No credentials given." if json_string.nil?
|
26
27
|
@credentials = JSON.parse(json_string)
|
27
28
|
@key = OpenSSL::PKey::RSA.new(@credentials["private_key"])
|
29
|
+
|
30
|
+
@gcs_host = gcs_host || "https://storage.googleapis.com"
|
28
31
|
end
|
29
32
|
|
30
33
|
# @return [String] Signed url
|
@@ -58,7 +61,7 @@ class GcsSigner
|
|
58
61
|
def sign_url(bucket, object_name, options = {})
|
59
62
|
options = apply_default_options(options)
|
60
63
|
|
61
|
-
url = URI.join
|
64
|
+
url = URI.join @gcs_host,
|
62
65
|
URI.escape("/#{bucket}/"), URI.escape(object_name)
|
63
66
|
signature = sign string_that_will_be_signed(url, options)
|
64
67
|
url.query = query_for_signed_url(signature, options)
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gcs-signer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sangwon Yi
|
8
|
+
- Minku Lee
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2017-05-25 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: rake
|
@@ -57,6 +58,7 @@ description: |2
|
|
57
58
|
No additional gems and API requests required to generate signed URL.
|
58
59
|
email:
|
59
60
|
- sangwon@sha.kr
|
61
|
+
- minku@sha.kr
|
60
62
|
executables: []
|
61
63
|
extensions: []
|
62
64
|
extra_rdoc_files: []
|
@@ -83,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
85
|
version: '0'
|
84
86
|
requirements: []
|
85
87
|
rubyforge_project:
|
86
|
-
rubygems_version: 2.
|
88
|
+
rubygems_version: 2.6.10
|
87
89
|
signing_key:
|
88
90
|
specification_version: 4
|
89
91
|
summary: Simple signed URL generator for Google Cloud Storage.
|