glogin 0.16.5 → 0.17.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.
data/lib/glogin/cookie.rb CHANGED
@@ -1,29 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- #
4
- # Copyright (c) 2017-2025 Yegor Bugayenko
5
- #
6
- # Permission is hereby granted, free of charge, to any person obtaining a copy
7
- # of this software and associated documentation files (the 'Software'), to deal
8
- # in the Software without restriction, including without limitation the rights
9
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- # copies of the Software, and to permit persons to whom the Software is
11
- # furnished to do so, subject to the following conditions:
12
- #
13
- # The above copyright notice and this permission notice shall be included in all
14
- # copies or substantial portions of the Software.
15
- #
16
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
19
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- # SOFTWARE.
3
+ # SPDX-FileCopyrightText: Copyright (c) 2017-2025 Yegor Bugayenko
4
+ # SPDX-License-Identifier: MIT
23
5
 
24
- require 'openssl'
25
- require 'digest/sha1'
26
6
  require 'base64'
7
+ require 'digest/sha1'
8
+ require 'openssl'
27
9
  require_relative 'codec'
28
10
 
29
11
  # GLogin main module.
@@ -34,18 +16,59 @@ module GLogin
34
16
  # Split symbol inside the cookie text
35
17
  SPLIT = '|'
36
18
 
19
+ # Secure cookie management for user sessions.
20
+ #
21
+ # This class provides two nested classes for handling cookies:
22
+ # - Cookie::Open: Creates encrypted cookies from user data
23
+ # - Cookie::Closed: Decrypts and validates existing cookies
37
24
  #
38
- # Secure cookie
25
+ # The cookie format stores user ID, login, avatar URL, and an optional
26
+ # context string for additional security validation.
39
27
  #
28
+ # @example Creating and reading a cookie
29
+ # # After successful authentication
30
+ # user_data = auth.user(code)
31
+ # cookie = GLogin::Cookie::Open.new(user_data, 'secret-key')
32
+ # response.set_cookie('glogin', cookie.to_s)
33
+ #
34
+ # # When reading the cookie
35
+ # cookie_text = request.cookies['glogin']
36
+ # closed = GLogin::Cookie::Closed.new(cookie_text, 'secret-key')
37
+ # user = closed.to_user
38
+ # # => {"id"=>"123", "login"=>"username", "avatar_url"=>"https://..."}
40
39
  class Cookie
41
- # Closed cookie.
40
+ # Closed cookie for reading existing cookies.
42
41
  #
43
42
  # An instance of this class is created when a cookie arrives
44
- # to the application. The cookie text is provided to the class
45
- # as the first parameter. Then, when an instance of the class
46
- # is created, the value encypted inside the cookie text may
47
- # be retrieved through the +to_user+ method.
43
+ # from the client. The encrypted cookie text is decrypted to
44
+ # retrieve the original user information.
45
+ #
46
+ # @example Read a cookie from HTTP request
47
+ # cookie_text = request.cookies['glogin']
48
+ # closed = GLogin::Cookie::Closed.new(cookie_text, ENV['SECRET'])
49
+ #
50
+ # begin
51
+ # user = closed.to_user
52
+ # session[:user_id] = user['id']
53
+ # rescue GLogin::Codec::DecodingError
54
+ # # Invalid cookie - redirect to login
55
+ # redirect '/login'
56
+ # end
57
+ #
58
+ # @example Using context for additional security
59
+ # closed = GLogin::Cookie::Closed.new(
60
+ # cookie_text,
61
+ # ENV['SECRET'],
62
+ # request.ip # Validate against IP address
63
+ # )
64
+ # user = closed.to_user
48
65
  class Closed
66
+ # Creates a new closed cookie instance.
67
+ #
68
+ # @param text [String] The encrypted cookie text to decrypt
69
+ # @param secret [String] The secret key used for decryption
70
+ # @param context [String] Optional context string for validation
71
+ # @raise [RuntimeError] if any parameter is nil
49
72
  def initialize(text, secret, context = '')
50
73
  raise 'Text can\'t be nil' if text.nil?
51
74
  @text = text
@@ -55,14 +78,27 @@ module GLogin
55
78
  @context = context.to_s
56
79
  end
57
80
 
58
- # Returns a hash with four elements: `id`, `login`, and `avatar_url`.
81
+ # Decrypts and returns the user information from the cookie.
59
82
  #
60
- # If the `secret` is empty, the text will not be decrypted, but used
61
- # "as is". This may be helpful during testing.
83
+ # @return [Hash] User information with keys 'id', 'login', and 'avatar_url'
84
+ # @raise [GLogin::Codec::DecodingError] if:
85
+ # - The cookie is corrupted or tampered with
86
+ # - The wrong secret key is used
87
+ # - The context doesn't match (if provided)
88
+ # @example Basic usage
89
+ # user = closed.to_user
90
+ # # => {"id"=>"123", "login"=>"octocat", "avatar_url"=>"https://..."}
62
91
  #
63
- # If the data is not valid, an exception
64
- # `GLogin::Codec::DecodingError` will be raised, which you have
65
- # to catch in your applicaiton and ignore the login attempt.
92
+ # @example Error handling
93
+ # begin
94
+ # user = closed.to_user
95
+ # puts "Welcome, #{user['login']}!"
96
+ # rescue GLogin::Codec::DecodingError => e
97
+ # puts "Invalid session: #{e.message}"
98
+ # redirect_to_login
99
+ # end
100
+ #
101
+ # @note If the secret is empty (test mode), the text is used as-is without decryption
66
102
  def to_user
67
103
  plain = Codec.new(@secret).decrypt(@text)
68
104
  id, login, avatar_url, ctx = plain.split(GLogin::SPLIT, 5)
@@ -76,18 +112,50 @@ module GLogin
76
112
  end
77
113
  end
78
114
 
79
- # Open
115
+ # Open cookie for creating new cookies.
116
+ #
117
+ # This class takes user information from GitHub authentication
118
+ # and creates an encrypted cookie that can be sent to the client.
119
+ #
120
+ # @example Create a cookie after successful authentication
121
+ # user_data = auth.user(code)
122
+ # open = GLogin::Cookie::Open.new(user_data, ENV['SECRET'])
123
+ #
124
+ # # Set cookie with options
125
+ # response.set_cookie('glogin', {
126
+ # value: open.to_s,
127
+ # expires: 1.week.from_now,
128
+ # httponly: true,
129
+ # secure: true
130
+ # })
131
+ #
132
+ # @example Using context for IP-based validation
133
+ # open = GLogin::Cookie::Open.new(
134
+ # user_data,
135
+ # ENV['SECRET'],
136
+ # request.ip # Bind cookie to IP address
137
+ # )
138
+ # response.set_cookie('glogin', open.to_s)
80
139
  class Open
81
140
  attr_reader :id, :login, :avatar_url
82
141
 
83
- # Here comes the JSON you receive from Auth.user().
142
+ # Creates a new open cookie from user data.
84
143
  #
85
- # The JSON is a Hash where every key is a string. When the class is instantiated,
86
- # its methods `id`, `login`, and `avatar_url` may be used to retrieve
87
- # the data inside the JSON, but this is not what this class is mainly about.
88
- #
89
- # The method +to_s+ returns an encrypted cookie string, that may be
90
- # sent to the user as a +Set-Cookie+ HTTP header.
144
+ # @param json [Hash] User data from Auth#user, must contain 'id' key
145
+ # @param secret [String] Secret key for encryption
146
+ # @param context [String] Optional context for additional validation
147
+ # @raise [RuntimeError] if json is nil or missing 'id' key
148
+ # @raise [RuntimeError] if secret or context is nil
149
+ # @example
150
+ # user_data = {
151
+ # 'id' => '123456',
152
+ # 'login' => 'octocat',
153
+ # 'avatar_url' => 'https://github.com/octocat.png'
154
+ # }
155
+ # open = GLogin::Cookie::Open.new(user_data, 'secret-key')
156
+ # puts open.id # => "123456"
157
+ # puts open.login # => "octocat"
158
+ # puts open.avatar_url # => "https://github.com/octocat.png"
91
159
  def initialize(json, secret, context = '')
92
160
  raise 'JSON can\'t be nil' if json.nil?
93
161
  raise 'JSON must contain "id" key' if json['id'].nil?
@@ -101,7 +169,27 @@ module GLogin
101
169
  @context = context.to_s
102
170
  end
103
171
 
104
- # Returns the text you should drop back to the user as a cookie.
172
+ # Generates the encrypted cookie string.
173
+ #
174
+ # This method encrypts the user information (id, login, avatar_url, and context)
175
+ # into a string that can be sent as an HTTP cookie. The encryption ensures
176
+ # the cookie cannot be tampered with.
177
+ #
178
+ # @return [String] The encrypted cookie value
179
+ # @example Generate cookie for HTTP response
180
+ # open = GLogin::Cookie::Open.new(user_data, secret)
181
+ # cookie_value = open.to_s
182
+ # # => "3Hs9k2LgU..." (encrypted string)
183
+ #
184
+ # # Use with Sinatra
185
+ # response.set_cookie('glogin', cookie_value)
186
+ #
187
+ # # Use with Rails
188
+ # cookies[:glogin] = {
189
+ # value: cookie_value,
190
+ # expires: 1.week.from_now,
191
+ # httponly: true
192
+ # }
105
193
  def to_s
106
194
  Codec.new(@secret).encrypt(
107
195
  [
@@ -1,30 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- #
4
- # Copyright (c) 2017-2025 Yegor Bugayenko
5
- #
6
- # Permission is hereby granted, free of charge, to any person obtaining a copy
7
- # of this software and associated documentation files (the 'Software'), to deal
8
- # in the Software without restriction, including without limitation the rights
9
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- # copies of the Software, and to permit persons to whom the Software is
11
- # furnished to do so, subject to the following conditions:
12
- #
13
- # The above copyright notice and this permission notice shall be included in all
14
- # copies or substantial portions of the Software.
15
- #
16
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
19
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- # SOFTWARE.
3
+ # SPDX-FileCopyrightText: Copyright (c) 2017-2025 Yegor Bugayenko
4
+ # SPDX-License-Identifier: MIT
23
5
 
24
6
  # GLogin main module.
25
7
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
26
8
  # Copyright:: Copyright (c) 2017-2025 Yegor Bugayenko
27
9
  # License:: MIT
28
10
  module GLogin
29
- VERSION = '0.16.5'
11
+ # Current version of the GLogin gem.
12
+ #
13
+ # @example Check the gem version
14
+ # puts GLogin::VERSION
15
+ # # => "0.17.0"
16
+ #
17
+ # @example Version comparison
18
+ # if Gem::Version.new(GLogin::VERSION) >= Gem::Version.new('0.1.0')
19
+ # puts "Using GLogin version 0.1.0 or newer"
20
+ # end
21
+ VERSION = '0.17.0'
30
22
  end
data/lib/glogin.rb CHANGED
@@ -1,32 +1,37 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- #
4
- # Copyright (c) 2017-2025 Yegor Bugayenko
5
- #
6
- # Permission is hereby granted, free of charge, to any person obtaining a copy
7
- # of this software and associated documentation files (the 'Software'), to deal
8
- # in the Software without restriction, including without limitation the rights
9
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- # copies of the Software, and to permit persons to whom the Software is
11
- # furnished to do so, subject to the following conditions:
12
- #
13
- # The above copyright notice and this permission notice shall be included in all
14
- # copies or substantial portions of the Software.
15
- #
16
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
19
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- # SOFTWARE.
3
+ # SPDX-FileCopyrightText: Copyright (c) 2017-2025 Yegor Bugayenko
4
+ # SPDX-License-Identifier: MIT
23
5
 
24
- require 'nokogiri'
25
- require_relative 'glogin/version'
26
6
  require_relative 'glogin/auth'
27
7
  require_relative 'glogin/cookie'
8
+ require_relative 'glogin/version'
28
9
 
29
10
  # GLogin main module.
11
+ #
12
+ # GLogin is a Ruby gem that provides OAuth integration with GitHub. It simplifies
13
+ # the process of authenticating users through GitHub and managing their sessions
14
+ # using secure cookies.
15
+ #
16
+ # @example Basic usage with Sinatra
17
+ # require 'sinatra'
18
+ # require 'glogin'
19
+ #
20
+ # configure do
21
+ # set :glogin, GLogin::Auth.new(
22
+ # ENV['GITHUB_CLIENT_ID'],
23
+ # ENV['GITHUB_CLIENT_SECRET'],
24
+ # 'http://localhost:4567/auth'
25
+ # )
26
+ # end
27
+ #
28
+ # get '/auth' do
29
+ # user = settings.glogin.user(params[:code])
30
+ # cookie = GLogin::Cookie::Open.new(user, ENV['ENCRYPTION_SECRET'])
31
+ # response.set_cookie('glogin', cookie.to_s)
32
+ # redirect '/'
33
+ # end
34
+ #
30
35
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
31
36
  # Copyright:: Copyright (c) 2017-2025 Yegor Bugayenko
32
37
  # License:: MIT
@@ -1,29 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- #
4
- # Copyright (c) 2017-2025 Yegor Bugayenko
5
- #
6
- # Permission is hereby granted, free of charge, to any person obtaining a copy
7
- # of this software and associated documentation files (the 'Software'), to deal
8
- # in the Software without restriction, including without limitation the rights
9
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- # copies of the Software, and to permit persons to whom the Software is
11
- # furnished to do so, subject to the following conditions:
12
- #
13
- # The above copyright notice and this permission notice shall be included in all
14
- # copies or substantial portions of the Software.
15
- #
16
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
19
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- # SOFTWARE.
3
+ # SPDX-FileCopyrightText: Copyright (c) 2017-2025 Yegor Bugayenko
4
+ # SPDX-License-Identifier: MIT
23
5
 
24
- require 'minitest/autorun'
25
- require 'webmock/minitest'
26
6
  require_relative '../../lib/glogin/cookie'
7
+ require_relative '../test__helper'
27
8
 
28
9
  class TestAuth < Minitest::Test
29
10
  def test_authenticate_via_https
@@ -70,7 +51,7 @@ class TestAuth < Minitest::Test
70
51
  auth = GLogin::Auth.new('1234', '4433', 'https://example.org')
71
52
  stub_request(:post, 'https://github.com/login/oauth/access_token').to_return(body: 'Hello!')
72
53
  e = assert_raises(StandardError) { auth.user('47839893') }
73
- assert_includes(e.message, 'unexpected token', e)
54
+ assert_includes(e.message, 'unexpected', e)
74
55
  end
75
56
 
76
57
  def test_no_token_in_json
@@ -1,29 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- #
4
- # Copyright (c) 2017-2025 Yegor Bugayenko
5
- #
6
- # Permission is hereby granted, free of charge, to any person obtaining a copy
7
- # of this software and associated documentation files (the 'Software'), to deal
8
- # in the Software without restriction, including without limitation the rights
9
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- # copies of the Software, and to permit persons to whom the Software is
11
- # furnished to do so, subject to the following conditions:
12
- #
13
- # The above copyright notice and this permission notice shall be included in all
14
- # copies or substantial portions of the Software.
15
- #
16
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
19
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- # SOFTWARE.
3
+ # SPDX-FileCopyrightText: Copyright (c) 2017-2025 Yegor Bugayenko
4
+ # SPDX-License-Identifier: MIT
23
5
 
24
- require 'minitest/autorun'
25
6
  require 'base64'
26
7
  require_relative '../../lib/glogin/codec'
8
+ require_relative '../test__helper'
27
9
 
28
10
  class TestCodec < Minitest::Test
29
11
  def test_encodes_and_decodes
@@ -1,28 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- #
4
- # Copyright (c) 2017-2025 Yegor Bugayenko
5
- #
6
- # Permission is hereby granted, free of charge, to any person obtaining a copy
7
- # of this software and associated documentation files (the 'Software'), to deal
8
- # in the Software without restriction, including without limitation the rights
9
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- # copies of the Software, and to permit persons to whom the Software is
11
- # furnished to do so, subject to the following conditions:
12
- #
13
- # The above copyright notice and this permission notice shall be included in all
14
- # copies or substantial portions of the Software.
15
- #
16
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
19
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- # SOFTWARE.
3
+ # SPDX-FileCopyrightText: Copyright (c) 2017-2025 Yegor Bugayenko
4
+ # SPDX-License-Identifier: MIT
23
5
 
24
- require 'minitest/autorun'
25
6
  require_relative '../../lib/glogin/cookie'
7
+ require_relative '../test__helper'
26
8
 
27
9
  class TestCookie < Minitest::Test
28
10
  def test_encrypts_and_decrypts
data/test/test__helper.rb CHANGED
@@ -1,30 +1,32 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- #
4
- # Copyright (c) 2017-2025 Yegor Bugayenko
5
- #
6
- # Permission is hereby granted, free of charge, to any person obtaining a copy
7
- # of this software and associated documentation files (the 'Software'), to deal
8
- # in the Software without restriction, including without limitation the rights
9
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- # copies of the Software, and to permit persons to whom the Software is
11
- # furnished to do so, subject to the following conditions:
12
- #
13
- # The above copyright notice and this permission notice shall be included in all
14
- # copies or substantial portions of the Software.
15
- #
16
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
19
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- # SOFTWARE.
3
+ # SPDX-FileCopyrightText: Copyright (c) 2017-2025 Yegor Bugayenko
4
+ # SPDX-License-Identifier: MIT
23
5
 
24
6
  $stdout.sync = true
25
7
 
26
8
  require 'simplecov'
27
- SimpleCov.start
9
+ require 'simplecov-cobertura'
10
+ unless SimpleCov.running || ENV['PICKS']
11
+ SimpleCov.command_name('test')
12
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
13
+ [
14
+ SimpleCov::Formatter::HTMLFormatter,
15
+ SimpleCov::Formatter::CoberturaFormatter
16
+ ]
17
+ )
18
+ SimpleCov.minimum_coverage 100
19
+ SimpleCov.minimum_coverage_by_file 95
20
+ SimpleCov.start do
21
+ add_filter 'test/'
22
+ add_filter 'vendor/'
23
+ add_filter 'target/'
24
+ track_files 'lib/**/*.rb'
25
+ track_files '*.rb'
26
+ end
27
+ end
28
28
 
29
29
  require 'minitest/autorun'
30
- require_relative '../lib/glogin'
30
+ require 'minitest/reporters'
31
+ require 'webmock/minitest'
32
+ Minitest::Reporters.use! [Minitest::Reporters::SpecReporter.new]
data/test/test_glogin.rb CHANGED
@@ -1,28 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- #
4
- # Copyright (c) 2017-2025 Yegor Bugayenko
5
- #
6
- # Permission is hereby granted, free of charge, to any person obtaining a copy
7
- # of this software and associated documentation files (the 'Software'), to deal
8
- # in the Software without restriction, including without limitation the rights
9
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- # copies of the Software, and to permit persons to whom the Software is
11
- # furnished to do so, subject to the following conditions:
12
- #
13
- # The above copyright notice and this permission notice shall be included in all
14
- # copies or substantial portions of the Software.
15
- #
16
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
19
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- # SOFTWARE.
3
+ # SPDX-FileCopyrightText: Copyright (c) 2017-2025 Yegor Bugayenko
4
+ # SPDX-License-Identifier: MIT
23
5
 
24
- require 'minitest/autorun'
25
6
  require_relative '../lib/glogin'
7
+ require_relative 'test__helper'
26
8
 
27
9
  # GLogin main module test.
28
10
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glogin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.5
4
+ version: 0.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-01-29 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: base58
@@ -24,6 +23,20 @@ dependencies:
24
23
  - - ">="
25
24
  - !ruby/object:Gem::Version
26
25
  version: '0.2'
26
+ - !ruby/object:Gem::Dependency
27
+ name: base64
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0.2'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0.2'
27
40
  - !ruby/object:Gem::Dependency
28
41
  name: openssl
29
42
  requirement: !ruby/object:Gem::Requirement
@@ -43,8 +56,8 @@ email: yegor256@gmail.com
43
56
  executables: []
44
57
  extensions: []
45
58
  extra_rdoc_files:
46
- - README.md
47
59
  - LICENSE.txt
60
+ - README.md
48
61
  files:
49
62
  - ".0pdd.yml"
50
63
  - ".gitattributes"
@@ -54,15 +67,20 @@ files:
54
67
  - ".github/workflows/markdown-lint.yml"
55
68
  - ".github/workflows/pdd.yml"
56
69
  - ".github/workflows/rake.yml"
70
+ - ".github/workflows/reuse.yml"
71
+ - ".github/workflows/typos.yml"
57
72
  - ".github/workflows/xcop.yml"
73
+ - ".github/workflows/yamllint.yml"
58
74
  - ".gitignore"
59
75
  - ".pdd"
60
76
  - ".rubocop.yml"
61
77
  - ".rultor.yml"
62
- - ".simplecov"
63
78
  - Gemfile
79
+ - Gemfile.lock
64
80
  - LICENSE.txt
81
+ - LICENSES/MIT.txt
65
82
  - README.md
83
+ - REUSE.toml
66
84
  - Rakefile
67
85
  - glogin.gemspec
68
86
  - lib/glogin.rb
@@ -82,7 +100,6 @@ licenses:
82
100
  - MIT
83
101
  metadata:
84
102
  rubygems_mfa_required: 'true'
85
- post_install_message:
86
103
  rdoc_options:
87
104
  - "--charset=UTF-8"
88
105
  require_paths:
@@ -98,8 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
115
  - !ruby/object:Gem::Version
99
116
  version: '0'
100
117
  requirements: []
101
- rubygems_version: 3.4.10
102
- signing_key:
118
+ rubygems_version: 3.6.7
103
119
  specification_version: 4
104
120
  summary: Login/logout via GitHub OAuth for your web app
105
121
  test_files: []
data/.simplecov DELETED
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- #
4
- # Copyright (c) 2017-2025 Yegor Bugayenko
5
- #
6
- # Permission is hereby granted, free of charge, to any person obtaining a copy
7
- # of this software and associated documentation files (the 'Software'), to deal
8
- # in the Software without restriction, including without limitation the rights
9
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- # copies of the Software, and to permit persons to whom the Software is
11
- # furnished to do so, subject to the following conditions:
12
- #
13
- # The above copyright notice and this permission notice shall be included in all
14
- # copies or substantial portions of the Software.
15
- #
16
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
19
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- # SOFTWARE.
23
-
24
- if Gem.win_platform?
25
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
26
- SimpleCov::Formatter::HTMLFormatter
27
- ]
28
- SimpleCov.start do
29
- add_filter '/test/'
30
- add_filter '/features/'
31
- end
32
- else
33
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
34
- [SimpleCov::Formatter::HTMLFormatter]
35
- )
36
- SimpleCov.start do
37
- add_filter '/test/'
38
- add_filter '/features/'
39
- minimum_coverage 20
40
- end
41
- end