peatio 0.4.1 → 0.4.2
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 +3 -0
- data/Gemfile.lock +1 -1
- data/lib/peatio/auth/jwt_authenticator.rb +24 -24
- data/lib/peatio/mq/events.rb +1 -1
- data/lib/peatio/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0571b3f094a51a7780a01511d2428918599c461c78620493099903613e88dd1
|
4
|
+
data.tar.gz: 8bd678a3af4dee0e3108a070bd6a0e2e3891f1330c6b7c2f1a726e3b0fc9e07b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a29628f6043f5d93a08126f1f6643bd0f280ce04bdd4e3635ada713292064a0515d043053b146ec2594c08679382ab709348c4ce1abcba3fde6e231d7d4f0cc
|
7
|
+
data.tar.gz: ba48681a96d5ec2b388a84efae83f6fc07de679bde9e3387da055eabc8e4fc9814ec58fcab848caea20e6732d2ef5b6180c92c34d1e7a9e77ad3771b1217761d
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -43,28 +43,6 @@ module Peatio::Auth
|
|
43
43
|
# auth = Peatio::Auth::JWTAuthenticator.new(rsa_public)
|
44
44
|
# auth.authenticate!("Bearer #{token}")
|
45
45
|
class JWTAuthenticator
|
46
|
-
@@verify_options = {
|
47
|
-
verify_expiration: true,
|
48
|
-
verify_not_before: true,
|
49
|
-
iss: ENV["JWT_ISSUER"],
|
50
|
-
verify_iss: !ENV["JWT_ISSUER"].nil?,
|
51
|
-
verify_iat: true,
|
52
|
-
verify_jti: true,
|
53
|
-
aud: ENV["JWT_AUDIENCE"].to_s.split(",").reject(&:empty?),
|
54
|
-
verify_aud: !ENV["JWT_AUDIENCE"].nil?,
|
55
|
-
sub: "session",
|
56
|
-
verify_sub: true,
|
57
|
-
algorithms: [ENV["JWT_ALGORITHM"] || "RS256"],
|
58
|
-
leeway: ENV["JWT_DEFAULT_LEEWAY"].yield_self { |n| n.to_i unless n.nil? },
|
59
|
-
iat_leeway: ENV["JWT_ISSUED_AT_LEEWAY"].yield_self { |n| n.to_i unless n.nil? },
|
60
|
-
exp_leeway: ENV["JWT_EXPIRATION_LEEWAY"].yield_self { |n| n.to_i unless n.nil? },
|
61
|
-
nbf_leeway: ENV["JWT_NOT_BEFORE_LEEWAY"].yield_self { |n| n.to_i unless n.nil? },
|
62
|
-
}.compact
|
63
|
-
|
64
|
-
@@encode_options = {
|
65
|
-
algorithm: @@verify_options[:algorithms].first,
|
66
|
-
}.compact
|
67
|
-
|
68
46
|
# Creates new authenticator with given public key.
|
69
47
|
#
|
70
48
|
# @param public_key [OpenSSL::PKey::PKey] Public key object to verify
|
@@ -74,6 +52,28 @@ module Peatio::Auth
|
|
74
52
|
def initialize(public_key, private_key = nil)
|
75
53
|
@public_key = public_key
|
76
54
|
@private_key = private_key
|
55
|
+
|
56
|
+
@verify_options = {
|
57
|
+
verify_expiration: true,
|
58
|
+
verify_not_before: true,
|
59
|
+
iss: ENV["JWT_ISSUER"],
|
60
|
+
verify_iss: !ENV["JWT_ISSUER"].nil?,
|
61
|
+
verify_iat: true,
|
62
|
+
verify_jti: true,
|
63
|
+
aud: ENV["JWT_AUDIENCE"].to_s.split(",").reject(&:empty?),
|
64
|
+
verify_aud: !ENV["JWT_AUDIENCE"].nil?,
|
65
|
+
sub: "session",
|
66
|
+
verify_sub: true,
|
67
|
+
algorithms: [ENV["JWT_ALGORITHM"] || "RS256"],
|
68
|
+
leeway: ENV["JWT_DEFAULT_LEEWAY"].yield_self { |n| n.to_i unless n.nil? },
|
69
|
+
iat_leeway: ENV["JWT_ISSUED_AT_LEEWAY"].yield_self { |n| n.to_i unless n.nil? },
|
70
|
+
exp_leeway: ENV["JWT_EXPIRATION_LEEWAY"].yield_self { |n| n.to_i unless n.nil? },
|
71
|
+
nbf_leeway: ENV["JWT_NOT_BEFORE_LEEWAY"].yield_self { |n| n.to_i unless n.nil? },
|
72
|
+
}.compact
|
73
|
+
|
74
|
+
@encode_options = {
|
75
|
+
algorithm: @verify_options[:algorithms].first,
|
76
|
+
}.compact
|
77
77
|
end
|
78
78
|
|
79
79
|
# Decodes and verifies JWT.
|
@@ -109,13 +109,13 @@ module Peatio::Auth
|
|
109
109
|
def encode(payload)
|
110
110
|
raise(::ArgumentError, "No private key given.") if @private_key.nil?
|
111
111
|
|
112
|
-
JWT.encode(payload, @private_key,
|
112
|
+
JWT.encode(payload, @private_key, @encode_options[:algorithm])
|
113
113
|
end
|
114
114
|
|
115
115
|
private
|
116
116
|
|
117
117
|
def decode_and_verify_token(token)
|
118
|
-
payload, header = JWT.decode(token, @public_key, true,
|
118
|
+
payload, header = JWT.decode(token, @public_key, true, @verify_options)
|
119
119
|
|
120
120
|
payload.keys.each { |k| payload[k.to_sym] = payload.delete(k) }
|
121
121
|
|
data/lib/peatio/mq/events.rb
CHANGED
data/lib/peatio/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: peatio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Louis B.
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-08-
|
12
|
+
date: 2018-08-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: clamp
|