url_signer 0.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/README.md +18 -0
- data/Rakefile +8 -0
- data/lib/url_signer/extensions/string.rb +13 -0
- data/lib/url_signer/extensions/uri.rb +24 -0
- data/lib/url_signer/version.rb +1 -1
- data/lib/url_signer.rb +5 -0
- data/spec/string_spec.rb +14 -0
- data/spec/uri_spec.rb +19 -0
- metadata +18 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56366ad2bd9634d9a762f6e0759dba5738656f18
|
4
|
+
data.tar.gz: 9917576c556cfe739a5c4a90a3a126041f86a665
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d38f39b64abaf780b9d366c399b359487772083a0c5f02b6b93c108c6414c233d11f824cc2a6ef4c536a36cbaa092a4f1102715ca3e5ad6d355968420f4d4c9d
|
7
|
+
data.tar.gz: 7f0c6eb90f44434f807c363048f686fb0d5a12343898111f3fbf010dad6a5b62614b4a3972c2fcf853f38d5998f0a5c2b2815b2e7a0869730d7028c36bdd184c
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
# UrlSign
|
2
|
+
[![Build Status](https://travis-ci.org/ushu/url_signer.svg?branch=master)](https://travis-ci.org/ushu/url_signer)
|
3
|
+
[![Code Climate](https://codeclimate.com/github/ushu/url_signer/badges/gpa.svg)](https://codeclimate.com/github/ushu/url_signer)
|
2
4
|
|
3
5
|
Quickly generate and verify signed urls.
|
4
6
|
|
@@ -39,6 +41,22 @@ Given a signed URL, you can check its authenticity by calling `UrlSigner.valid?`
|
|
39
41
|
true
|
40
42
|
```
|
41
43
|
|
44
|
+
### helper methods
|
45
|
+
|
46
|
+
The gem adds helper methods to <tt>String</tt> and <tt>URI</tt> classes:
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
# to generate a signed uri directly form a string
|
50
|
+
signed_url = 'http://google.fr'.to_signed_uri(key: 'test')
|
51
|
+
|
52
|
+
# or if we have a URI insance already
|
53
|
+
url = URI.parse('http://google.fr')
|
54
|
+
signed_url = url.signed(key: 'test')
|
55
|
+
|
56
|
+
# finally to check for signature authenticity
|
57
|
+
signed_url.signature_valid?(key: 'test')
|
58
|
+
```
|
59
|
+
|
42
60
|
## Contributing
|
43
61
|
|
44
62
|
1. Fork it ( https://github.com/[my-github-username]/url_sign/fork )
|
data/Rakefile
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'url_signer'
|
3
|
+
|
4
|
+
class String
|
5
|
+
|
6
|
+
# Return a signed <tt>URI</tt> form the current <tt>String</tt>.
|
7
|
+
#
|
8
|
+
# 'http://google.fr'.to_signed_uri # => <URI::HTTP...>
|
9
|
+
def to_signed_uri(*options)
|
10
|
+
UrlSigner.sign(self, *options)
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'url_signer'
|
3
|
+
|
4
|
+
module URI
|
5
|
+
class Generic
|
6
|
+
|
7
|
+
# Return a signed version of the <tt>URI</tt>.
|
8
|
+
#
|
9
|
+
# url = URI.parse('http://google.fr')
|
10
|
+
# signed_url = url.signed
|
11
|
+
def signed(*options)
|
12
|
+
UrlSigner.sign(self, *options)
|
13
|
+
end
|
14
|
+
|
15
|
+
# Checks the validity of the current <tt>URI</tt> signature.
|
16
|
+
#
|
17
|
+
# signed_url = URI.parse('http://google.fr').signed
|
18
|
+
# signed_url.signature_valid? # => true
|
19
|
+
def signature_valid?(*options)
|
20
|
+
UrlSigner.valid?(self, *options)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
data/lib/url_signer/version.rb
CHANGED
data/lib/url_signer.rb
CHANGED
data/spec/string_spec.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "String extension" do
|
4
|
+
let(:url_string) { 'http://google.fr' }
|
5
|
+
let(:url) { URI.parse(url_string) }
|
6
|
+
let(:signed_url) { UrlSigner.sign(url, key: 'toto') }
|
7
|
+
|
8
|
+
describe "#to_signed_uri" do
|
9
|
+
it "returns a signed version of the URI" do
|
10
|
+
expect(url_string.to_signed_uri(key: 'toto')).to eq(signed_url)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
end # URI extension
|
data/spec/uri_spec.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "URI extension" do
|
4
|
+
let(:url) { URI.parse('http://google.fr') }
|
5
|
+
let(:signed_url) { UrlSigner.sign(url, key: 'toto') }
|
6
|
+
|
7
|
+
describe "#signed" do
|
8
|
+
it "returns a signed version of the URI" do
|
9
|
+
expect(url.signed(key: 'toto')).to eq(signed_url)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#valid" do
|
14
|
+
it "returns true if the current url is signed" do
|
15
|
+
expect(signed_url.signature_valid?(key: 'toto')).to eq(true)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end # URI extension
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: url_signer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aurélien Noce
|
@@ -14,42 +14,42 @@ dependencies:
|
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.6'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '10.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '3.1'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.1'
|
55
55
|
description: Simple solution (2 methods) to sign URLs and verify the generated URLs.
|
@@ -60,19 +60,24 @@ executables: []
|
|
60
60
|
extensions: []
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
|
-
- .gitignore
|
63
|
+
- ".gitignore"
|
64
|
+
- ".travis.yml"
|
64
65
|
- Gemfile
|
65
66
|
- LICENSE.txt
|
66
67
|
- README.md
|
67
68
|
- Rakefile
|
68
69
|
- lib/url_signer.rb
|
69
70
|
- lib/url_signer/base.rb
|
71
|
+
- lib/url_signer/extensions/string.rb
|
72
|
+
- lib/url_signer/extensions/uri.rb
|
70
73
|
- lib/url_signer/signer.rb
|
71
74
|
- lib/url_signer/verifier.rb
|
72
75
|
- lib/url_signer/version.rb
|
73
76
|
- spec/base_spec.rb
|
74
77
|
- spec/signer_spec.rb
|
75
78
|
- spec/spec_helper.rb
|
79
|
+
- spec/string_spec.rb
|
80
|
+
- spec/uri_spec.rb
|
76
81
|
- spec/url_signer_spec.rb
|
77
82
|
- spec/verifier_spec.rb
|
78
83
|
- url_signer.gemspec
|
@@ -86,17 +91,17 @@ require_paths:
|
|
86
91
|
- lib
|
87
92
|
required_ruby_version: !ruby/object:Gem::Requirement
|
88
93
|
requirements:
|
89
|
-
- -
|
94
|
+
- - ">="
|
90
95
|
- !ruby/object:Gem::Version
|
91
96
|
version: '0'
|
92
97
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
98
|
requirements:
|
94
|
-
- -
|
99
|
+
- - ">="
|
95
100
|
- !ruby/object:Gem::Version
|
96
101
|
version: '0'
|
97
102
|
requirements: []
|
98
103
|
rubyforge_project:
|
99
|
-
rubygems_version: 2.
|
104
|
+
rubygems_version: 2.2.2
|
100
105
|
signing_key:
|
101
106
|
specification_version: 4
|
102
107
|
summary: Sign and verify URLs
|
@@ -104,6 +109,7 @@ test_files:
|
|
104
109
|
- spec/base_spec.rb
|
105
110
|
- spec/signer_spec.rb
|
106
111
|
- spec/spec_helper.rb
|
112
|
+
- spec/string_spec.rb
|
113
|
+
- spec/uri_spec.rb
|
107
114
|
- spec/url_signer_spec.rb
|
108
115
|
- spec/verifier_spec.rb
|
109
|
-
has_rdoc:
|