oo_auth 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: f44e251363fa6a3e04af50dbc4d52679750ea2c1
4
- data.tar.gz: ad34af2268abd94cda65a31c06c32d2530b6bc88
2
+ SHA256:
3
+ metadata.gz: 0e3c25ecc07c0f5e8a9bb658923875e6752758f47e1bd8853a96600f7f0f5037
4
+ data.tar.gz: b9ef1572c7a6debae566c0ecdb890a7a45c9c7014ea0f2b38e3778d87d9fa90c
5
5
  SHA512:
6
- metadata.gz: 59e9c9926872c7efaa36e45a6098692ade3417ba335b6b5f3eb186bcefd5a7da953366b89aad2122c08f4bc2b628288e507ff8b64bce735b4e9a695301dafb72
7
- data.tar.gz: 4e393b44327a8c313310b5c69226f776e83d1d027d4168e18769e2f0deec6e03f44ea0883425ee284168872d26a02b9d0f1b934632bbb037acfbd61827296e50
6
+ metadata.gz: cd0feb225e94f8f7fc260f10ffc628b5d8d5f5482a7158670cd7e1dd0a0a9e51fa24227b71ff94eaa0bf62732f4ab80ad2d138c7b12d3f53615f38fbb474721e
7
+ data.tar.gz: 47aca33e5594764cf1759b392930fd0ab6e0c7507c7a2e6b6c68659309713e43b094eb016f50b896ffc3617a070ceabf2e460b35607111489e6441ea38174921
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Gem Version](https://badge.fury.io/rb/oo_auth.png)](http://badge.fury.io/rb/oo_auth) [![Code Climate](https://codeclimate.com/github/mtgrosser/oo_auth.png)](https://codeclimate.com/github/mtgrosser/oo_auth)
1
+ [![Gem Version](https://badge.fury.io/rb/oo_auth.png)](http://badge.fury.io/rb/oo_auth) [![build](https://github.com/mtgrosser/oo_auth/actions/workflows/build.yml/badge.svg)](https://github.com/mtgrosser/oo_auth/actions/workflows/build.yml) [![Code Climate](https://codeclimate.com/github/mtgrosser/oo_auth.png)](https://codeclimate.com/github/mtgrosser/oo_auth)
2
2
 
3
3
  # oo_auth
4
4
 
@@ -3,15 +3,14 @@ module OoAuth
3
3
  class RedisStore < AbstractStore
4
4
  attr_reader :redis, :namespace, :ttl
5
5
 
6
- def initialize(options = {})
7
- options.symbolize_keys!
6
+ def initialize(**options)
8
7
  @namespace = options.delete(:namespace)
9
8
  @ttl = options.delete(:ttl) || 15.minutes
10
- @redis = Redis.new(options)
9
+ @redis = Redis.new(**options)
11
10
  end
12
11
 
13
12
  def remember(nonce)
14
- return nonce if @redis.set(key(nonce), '1', { nx: true, ex: ttl })
13
+ return nonce if @redis.set(key(nonce), '1', nx: true, ex: ttl)
15
14
  false
16
15
  rescue Errno::ECONNREFUSED
17
16
  false
@@ -21,8 +20,8 @@ module OoAuth
21
20
 
22
21
  def key(nonce)
23
22
  "#{@namespace}:oo_auth_nonce:#{nonce.timestamp}:#{nonce.value}"
24
- end
23
+ end
25
24
 
26
25
  end
27
26
  end
28
- end
27
+ end
@@ -18,7 +18,7 @@ module OoAuth
18
18
  header = header.to_s
19
19
  return unless header.start_with?('OAuth ')
20
20
  # decompose
21
- params = header[6, header.length].split(',').inject({}) do |hsh, str|
21
+ header[6, header.length].split(',').inject({}) do |hsh, str|
22
22
  key, value = str.split('=').map { |s| OoAuth.unescape(s.strip) }
23
23
  if PARAMETERS.include?(key)
24
24
  hsh[key] = value.sub(/^\"(.*)\"$/, '\1')
@@ -1,3 +1,3 @@
1
1
  module OoAuth
2
- VERSION = '1.0.1'
2
+ VERSION = '1.1.0'
3
3
  end
data/lib/oo_auth.rb CHANGED
@@ -78,13 +78,13 @@ module OoAuth
78
78
  #
79
79
  # See Also: {OAuth core spec version 1.0, section 5.1}[http://oauth.net/core/1.0#rfc.section.5.1]
80
80
  def escape(value)
81
- URI.escape(value.to_s, RESERVED_CHARACTERS)
81
+ uri_escape(value.to_s)
82
82
  rescue ArgumentError
83
- URI.escape(value.to_s.force_encoding(Encoding::UTF_8), RESERVED_CHARACTERS)
83
+ uri_escape(value.to_s.force_encoding(Encoding::UTF_8))
84
84
  end
85
85
 
86
86
  def unescape(value)
87
- URI.unescape(value.gsub('+', '%2B'))
87
+ URI.decode_www_form_component(value.gsub('+', '%2B'))
88
88
  end
89
89
 
90
90
  # cf. http://tools.ietf.org/html/rfc5849#section-3.4.1.1
@@ -109,21 +109,29 @@ module OoAuth
109
109
  end
110
110
 
111
111
  # Use this to sign Net::HTTP or ActionDispatch requests
112
- def sign!(*args)
112
+ def sign!(*args, **kwargs)
113
113
  credentials = args.pop
114
- proxy = RequestProxy.new(*args)
114
+ proxy = RequestProxy.new(*args, **kwargs)
115
115
  Signature.sign!(proxy, credentials)
116
116
  end
117
117
 
118
118
  # Use this in your controllers to verify the OAuth signature
119
119
  # of a request.
120
- def authorize!(*args)
121
- proxy = RequestProxy.new(*args)
120
+ def authorize!(...)
121
+ proxy = RequestProxy.new(...)
122
122
  return unless authorization = self.authorization(proxy.consumer_key, proxy.token)
123
123
  return unless Signature.verify!(proxy, authorization.credentials)
124
124
  authorization
125
125
  end
126
126
 
127
+ private
128
+
129
+ def uri_escape(string)
130
+ encoding = string.encoding
131
+ string.b.gsub(RESERVED_CHARACTERS) { |m|
132
+ '%' + m.unpack('H2' * m.bytesize).join('%').upcase }.force_encoding(encoding)
133
+ end
134
+
127
135
  end
128
136
 
129
137
  end
metadata CHANGED
@@ -1,92 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oo_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthias Grosser
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-16 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: byebug
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: simplecov
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: rake
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: 0.8.7
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: 0.8.7
55
- - !ruby/object:Gem::Dependency
56
- name: minitest
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '4.7'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '4.7'
69
- - !ruby/object:Gem::Dependency
70
- name: timecop
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: 0.6.3
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: 0.6.3
11
+ date: 2023-05-25 00:00:00.000000000 Z
12
+ dependencies: []
83
13
  description: Out Of Band OAuth
84
14
  email: mtgrosser@gmx.net
85
15
  executables: []
86
16
  extensions: []
87
17
  extra_rdoc_files: []
88
18
  files:
89
- - CHANGELOG
90
19
  - LICENSE
91
20
  - README.md
92
21
  - lib/oo_auth.rb
@@ -103,7 +32,7 @@ homepage: http://github.com/mtgrosser/oo_auth
103
32
  licenses:
104
33
  - MIT
105
34
  metadata: {}
106
- post_install_message:
35
+ post_install_message:
107
36
  rdoc_options: []
108
37
  require_paths:
109
38
  - lib
@@ -111,16 +40,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
111
40
  requirements:
112
41
  - - ">="
113
42
  - !ruby/object:Gem::Version
114
- version: '2.0'
43
+ version: '3.0'
115
44
  required_rubygems_version: !ruby/object:Gem::Requirement
116
45
  requirements:
117
46
  - - ">="
118
47
  - !ruby/object:Gem::Version
119
48
  version: '0'
120
49
  requirements: []
121
- rubyforge_project:
122
- rubygems_version: 2.4.5.1
123
- signing_key:
50
+ rubygems_version: 3.3.26
51
+ signing_key:
124
52
  specification_version: 4
125
53
  summary: OAuth without the callbacks
126
54
  test_files: []
data/CHANGELOG DELETED
@@ -1,7 +0,0 @@
1
- 1.0.0 - 2015-11-16
2
-
3
- * Support HMAC-SHA256
4
-
5
- 0.0.1 - 2013-11-06
6
-
7
- * First release