wechat-validation 0.2 → 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/.gitignore +0 -1
- data/CHANGELOG.md +6 -2
- data/Gemfile.lock +39 -0
- data/README.md +21 -2
- data/ROADMAP.md +10 -2
- data/_config.yml +1 -0
- data/bin/console +3 -3
- data/lib/wechat/validation.rb +2 -0
- data/lib/wechat/validation/signature.rb +9 -1
- data/lib/wechat/validation/version.rb +1 -1
- data/wechat-validation.gemspec +4 -2
- metadata +19 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7e976d382b0682e853dfc2b5ca3300cf709ceef1
|
|
4
|
+
data.tar.gz: 78b7cce53115b76455f2c649e542a221917f0931
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 18fbf333ab842251899bce8e91ef54accd63f17856715e198c9b4a1d2f6c6767237409fed730e6a8df9460f318196667ffa420926b663e63ac5761b783b47d26
|
|
7
|
+
data.tar.gz: 96a68cb7b7ef16e86e363425204f2781586c5ea248155fc7a9abeccf39bf72d04f21f9e974c670d03dcc562388941d6deb7096fa374f155bf008f09ec6471088
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
# Wechat Validation Change Log 微信验证库变更日志
|
|
2
2
|
|
|
3
3
|
## v0.1
|
|
4
|
-
1. Wechat::Validation.sign method
|
|
4
|
+
1. Wechat::Validation.sign method
|
|
5
5
|
|
|
6
6
|
## v0.2
|
|
7
|
-
1. Deprecated the Wechat Validation ::sign method, use Wechat Validation Signature ::create instead
|
|
7
|
+
1. Deprecated the Wechat Validation ::sign method, use Wechat Validation Signature ::create instead
|
|
8
|
+
|
|
9
|
+
## v0.2.1
|
|
10
|
+
1. Improve the Ruby Gem Specification to depend on [wechat-core](https://github.com/topbitdu/wechat-core) v0.4
|
|
11
|
+
2. Improve the Signature class for the argument validation
|
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
wechat-validation (0.2.1)
|
|
5
|
+
wechat-core (>= 0.4)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
diff-lcs (1.2.5)
|
|
11
|
+
httpclient (2.8.2.4)
|
|
12
|
+
rake (10.5.0)
|
|
13
|
+
rspec (3.4.0)
|
|
14
|
+
rspec-core (~> 3.4.0)
|
|
15
|
+
rspec-expectations (~> 3.4.0)
|
|
16
|
+
rspec-mocks (~> 3.4.0)
|
|
17
|
+
rspec-core (3.4.4)
|
|
18
|
+
rspec-support (~> 3.4.0)
|
|
19
|
+
rspec-expectations (3.4.0)
|
|
20
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
21
|
+
rspec-support (~> 3.4.0)
|
|
22
|
+
rspec-mocks (3.4.1)
|
|
23
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
24
|
+
rspec-support (~> 3.4.0)
|
|
25
|
+
rspec-support (3.4.1)
|
|
26
|
+
wechat-core (0.4)
|
|
27
|
+
httpclient (>= 2.8)
|
|
28
|
+
|
|
29
|
+
PLATFORMS
|
|
30
|
+
ruby
|
|
31
|
+
|
|
32
|
+
DEPENDENCIES
|
|
33
|
+
bundler (~> 1.11)
|
|
34
|
+
rake (~> 10.0)
|
|
35
|
+
rspec (~> 3.0)
|
|
36
|
+
wechat-validation!
|
|
37
|
+
|
|
38
|
+
BUNDLED WITH
|
|
39
|
+
1.12.5
|
data/README.md
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
# Wechat Validation 微信服务器验证库
|
|
2
2
|
|
|
3
|
+
[](http://www.rubydoc.info/gems/wechat-validation/frames)
|
|
3
4
|
[](http://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
4
6
|
[](https://badge.fury.io/rb/wechat-validation)
|
|
7
|
+
[](https://gemnasium.com/github.com/topbitdu/wechat-validation)
|
|
5
8
|
|
|
6
9
|
The Wechat Server Validation Library is a code base for validating the HTTP server in Wechat.
|
|
7
10
|
微信服务器验证库用于处理[微信服务器验证请求](http://mp.weixin.qq.com/wiki/8/f9a0b8382e0b77d87b3bcc1ce6fbc104.html#.E7.AC.AC.E4.BA.8C.E6.AD.A5.EF.BC.9A.E9.AA.8C.E8.AF.81.E6.9C.8D.E5.8A.A1.E5.99.A8.E5.9C.B0.E5.9D.80.E7.9A.84.E6.9C.89.E6.95.88.E6.80.A7)。
|
|
8
11
|
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## Recent Update
|
|
15
|
+
|
|
16
|
+
Check out the [Road Map](ROADMAP.md) to find out what's the next.
|
|
17
|
+
Check out the [Change Log](CHANGELOG.md) to find out what's new.
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
9
21
|
## Installation
|
|
10
22
|
|
|
11
23
|
Add this line to your application's Gemfile:
|
|
@@ -22,28 +34,35 @@ Or install it yourself as:
|
|
|
22
34
|
|
|
23
35
|
$ gem install wechat-validation
|
|
24
36
|
|
|
37
|
+
|
|
38
|
+
|
|
25
39
|
## Usage
|
|
26
40
|
|
|
27
41
|
```ruby
|
|
28
|
-
actual_signature = ::Wechat::Validation.
|
|
42
|
+
actual_signature = ::Wechat::Validation::Signature.create(params[:nonce], params[:timestamp], Rails.application.secrets.wechat_validation_token)
|
|
29
43
|
if params[:signature]==actual_signature
|
|
30
44
|
# Correct
|
|
31
45
|
else
|
|
32
46
|
# Wrong
|
|
33
47
|
end
|
|
34
48
|
```
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
35
52
|
## Development
|
|
36
53
|
|
|
37
54
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
38
55
|
|
|
39
56
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
40
57
|
|
|
58
|
+
|
|
59
|
+
|
|
41
60
|
## Contributing
|
|
42
61
|
|
|
43
62
|
Bug reports and pull requests are welcome on GitHub at https://github.com/topbitdu/wechat-validation. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
44
63
|
|
|
45
64
|
|
|
65
|
+
|
|
46
66
|
## License
|
|
47
67
|
|
|
48
68
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
|
49
|
-
|
data/ROADMAP.md
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
# Wechat Validation Road Map 微信验证库路线图
|
|
2
2
|
|
|
3
3
|
## v0.1
|
|
4
|
-
1. Wechat::Validation.sign method
|
|
4
|
+
1. Wechat::Validation.sign method
|
|
5
5
|
|
|
6
6
|
## v0.2
|
|
7
|
-
1.
|
|
7
|
+
1. Improve the Wechat Validation to deprecate the ::sign method, use Wechat Validation Signature ::create instead
|
|
8
|
+
|
|
9
|
+
## v0.2.1
|
|
10
|
+
1. Improve the Ruby Gem Specification to depend on [wechat-core](https://github.com/topbitdu/wechat-core) v0.4
|
|
11
|
+
2. Improve the Signature class for the argument validation
|
|
12
|
+
|
|
13
|
+
## v1.0
|
|
14
|
+
1. Remove the deprecated classes & methods
|
|
15
|
+
2. Improve the Signature class for argument validation
|
data/_config.yml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
markdown: kramdown
|
data/bin/console
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
3
|
+
require 'bundler/setup'
|
|
4
|
+
require 'wechat/validation'
|
|
5
5
|
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
|
@@ -10,5 +10,5 @@ require "wechat/validation"
|
|
|
10
10
|
# require "pry"
|
|
11
11
|
# Pry.start
|
|
12
12
|
|
|
13
|
-
require
|
|
13
|
+
require 'irb'
|
|
14
14
|
IRB.start
|
data/lib/wechat/validation.rb
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
class Wechat::Validation::Signature
|
|
2
2
|
|
|
3
|
+
extend Wechat::Core::Common
|
|
4
|
+
|
|
3
5
|
# 验证服务器地址的有效性
|
|
4
6
|
# http://mp.weixin.qq.com/wiki/8/f9a0b8382e0b77d87b3bcc1ce6fbc104.html#.E7.AC.AC.E4.BA.8C.E6.AD.A5.EF.BC.9A.E9.AA.8C.E8.AF.81.E6.9C.8D.E5.8A.A1.E5.99.A8.E5.9C.B0.E5.9D.80.E7.9A.84.E6.9C.89.E6.95.88.E6.80.A7
|
|
5
7
|
#
|
|
@@ -10,7 +12,13 @@ class Wechat::Validation::Signature
|
|
|
10
12
|
# 2. 将三个参数字符串拼接成一个字符串进行sha1加密
|
|
11
13
|
# 3. 开发者获得加密后的字符串可与signature对比,标识该请求来源于微信
|
|
12
14
|
def self.create(nonce, timestamp, token)
|
|
13
|
-
|
|
15
|
+
|
|
16
|
+
assert_present! :nonce, nonce
|
|
17
|
+
assert_present! :timestamp, timestamp
|
|
18
|
+
assert_present! :token, token
|
|
19
|
+
|
|
20
|
+
Digest::SHA1.hexdigest [ nonce.to_s, timestamp.to_s, token.to_s ].sort.join
|
|
21
|
+
|
|
14
22
|
end
|
|
15
23
|
|
|
16
24
|
end
|
data/wechat-validation.gemspec
CHANGED
|
@@ -26,8 +26,10 @@ Gem::Specification.new do |spec|
|
|
|
26
26
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
27
27
|
spec.require_paths = [ 'lib' ]
|
|
28
28
|
|
|
29
|
+
spec.add_dependency 'wechat-core', '~> 0.4'
|
|
30
|
+
|
|
29
31
|
spec.add_development_dependency 'bundler', '~> 1.11'
|
|
30
|
-
spec.add_development_dependency 'rake',
|
|
31
|
-
spec.add_development_dependency 'rspec',
|
|
32
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
|
33
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
|
32
34
|
|
|
33
35
|
end
|
metadata
CHANGED
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: wechat-validation
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Topbit Du
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2017-01-12 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: wechat-core
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0.4'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0.4'
|
|
13
27
|
- !ruby/object:Gem::Dependency
|
|
14
28
|
name: bundler
|
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -66,10 +80,12 @@ files:
|
|
|
66
80
|
- CHANGELOG.md
|
|
67
81
|
- CODE_OF_CONDUCT.md
|
|
68
82
|
- Gemfile
|
|
83
|
+
- Gemfile.lock
|
|
69
84
|
- LICENSE.txt
|
|
70
85
|
- README.md
|
|
71
86
|
- ROADMAP.md
|
|
72
87
|
- Rakefile
|
|
88
|
+
- _config.yml
|
|
73
89
|
- bin/console
|
|
74
90
|
- bin/setup
|
|
75
91
|
- lib/wechat/validation.rb
|
|
@@ -96,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
96
112
|
version: '0'
|
|
97
113
|
requirements: []
|
|
98
114
|
rubyforge_project:
|
|
99
|
-
rubygems_version: 2.4
|
|
115
|
+
rubygems_version: 2.6.4
|
|
100
116
|
signing_key:
|
|
101
117
|
specification_version: 4
|
|
102
118
|
summary: Wechat Server Validation Library 微信服务器验证库
|