yt-auth 0.3.1 → 1.1.0

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
- SHA1:
3
- metadata.gz: 7fe566f505bb9ce9a4481ce80a8b280b8d2e9647
4
- data.tar.gz: 874cd60e6091c8b75d0c0981bdcba59076534060
2
+ SHA256:
3
+ metadata.gz: 05a1a75f5f8f810adcf491d297677e947d2e5cd78107cfbd313e1188a9db17c0
4
+ data.tar.gz: b67125a4109041568d7e9934fbc47f05b468c131c5917efc1e9cca71d0ee90b1
5
5
  SHA512:
6
- metadata.gz: 1a2bb317a6c99de5e2fee9e8f687884e801570a87f1623a7d76fe3e2a4f627e30af9cbda0c02fdf0fea6fcd9136003020fd942c2599512d901d14efc177836e8
7
- data.tar.gz: 970fc17a7774877192ab4561fc482e03a288ae18da10a1a5342878e2b3f18e0cf614f85f602eb52e88492892b84fedede286876eebf8e220e85eb7c38c2285a1
6
+ metadata.gz: 81a37ada6ca52b871e50cb87f1d0314c49f4b6464072f5a26875d44aa96f6f30ac54a1474c8921d99b26fbf3711de46d83faf5f3604acf157875b545cd12361d
7
+ data.tar.gz: b7f95d81006bc85665587abbbb5dbf8f75cb68f0aa221e85556d6aa31764f414fb328643edf319a79ff00e9f1e3d9f21361be35c5b237f325bf4693d9e55e4b2
data/CHANGELOG.md CHANGED
@@ -6,6 +6,18 @@ For more information about changelogs, check
6
6
  [Keep a Changelog](http://keepachangelog.com) and
7
7
  [Vandamme](http://tech-angels.github.io/vandamme).
8
8
 
9
+ ## 1.1.0 - 2024-12-10
10
+
11
+ * [FEATURE] Support mocking
12
+
13
+ - Use `Yt.configuration.mock_auth_error` to mock an error response
14
+ - Use `Yt.configuration.mock_auth_email` to mock authenticating as an email
15
+ - If the value of `mock_auth_email` is `invalid-email`, raise a Yt::HTTPError
16
+
17
+ ## 1.0.0 - 2024-11-26
18
+
19
+ Released major version. No breaking changes.
20
+
9
21
  ## 0.3.1 - 2017-08-26
10
22
 
11
23
  * [ENHANCEMENT] Add placeholder method to be notified when token is refreshed.
@@ -20,7 +32,7 @@ If your code uses `Yt::Auth.new(refresh_token:)` then you must use `Yt::Auth.fin
20
32
 
21
33
  * [ENHANCEMENT] Extract `Auth#url` into `Auth.url_for`
22
34
  * [ENHANCEMENT] Rename `Auth.new(code:)` into `Auth.create(code:)`
23
- * [ENHANCEMENT] Rename `Auth.new(refresh_token:)` into `Auth.create(refresh_token:)`
35
+ * [ENHANCEMENT] Rename `Auth.new(refresh_token:)` into `Auth.find_by(refresh_token:)`
24
36
  * [FEATURE] Yt::Auth.url_for now accepts the scope to authenticate
25
37
  * [FEATURE] Yt::Auth.url_for now accepts an option to force re-authentication
26
38
  * [FEATURE] Add `Auth#revoke` to revoke a refresh token
data/README.md CHANGED
@@ -7,12 +7,12 @@ their Google-based email address.
7
7
  With Yt::Auth, it is easy to limit access to your app to a few users without
8
8
  the need for them to create a username and password.
9
9
 
10
- The **source code** is available on [GitHub](https://github.com/fullscreen/yt-auth) and the **documentation** on [RubyDoc](http://www.rubydoc.info/gems/yt-auth/frames).
10
+ The **source code** is available on [GitHub](https://github.com/claudiob/yt-auth) and the **documentation** on [RubyDoc](http://www.rubydoc.info/gems/yt-auth/frames).
11
11
 
12
- [![Build Status](http://img.shields.io/travis/Fullscreen/yt-auth/master.svg)](https://travis-ci.org/Fullscreen/yt-auth)
13
- [![Coverage Status](http://img.shields.io/coveralls/Fullscreen/yt-auth/master.svg)](https://coveralls.io/r/Fullscreen/yt-auth)
14
- [![Dependency Status](http://img.shields.io/gemnasium/Fullscreen/yt-auth.svg)](https://gemnasium.com/Fullscreen/yt-auth)
15
- [![Code Climate](http://img.shields.io/codeclimate/github/Fullscreen/yt-auth.svg)](https://codeclimate.com/github/Fullscreen/yt-auth)
12
+ [![Build Status](http://img.shields.io/travis/claudiob/yt-auth/master.svg)](https://travis-ci.org/claudiob/yt-auth)
13
+ [![Coverage Status](http://img.shields.io/coveralls/claudiob/yt-auth/master.svg)](https://coveralls.io/r/claudiob/yt-auth)
14
+ [![Dependency Status](http://img.shields.io/gemnasium/claudiob/yt-auth.svg)](https://gemnasium.com/claudiob/yt-auth)
15
+ [![Code Climate](http://img.shields.io/codeclimate/github/claudiob/yt-auth.svg)](https://codeclimate.com/github/claudiob/yt-auth)
16
16
  [![Online docs](http://img.shields.io/badge/docs-✓-green.svg)](http://www.rubydoc.info/gems/yt-auth/frames)
17
17
  [![Gem Version](http://img.shields.io/gem/v/yt-auth.svg)](http://rubygems.org/gems/yt-auth)
18
18
 
@@ -112,6 +112,9 @@ How to contribute
112
112
  Contribute to the code by forking the project, adding the missing code,
113
113
  writing the appropriate tests and submitting a pull request.
114
114
 
115
+ To run the tests correctly, set up the environment variables `YT_ACCOUNT_CLIENT_ID`
116
+ and `YT_ACCOUNT_CLIENT_SECRET` with the credentials of an existing Google OAuth app.
117
+
115
118
  In order for a PR to be approved, all the tests need to pass and all the public
116
119
  methods need to be documented and listed in the guides. Remember:
117
120
 
data/bin/console CHANGED
@@ -6,9 +6,5 @@ require 'yt/auth'
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.
8
8
 
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require 'pry'
11
- # Pry.start
12
-
13
9
  require 'irb'
14
10
  IRB.start(__FILE__)
@@ -2,6 +2,6 @@ module Yt
2
2
  class Auth
3
3
  # @return [String] the SemVer-compatible gem version.
4
4
  # @see http://semver.org
5
- VERSION = '0.3.1'
5
+ VERSION = '1.1.0'
6
6
  end
7
7
  end
data/lib/yt/auth.rb CHANGED
@@ -33,10 +33,16 @@ module Yt
33
33
  # @option options [Array<String>] :scopes The list of scopes that users
34
34
  # are requested to authorize.
35
35
  def self.url_for(options = {})
36
- host = 'accounts.google.com'
37
- path = '/o/oauth2/auth'
38
- query = URI.encode_www_form url_params(options)
39
- URI::HTTPS.build(host: host, path: path, query: query).to_s
36
+ if Yt.configuration.mock_auth_error
37
+ options[:redirect_uri] + '?error=' + Yt.configuration.mock_auth_error
38
+ elsif Yt.configuration.mock_auth_email
39
+ options[:redirect_uri] + '?code=mock-email'
40
+ else
41
+ host = 'accounts.google.com'
42
+ path = '/o/oauth2/auth'
43
+ query = URI.encode_www_form url_params(options)
44
+ URI::HTTPS.build(host: host, path: path, query: query).to_s
45
+ end
40
46
  end
41
47
 
42
48
  # @param [Hash] options the options to initialize an instance of Yt::Auth.
@@ -57,7 +63,15 @@ module Yt
57
63
 
58
64
  # @return [String] the email of an authenticated Google account.
59
65
  def email
60
- profile['email']
66
+ if Yt.configuration.mock_auth_email
67
+ if Yt.configuration.mock_auth_email.eql? 'invalid-email'
68
+ raise Yt::HTTPError, 'Malformed auth code'
69
+ else
70
+ Yt.configuration.mock_auth_email
71
+ end
72
+ else
73
+ profile['email']
74
+ end
61
75
  end
62
76
 
63
77
  # @return [String] the access token of an authenticated Google account.
@@ -108,24 +122,24 @@ module Yt
108
122
 
109
123
  def tokens_params
110
124
  {}.tap do |params|
111
- params[:host] = 'accounts.google.com'
112
- params[:path] = '/o/oauth2/token'
125
+ params[:host] = 'oauth2.googleapis.com'
126
+ params[:path] = '/token'
113
127
  params[:method] = :post
114
128
  params[:request_format] = :form
115
129
  params[:body] = @tokens_body
116
- params[:error_message] = ->(body) { error_message_for body }
130
+ params[:error_message] = ->(code) { error_message_for code }
117
131
  end
118
132
  end
119
133
 
120
134
  def revoke_params
121
135
  {}.tap do |params|
122
- params[:host] = 'accounts.google.com'
123
- params[:path] = '/o/oauth2/revoke'
136
+ params[:host] = 'oauth2.googleapis.com'
137
+ params[:path] = '/revoke'
124
138
  params[:params] = {token: refresh_token || access_token}
125
139
  end
126
140
  end
127
141
 
128
- def error_message_for(body)
142
+ def error_message_for(code)
129
143
  key = @tokens_body[:grant_type].to_s.tr '_', ' '
130
144
  JSON(body)['error_description'] || "Invalid #{key}."
131
145
  end
data/yt-auth.gemspec CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.summary = %q{Google Authentication Ruby client}
13
13
  spec.description = %q{Yt::Auth makes it easy to authenticate users to any
14
14
  web application by means of their Google account.}
15
- spec.homepage = 'https://github.com/fullscreen/yt-auth'
15
+ spec.homepage = 'https://github.com/claudiob/yt-auth'
16
16
  spec.license = 'MIT'
17
17
 
18
18
  spec.required_ruby_version = '>= 2.2.2'
@@ -24,13 +24,12 @@ Gem::Specification.new do |spec|
24
24
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
25
  spec.require_paths = ['lib']
26
26
 
27
- spec.add_dependency 'yt-support', '>= 0.1.3'
27
+ spec.add_dependency 'yt-support', '~> 1.0'
28
28
  spec.add_dependency 'jwt', '>= 1.5.6'
29
29
 
30
- spec.add_development_dependency 'bundler', '~> 1.14'
31
- spec.add_development_dependency 'rspec', '~> 3.5'
32
- spec.add_development_dependency 'rake', '~> 12.0'
33
- spec.add_development_dependency 'coveralls', '~> 0.8.20'
34
- spec.add_development_dependency 'pry-nav', '~> 0.2.4'
35
- spec.add_development_dependency 'yard', '~> 0.9.8'
30
+ spec.add_development_dependency 'bundler'
31
+ spec.add_development_dependency 'rspec'#, '~> 3.5'
32
+ spec.add_development_dependency 'rake'#, '~> 12.0'
33
+ spec.add_development_dependency 'coveralls'#, '~> 0.8.20'
34
+ spec.add_development_dependency 'yard'#, '~> 0.9.8'
36
35
  end
metadata CHANGED
@@ -1,30 +1,30 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yt-auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claudio Baccigalupo
8
8
  - Kang-Kyu Lee
9
- autorequire:
9
+ autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2017-08-27 00:00:00.000000000 Z
12
+ date: 2024-12-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: yt-support
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ">="
18
+ - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: 0.1.3
20
+ version: '1.0'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ">="
25
+ - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: 0.1.3
27
+ version: '1.0'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: jwt
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -43,86 +43,72 @@ dependencies:
43
43
  name: bundler
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - "~>"
46
+ - - ">="
47
47
  - !ruby/object:Gem::Version
48
- version: '1.14'
48
+ version: '0'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - "~>"
53
+ - - ">="
54
54
  - !ruby/object:Gem::Version
55
- version: '1.14'
55
+ version: '0'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: rspec
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - "~>"
60
+ - - ">="
61
61
  - !ruby/object:Gem::Version
62
- version: '3.5'
62
+ version: '0'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - "~>"
67
+ - - ">="
68
68
  - !ruby/object:Gem::Version
69
- version: '3.5'
69
+ version: '0'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rake
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - "~>"
74
+ - - ">="
75
75
  - !ruby/object:Gem::Version
76
- version: '12.0'
76
+ version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - "~>"
81
+ - - ">="
82
82
  - !ruby/object:Gem::Version
83
- version: '12.0'
83
+ version: '0'
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: coveralls
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
- - - "~>"
89
- - !ruby/object:Gem::Version
90
- version: 0.8.20
91
- type: :development
92
- prerelease: false
93
- version_requirements: !ruby/object:Gem::Requirement
94
- requirements:
95
- - - "~>"
96
- - !ruby/object:Gem::Version
97
- version: 0.8.20
98
- - !ruby/object:Gem::Dependency
99
- name: pry-nav
100
- requirement: !ruby/object:Gem::Requirement
101
- requirements:
102
- - - "~>"
88
+ - - ">="
103
89
  - !ruby/object:Gem::Version
104
- version: 0.2.4
90
+ version: '0'
105
91
  type: :development
106
92
  prerelease: false
107
93
  version_requirements: !ruby/object:Gem::Requirement
108
94
  requirements:
109
- - - "~>"
95
+ - - ">="
110
96
  - !ruby/object:Gem::Version
111
- version: 0.2.4
97
+ version: '0'
112
98
  - !ruby/object:Gem::Dependency
113
99
  name: yard
114
100
  requirement: !ruby/object:Gem::Requirement
115
101
  requirements:
116
- - - "~>"
102
+ - - ">="
117
103
  - !ruby/object:Gem::Version
118
- version: 0.9.8
104
+ version: '0'
119
105
  type: :development
120
106
  prerelease: false
121
107
  version_requirements: !ruby/object:Gem::Requirement
122
108
  requirements:
123
- - - "~>"
109
+ - - ">="
124
110
  - !ruby/object:Gem::Version
125
- version: 0.9.8
111
+ version: '0'
126
112
  description: |-
127
113
  Yt::Auth makes it easy to authenticate users to any
128
114
  web application by means of their Google account.
@@ -146,11 +132,11 @@ files:
146
132
  - lib/yt/auth.rb
147
133
  - lib/yt/auth/version.rb
148
134
  - yt-auth.gemspec
149
- homepage: https://github.com/fullscreen/yt-auth
135
+ homepage: https://github.com/claudiob/yt-auth
150
136
  licenses:
151
137
  - MIT
152
138
  metadata: {}
153
- post_install_message:
139
+ post_install_message:
154
140
  rdoc_options: []
155
141
  require_paths:
156
142
  - lib
@@ -165,9 +151,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
151
  - !ruby/object:Gem::Version
166
152
  version: '0'
167
153
  requirements: []
168
- rubyforge_project:
169
- rubygems_version: 2.6.11
170
- signing_key:
154
+ rubygems_version: 3.5.23
155
+ signing_key:
171
156
  specification_version: 4
172
157
  summary: Google Authentication Ruby client
173
158
  test_files: []