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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b32339eba13b7179d18eeca7a1517c968284e48757527af84e15d81b004d662b
4
- data.tar.gz: 1577ff856ca266d0a18224d1ba70809d407ab263ad4f4807252ffb1e3d5a9e3e
3
+ metadata.gz: a0571b3f094a51a7780a01511d2428918599c461c78620493099903613e88dd1
4
+ data.tar.gz: 8bd678a3af4dee0e3108a070bd6a0e2e3891f1330c6b7c2f1a726e3b0fc9e07b
5
5
  SHA512:
6
- metadata.gz: 5b50ef26806f1fd35cc6be9b9e19b1300a5ea84364fa4f1708be37ed83cedfb8ea3e61746db4e8e8154685792624ef31f3dc19a247437f3645dc80ef5cec28d0
7
- data.tar.gz: f92147b4dd5011c7439c247b7e55de5b032c4fb4d6a69bc88f25230e9fb04e2f016aae2aee6c4ea749208245ec183cdfc4e6ef9020217d0a2fce51dc83e5556f
6
+ metadata.gz: 0a29628f6043f5d93a08126f1f6643bd0f280ce04bdd4e3635ada713292064a0515d043053b146ec2594c08679382ab709348c4ce1abcba3fde6e231d7d4f0cc
7
+ data.tar.gz: ba48681a96d5ec2b388a84efae83f6fc07de679bde9e3387da055eabc8e4fc9814ec58fcab848caea20e6732d2ef5b6180c92c34d1e7a9e77ad3771b1217761d
data/.gitignore CHANGED
@@ -10,3 +10,6 @@
10
10
 
11
11
  # rspec failure tracking
12
12
  .rspec_status
13
+
14
+ # Ignore RubyMine files
15
+ .idea
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- peatio (0.4.1)
4
+ peatio (0.4.2)
5
5
  amqp
6
6
  bunny
7
7
  clamp
@@ -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, @@encode_options[:algorithm])
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, @@verify_options)
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
 
@@ -54,7 +54,7 @@ module Peatio::MQ::Events
54
54
  attr_accessor :exchange_name
55
55
 
56
56
  def initialize
57
- @exchange_name = "peatio.events.market"
57
+ @exchange_name = "peatio.events.ranger"
58
58
  end
59
59
 
60
60
  def connect!
@@ -1,3 +1,3 @@
1
1
  module Peatio
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
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.1
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-27 00:00:00.000000000 Z
12
+ date: 2018-08-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: clamp