signet 0.11.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +47 -36
- data/Gemfile +5 -4
- data/README.md +4 -5
- data/Rakefile +86 -37
- data/lib/signet.rb +17 -14
- data/lib/signet/errors.rb +4 -4
- data/lib/signet/oauth_1.rb +128 -153
- data/lib/signet/oauth_1/client.rb +309 -343
- data/lib/signet/oauth_1/credential.rb +40 -37
- data/lib/signet/oauth_1/server.rb +197 -203
- data/lib/signet/oauth_1/signature_methods/hmac_sha1.rb +11 -10
- data/lib/signet/oauth_1/signature_methods/plaintext.rb +8 -7
- data/lib/signet/oauth_1/signature_methods/rsa_sha1.rb +11 -11
- data/lib/signet/oauth_2.rb +41 -43
- data/lib/signet/oauth_2/client.rb +302 -313
- data/lib/signet/version.rb +2 -73
- data/signet.gemspec +37 -39
- data/spec/signet/oauth_1/client_spec.rb +313 -315
- data/spec/signet/oauth_1/credential_spec.rb +64 -56
- data/spec/signet/oauth_1/server_spec.rb +362 -362
- data/spec/signet/oauth_1/signature_methods/hmac_sha1_spec.rb +26 -26
- data/spec/signet/oauth_1/signature_methods/plaintext_spec.rb +28 -28
- data/spec/signet/oauth_1/signature_methods/rsa_sha1_spec.rb +34 -35
- data/spec/signet/oauth_1_spec.rb +527 -524
- data/spec/signet/oauth_2/client_spec.rb +612 -576
- data/spec/signet/oauth_2_spec.rb +88 -89
- data/spec/signet_spec.rb +41 -41
- data/spec/spec_helper.rb +7 -7
- data/spec/spec_helper_spec.rb +8 -8
- metadata +50 -43
- data/tasks/clobber.rake +0 -2
- data/tasks/gem.rake +0 -34
- data/tasks/git.rake +0 -40
- data/tasks/metrics.rake +0 -41
- data/tasks/spec.rake +0 -34
- data/tasks/wiki.rake +0 -38
- data/tasks/yard.rake +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c80485d96774a5d31447471f38ed3f976ed3cbc751f26d9758798adee4e3fced
|
4
|
+
data.tar.gz: 70a563487e412a15c01799c09ec1fed027152e024053272c15858743cf4a58ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e004219f1e71c272772bb4892574d8bcc2725fc8f3fb0b474612839661f0a272400ffff50149499b27f91d6287aaeb41fe1065d7bd2652a0f58cdd9f2f12e1da
|
7
|
+
data.tar.gz: 046c9e719091f1f8d17fc324762558b2e6cb00d9b74c0ad66ec4da5bda5d8ba2a2ba6f2e070baacd6af2853d2ca30c1ea198c8ec59bb6fcdf9f63ac11929df9c
|
data/CHANGELOG.md
CHANGED
@@ -1,27 +1,38 @@
|
|
1
|
-
|
1
|
+
### 0.12.0 / 2019-10-08
|
2
|
+
|
3
|
+
* This version now requires Ruby 2.4.
|
4
|
+
* Support array values of the "aud" field.
|
5
|
+
* Normalize the version constant to match related gems.
|
6
|
+
|
7
|
+
### 0.11.0 / 2018-10-08
|
8
|
+
|
2
9
|
* Add constant time comparison for oauth signatures.
|
3
10
|
|
4
|
-
|
11
|
+
### 0.10.0 / 2018-09-21
|
12
|
+
|
5
13
|
* Add UnexpectedStatusError class for http status errors that are not handled.
|
6
14
|
|
7
|
-
|
15
|
+
### 0.9.2 / 2018-09-12
|
16
|
+
|
8
17
|
* Update issued_at correctly when it is set simultaneously with expires_in.
|
9
18
|
|
10
|
-
|
19
|
+
### 0.9.1 / 2018-08-29
|
20
|
+
|
11
21
|
* Warn on EOL ruby versions.
|
12
22
|
* Fix DateTime normalization.
|
13
23
|
|
14
|
-
|
24
|
+
### 0.9.0 / 2018-08-20
|
25
|
+
|
15
26
|
* Add RemoteServerError class for 5xx level errors.
|
16
27
|
* Allow to_json to be called with arguments
|
17
28
|
* Expires_in now sets and reflects current expires_at value
|
18
29
|
* Expires_within(0) now returns false when expires_at is nil.
|
19
30
|
|
20
|
-
|
31
|
+
### 0.8.1 / 2017-10-13
|
21
32
|
|
22
33
|
* Restore support for Ruby 1.9.3
|
23
34
|
|
24
|
-
|
35
|
+
### 0.8.0 / 2017-10-12
|
25
36
|
|
26
37
|
* Ensure the "expires_at" attribute is recalculated on refresh (chutzimir)
|
27
38
|
* Fix warnings on Ruby 2.4 (koic)
|
@@ -29,20 +40,20 @@
|
|
29
40
|
* Provide signature verification algorithm for compatibility with ruby-jwt 2.0 (jurriaan)
|
30
41
|
* Signet::OAuth2::Client#decoded_id_token can take a keyfinder block (mvastola)
|
31
42
|
|
32
|
-
|
43
|
+
### 0.7.3 / 2016-06-20
|
33
44
|
|
34
45
|
* Fix timestamp parsing on 32-bit systems
|
35
46
|
* Fix expiration check when issue/expiry times are nil
|
36
47
|
|
37
|
-
|
48
|
+
### 0.7.2 / 2015-12-21
|
38
49
|
|
39
50
|
* Don't assume Faraday form encoding middleware is present
|
40
51
|
|
41
|
-
|
52
|
+
### 0.7.1 / 2015-12-17
|
42
53
|
|
43
54
|
* Fix an issue with date parsing
|
44
55
|
|
45
|
-
|
56
|
+
### 0.7 / 2015-12-06
|
46
57
|
|
47
58
|
* No longer overwrite SSL environment variables.
|
48
59
|
* Tighten up date & URL (de)serialization for OAuth2 client
|
@@ -51,7 +62,7 @@
|
|
51
62
|
* Add expires_within(sec) method to oauth2 client to facilitate proactive
|
52
63
|
refreshes
|
53
64
|
|
54
|
-
|
65
|
+
### 0.6.1 / 2015-06-08
|
55
66
|
|
56
67
|
* Fix language warnings for unused & shadowed variables ((@blowmage)[])
|
57
68
|
* Update SSL cert path for OSX ((@gambaroff)[])
|
@@ -59,14 +70,14 @@
|
|
59
70
|
* Fix incorrect parameter name in OAuth2 client docs ((@samuelreh)[])
|
60
71
|
* Fix symbolization of URL parameter keys ((@swifthand)[])
|
61
72
|
|
62
|
-
|
73
|
+
### 0.6.0 / 2014-12-05
|
63
74
|
|
64
75
|
* Drop support for ruby versions < 1.9.3
|
65
76
|
* Update gem dependencies and lock down versions tighter
|
66
77
|
* Allow form encoded responses when exchanging OAuth 2 authorization codes
|
67
78
|
* Normalize options keys for indifferent access
|
68
79
|
|
69
|
-
|
80
|
+
### 0.5.1 / 2014-06-08
|
70
81
|
|
71
82
|
* Allow Hash objects to be used to initialize authorization URI
|
72
83
|
* Added PLAINTEXT and RSA-SHA1 signature methods to OAuth 1 support
|
@@ -74,53 +85,53 @@
|
|
74
85
|
* The `approval_prompt` option no longer defaults to `:force`
|
75
86
|
* The `approval_prompt` and `prompt` are now mutually exclusive.
|
76
87
|
|
77
|
-
|
88
|
+
### 0.5.0 / 2013-05-31
|
78
89
|
|
79
90
|
* Switched to faraday 0.9.0
|
80
91
|
* Added `expires_at` option
|
81
92
|
|
82
|
-
|
93
|
+
### 0.4.5
|
83
94
|
|
84
95
|
* Minor documentation fixes
|
85
96
|
* Allow postmessage as a valid redirect_uri in OAuth 2
|
86
97
|
|
87
|
-
|
98
|
+
### 0.4.4
|
88
99
|
|
89
100
|
* Add support for assertion profile
|
90
101
|
|
91
|
-
|
102
|
+
### 0.4.3
|
92
103
|
|
93
104
|
* Added method to clear credentials
|
94
105
|
|
95
|
-
|
106
|
+
### 0.4.2
|
96
107
|
|
97
108
|
* Backwards compatibility for MultiJson
|
98
109
|
|
99
|
-
|
110
|
+
### 0.4.1
|
100
111
|
|
101
112
|
* Updated Launchy dependency
|
102
113
|
|
103
|
-
|
114
|
+
### 0.4.0
|
104
115
|
|
105
116
|
* Added OAuth 1 server implementation
|
106
117
|
* Updated Faraday dependency
|
107
118
|
|
108
|
-
|
119
|
+
### 0.3.4
|
109
120
|
|
110
121
|
* Attempts to auto-detect CA cert location
|
111
122
|
|
112
|
-
|
123
|
+
### 0.3.3
|
113
124
|
|
114
125
|
* Request objects no longer recreated during processing
|
115
126
|
* Faraday middleware now supported
|
116
127
|
* Streamed requests now supported
|
117
128
|
* Fixed assertion profiles; client ID/secret omission no longer an error
|
118
129
|
|
119
|
-
|
130
|
+
### 0.3.2
|
120
131
|
|
121
132
|
* Added audience security check for ID tokens
|
122
133
|
|
123
|
-
|
134
|
+
### 0.3.1
|
124
135
|
|
125
136
|
* Fixed a warning while determining grant type
|
126
137
|
* Removed requirement that a connection be supplied when authorizing requests
|
@@ -128,52 +139,52 @@
|
|
128
139
|
* Fixed some documentation stuff around markdown formatting
|
129
140
|
* Added support for Google Code wiki format output when generating docs
|
130
141
|
|
131
|
-
|
142
|
+
### 0.3.0
|
132
143
|
|
133
144
|
* Replaced httpadapter gem dependency with faraday
|
134
145
|
* Replaced json gem dependency with multi_json
|
135
146
|
* Updated to OAuth 2.0 draft 22
|
136
147
|
* Complete test coverage
|
137
148
|
|
138
|
-
|
149
|
+
### 0.2.4
|
139
150
|
|
140
151
|
* Updated to incorporate changes to the Google OAuth endpoints
|
141
152
|
|
142
|
-
|
153
|
+
### 0.2.3
|
143
154
|
|
144
155
|
* Added support for JWT-formatted ID tokens.
|
145
156
|
* Added :issued_at option to #update_token! method.
|
146
157
|
|
147
|
-
|
158
|
+
### 0.2.2
|
148
159
|
|
149
160
|
* Lowered requirements for json gem
|
150
161
|
|
151
|
-
|
162
|
+
### 0.2.1
|
152
163
|
|
153
164
|
* Updated to keep in sync with the new httpadapter changes
|
154
165
|
|
155
|
-
|
166
|
+
### 0.2.0
|
156
167
|
|
157
168
|
* Added support for OAuth 2.0 draft 10
|
158
169
|
|
159
|
-
|
170
|
+
### 0.1.4
|
160
171
|
|
161
172
|
* Added support for a two-legged authorization flow
|
162
173
|
|
163
|
-
|
174
|
+
### 0.1.3
|
164
175
|
|
165
176
|
* Fixed issue with headers passed in as a Hash
|
166
177
|
* Fixed incompatibilities with Ruby 1.8.6
|
167
178
|
|
168
|
-
|
179
|
+
### 0.1.2
|
169
180
|
|
170
181
|
* Fixed bug with overzealous normalization
|
171
182
|
|
172
|
-
|
183
|
+
### 0.1.1
|
173
184
|
|
174
185
|
* Fixed bug with missing StringIO require
|
175
186
|
* Fixed issue with dependency on unreleased features of addressable
|
176
187
|
|
177
|
-
|
188
|
+
### 0.1.0
|
178
189
|
|
179
190
|
* Initial release
|
data/Gemfile
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
source
|
1
|
+
source "https://rubygems.org"
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
gem
|
6
|
-
gem
|
7
|
-
gem
|
5
|
+
gem "bundler", ">= 1.15"
|
6
|
+
gem "gems", "~> 1.2"
|
7
|
+
gem "hurley"
|
8
|
+
gem "jruby-openssl", platforms: :jruby
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Signet
|
2
2
|
|
3
3
|
<dl>
|
4
|
-
<dt>Homepage</dt><dd><a href="
|
4
|
+
<dt>Homepage</dt><dd><a href="https://github.com/googleapis/signet/">https://github.com/googleapis/signet/</a></dd>
|
5
5
|
<dt>Author</dt><dd><a href="mailto:bobaman@google.com">Bob Aman</a></dd>
|
6
6
|
<dt>Copyright</dt><dd>Copyright © 2010 Google, Inc.</dd>
|
7
7
|
<dt>License</dt><dd>Apache 2.0</dd>
|
@@ -59,10 +59,9 @@ client.fetch_access_token!
|
|
59
59
|
Be sure `https://rubygems.org` is in your gem sources.
|
60
60
|
|
61
61
|
## Supported Ruby Versions
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
official support only for Ruby versions that are considered current and
|
62
|
+
|
63
|
+
This library requires Ruby 2.4 or later.
|
64
|
+
In general, this library supports Ruby versions that are considered current and
|
66
65
|
supported by Ruby Core (that is, Ruby versions that are either in normal
|
67
66
|
maintenance or in security maintenance).
|
68
67
|
See https://www.ruby-lang.org/en/downloads/branches/ for further details.
|
data/Rakefile
CHANGED
@@ -1,42 +1,91 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
require 'rubygems'
|
6
|
-
require 'rake'
|
1
|
+
require "rubygems"
|
2
|
+
require "json"
|
3
|
+
require "rake"
|
7
4
|
require "bundler/gem_tasks"
|
8
5
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
6
|
+
task :release_gem, :tag do |_t, args|
|
7
|
+
tag = args[:tag]
|
8
|
+
raise "You must provide a tag to release." if tag.nil?
|
9
|
+
|
10
|
+
# Verify the tag format "vVERSION"
|
11
|
+
m = tag.match(/signet\/v(?<version>\S*)/)
|
12
|
+
raise "Tag #{tag} does not match the expected format." if m.nil?
|
13
|
+
|
14
|
+
version = m[:version]
|
15
|
+
raise "You must provide a version." if version.nil?
|
16
|
+
|
17
|
+
api_token = ENV["RUBYGEMS_API_TOKEN"]
|
18
|
+
|
19
|
+
require "gems"
|
20
|
+
if api_token
|
21
|
+
::Gems.configure do |config|
|
22
|
+
config.key = api_token
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
Bundler.with_clean_env do
|
27
|
+
sh "rm -rf pkg"
|
28
|
+
sh "bundle update"
|
29
|
+
sh "bundle exec rake build"
|
30
|
+
end
|
31
|
+
|
32
|
+
path_to_be_pushed = "pkg/signet-#{version}.gem"
|
33
|
+
if File.file? path_to_be_pushed
|
34
|
+
begin
|
35
|
+
::Gems.push File.new(path_to_be_pushed)
|
36
|
+
puts "Successfully built and pushed signet for version #{version}"
|
37
|
+
rescue StandardError => e
|
38
|
+
puts "Error while releasing signet version #{version}: #{e.message}"
|
39
|
+
end
|
40
|
+
else
|
41
|
+
raise "Cannot build signet for version #{version}"
|
42
|
+
end
|
37
43
|
end
|
38
44
|
|
39
|
-
|
40
|
-
|
45
|
+
task :ci do
|
46
|
+
header "Using Ruby - #{RUBY_VERSION}"
|
47
|
+
sh "bundle exec rubocop"
|
48
|
+
sh "bundle exec rspec"
|
49
|
+
end
|
41
50
|
|
42
|
-
|
51
|
+
namespace :kokoro do
|
52
|
+
task :load_env_vars do
|
53
|
+
service_account = "#{ENV['KOKORO_GFILE_DIR']}/service-account.json"
|
54
|
+
ENV["GOOGLE_APPLICATION_CREDENTIALS"] = service_account
|
55
|
+
filename = "#{ENV['KOKORO_GFILE_DIR']}/env_vars.json"
|
56
|
+
env_vars = JSON.parse File.read(filename)
|
57
|
+
env_vars.each { |k, v| ENV[k] = v }
|
58
|
+
end
|
59
|
+
|
60
|
+
task :presubmit do
|
61
|
+
Rake::Task["ci"].invoke
|
62
|
+
end
|
63
|
+
|
64
|
+
task :continuous do
|
65
|
+
Rake::Task["ci"].invoke
|
66
|
+
end
|
67
|
+
|
68
|
+
task :nightly do
|
69
|
+
Rake::Task["ci"].invoke
|
70
|
+
end
|
71
|
+
|
72
|
+
task :release do
|
73
|
+
version = "0.1.0"
|
74
|
+
Bundler.with_clean_env do
|
75
|
+
version = `bundle exec gem list`
|
76
|
+
.split("\n").select { |line| line.include? "signet" }
|
77
|
+
.first.split("(").last.split(")").first || "0.1.0"
|
78
|
+
end
|
79
|
+
Rake::Task["kokoro:load_env_vars"].invoke
|
80
|
+
Rake::Task["release_gem"].invoke "signet/v#{version}"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def header str, token = "#"
|
85
|
+
line_length = str.length + 8
|
86
|
+
puts ""
|
87
|
+
puts token * line_length
|
88
|
+
puts "#{token * 3} #{str} #{token * 3}"
|
89
|
+
puts token * line_length
|
90
|
+
puts ""
|
91
|
+
end
|
data/lib/signet.rb
CHANGED
@@ -12,13 +12,15 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
require
|
15
|
+
require "signet/version"
|
16
16
|
|
17
17
|
module Signet #:nodoc:
|
18
|
-
|
18
|
+
# rubocop:disable Metrics/AbcSize
|
19
|
+
# rubocop:disable Metrics/MethodLength
|
20
|
+
def self.parse_auth_param_list auth_param_string
|
19
21
|
# Production rules from:
|
20
22
|
# http://tools.ietf.org/html/draft-ietf-httpbis-p1-messaging-12
|
21
|
-
token = /[
|
23
|
+
token = /[-!#{$OUTPUT_RECORD_SEPARATOR}%&'*+.^_`|~0-9a-zA-Z]+/
|
22
24
|
d_qdtext = /[\s\x21\x23-\x5B\x5D-\x7E\x80-\xFF]/n
|
23
25
|
d_quoted_pair = /\\[\s\x21-\x7E\x80-\xFF]/n
|
24
26
|
d_qs = /"(?:#{d_qdtext}|#{d_quoted_pair})*"/
|
@@ -36,10 +38,10 @@ module Signet #:nodoc:
|
|
36
38
|
#
|
37
39
|
# This would be way easier in Ruby 1.9, but we want backwards
|
38
40
|
# compatibility.
|
39
|
-
while (match = remainder.match
|
41
|
+
while (match = remainder.match auth_param)
|
40
42
|
if match.pre_match && match.pre_match !~ /^[\s,]*$/
|
41
43
|
raise ParseError,
|
42
|
-
|
44
|
+
"Unexpected auth param format: '#{auth_param_string}'."
|
43
45
|
end
|
44
46
|
auth_param_pairs << match.captures[0] # Appending pair
|
45
47
|
remainder = match.post_match
|
@@ -47,24 +49,25 @@ module Signet #:nodoc:
|
|
47
49
|
end
|
48
50
|
if last_match.post_match && last_match.post_match !~ /^[\s,]*$/
|
49
51
|
raise ParseError,
|
50
|
-
|
52
|
+
"Unexpected auth param format: '#{auth_param_string}'."
|
51
53
|
end
|
52
54
|
# Now parse the auth-param pair strings & turn them into key-value pairs.
|
53
|
-
|
54
|
-
name, value = pair.split
|
55
|
+
(auth_param_pairs.each_with_object [] do |pair, accu|
|
56
|
+
name, value = pair.split "=", 2
|
55
57
|
if value =~ /^".*"$/
|
56
58
|
value = value.gsub(/^"(.*)"$/, '\1').gsub(/\\(.)/, '\1')
|
57
59
|
elsif value =~ /^'.*'$/
|
58
60
|
value = value.gsub(/^'(.*)'$/, '\1').gsub(/\\(.)/, '\1')
|
59
|
-
elsif value =~
|
61
|
+
elsif value =~ %r{[\(\)<>@,;:\\\"/\[\]?={}]}
|
60
62
|
# Certain special characters are not allowed
|
61
|
-
raise ParseError,
|
62
|
-
|
63
|
-
|
64
|
-
|
63
|
+
raise ParseError,
|
64
|
+
"Unexpected characters in auth param " \
|
65
|
+
"list: '#{auth_param_string}'."
|
66
|
+
|
65
67
|
end
|
66
68
|
accu << [name, value]
|
67
|
-
accu
|
68
69
|
end)
|
69
70
|
end
|
71
|
+
# rubocop:enable Metrics/AbcSize
|
72
|
+
# rubocop:enable Metrics/MethodLength
|
70
73
|
end
|