glogin 0.9.0 → 0.10.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 +4 -4
- data/.github/workflows/codecov.yml +2 -2
- data/.github/workflows/pdd.yml +11 -0
- data/.github/workflows/rake.yml +3 -3
- data/.github/workflows/xcop.yml +11 -0
- data/.rultor.yml +1 -5
- data/.simplecov +1 -1
- data/Gemfile +1 -2
- data/LICENSE.txt +1 -1
- data/README.md +0 -2
- data/Rakefile +1 -1
- data/glogin.gemspec +2 -2
- data/lib/glogin/auth.rb +2 -2
- data/lib/glogin/codec.rb +51 -48
- data/lib/glogin/cookie.rb +2 -2
- data/lib/glogin/version.rb +3 -3
- data/lib/glogin.rb +2 -2
- data/test/glogin/test_auth.rb +1 -1
- data/test/glogin/test_codec.rb +1 -1
- data/test/glogin/test_cookie.rb +1 -1
- data/test/test__helper.rb +1 -5
- data/test/test_glogin.rb +2 -2
- metadata +19 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cbb6b682a4165d9835c47fc78a8ca518ddc3fb01b8292a1f3eb202aad075f6fd
|
4
|
+
data.tar.gz: b697264e4615fc83a4039781001ff324d632e393cba2d1f759fcf6ab3c21b600
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12201bbccf0b2f44210030dc3e8bef73a323a33b773f855ffb853b207eff281ff266de90ee344e54470d1d997d58c01f66274ce3cddb187ad81bb433ade74bee
|
7
|
+
data.tar.gz: 0031771355c95b84efb2b7293ef60d7e3cbb313fda141bc0470db792b95383ee980ac027984189ec0f4751a51449b6f1e7131fa5c1c10afe6d4029e8ba01349a
|
data/.github/workflows/rake.yml
CHANGED
@@ -12,12 +12,12 @@ jobs:
|
|
12
12
|
name: test
|
13
13
|
strategy:
|
14
14
|
matrix:
|
15
|
-
os: [ubuntu-
|
16
|
-
ruby: [2.7]
|
15
|
+
os: [ubuntu-20.04, macos-12]
|
16
|
+
ruby: [2.7, 3.2]
|
17
17
|
runs-on: ${{ matrix.os }}
|
18
18
|
steps:
|
19
19
|
- uses: actions/checkout@v3
|
20
|
-
- uses:
|
20
|
+
- uses: ruby/setup-ruby@v1
|
21
21
|
with:
|
22
22
|
ruby-version: ${{ matrix.ruby }}
|
23
23
|
- run: bundle update
|
data/.rultor.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
docker:
|
2
|
-
image: yegor256/rultor-image:1.
|
2
|
+
image: yegor256/rultor-image:1.19.0
|
3
3
|
assets:
|
4
4
|
rubygems.yml: yegor256/home#assets/rubygems.yml
|
5
5
|
install: |
|
@@ -19,7 +19,3 @@ release:
|
|
19
19
|
merge:
|
20
20
|
script: |-
|
21
21
|
bundle exec rake
|
22
|
-
deploy:
|
23
|
-
script: |-
|
24
|
-
echo "There is nothing to deploy"
|
25
|
-
exit -1
|
data/.simplecov
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
#
|
4
|
-
# Copyright (c) 2017-
|
4
|
+
# Copyright (c) 2017-2023 Yegor Bugayenko
|
5
5
|
#
|
6
6
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
7
|
# of this software and associated documentation files (the 'Software'), to deal
|
data/Gemfile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
#
|
4
|
-
# Copyright (c) 2017-
|
4
|
+
# Copyright (c) 2017-2023 Yegor Bugayenko
|
5
5
|
#
|
6
6
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
7
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -22,5 +22,4 @@
|
|
22
22
|
# SOFTWARE.
|
23
23
|
|
24
24
|
source 'https://rubygems.org'
|
25
|
-
ruby '~>2.3'
|
26
25
|
gemspec
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
<img src="/logo.svg" width="64px" height="64px"/>
|
2
2
|
|
3
|
-
[](https://www.0crat.com/p/C3RFVLU72)
|
4
3
|
[](http://www.rultor.com/p/yegor256/glogin)
|
5
4
|
[](https://www.jetbrains.com/ruby/)
|
6
5
|
|
@@ -10,7 +9,6 @@
|
|
10
9
|
[](https://codeclimate.com/github/yegor256/glogin/maintainability)
|
11
10
|
[](https://codecov.io/github/yegor256/glogin?branch=master)
|
12
11
|
[](http://rubydoc.info/github/yegor256/glogin/master/frames)
|
13
|
-
|
14
12
|

|
15
13
|
[](https://hitsofcode.com/view/github/yegor256/glogin)
|
16
14
|
[](https://github.com/yegor256/glogin/blob/master/LICENSE.txt)
|
data/Rakefile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
#
|
4
|
-
# Copyright (c) 2017-
|
4
|
+
# Copyright (c) 2017-2023 Yegor Bugayenko
|
5
5
|
#
|
6
6
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
7
|
# of this software and associated documentation files (the 'Software'), to deal
|
data/glogin.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2017-
|
3
|
+
# Copyright (c) 2017-2023 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -42,13 +42,13 @@ Gem::Specification.new do |s|
|
|
42
42
|
s.rdoc_options = ['--charset=UTF-8']
|
43
43
|
s.extra_rdoc_files = ['README.md', 'LICENSE.txt']
|
44
44
|
s.add_runtime_dependency 'base58', '0.2.3'
|
45
|
-
s.add_development_dependency 'codecov', '0.6.0'
|
46
45
|
s.add_development_dependency 'minitest', '5.16.1'
|
47
46
|
s.add_development_dependency 'rake', '13.0.6'
|
48
47
|
s.add_development_dependency 'rdoc', '6.4.0'
|
49
48
|
s.add_development_dependency 'rspec-rails', '5.1.2'
|
50
49
|
s.add_development_dependency 'rubocop', '1.31.1'
|
51
50
|
s.add_development_dependency 'rubocop-rspec', '2.11.1'
|
51
|
+
s.add_development_dependency 'simplecov', '0.22.0'
|
52
52
|
s.add_development_dependency 'webmock', '3.14.0'
|
53
53
|
s.metadata['rubygems_mfa_required'] = 'true'
|
54
54
|
end
|
data/lib/glogin/auth.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
#
|
4
|
-
# Copyright (c) 2017-
|
4
|
+
# Copyright (c) 2017-2023 Yegor Bugayenko
|
5
5
|
#
|
6
6
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
7
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -28,7 +28,7 @@ require 'cgi'
|
|
28
28
|
|
29
29
|
# GLogin main module.
|
30
30
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
31
|
-
# Copyright:: Copyright (c) 2017-
|
31
|
+
# Copyright:: Copyright (c) 2017-2023 Yegor Bugayenko
|
32
32
|
# License:: MIT
|
33
33
|
module GLogin
|
34
34
|
#
|
data/lib/glogin/codec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
#
|
4
|
-
# Copyright (c) 2017-
|
4
|
+
# Copyright (c) 2017-2023 Yegor Bugayenko
|
5
5
|
#
|
6
6
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
7
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -28,60 +28,63 @@ require 'base58'
|
|
28
28
|
|
29
29
|
# Codec.
|
30
30
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
31
|
-
# Copyright:: Copyright (c) 2017-
|
31
|
+
# Copyright:: Copyright (c) 2017-2023 Yegor Bugayenko
|
32
32
|
# License:: MIT
|
33
|
-
|
34
|
-
#
|
35
|
-
class
|
33
|
+
module GLogin
|
34
|
+
# The codec
|
35
|
+
class Codec
|
36
|
+
# When can't decode.
|
37
|
+
class DecodingError < StandardError; end
|
36
38
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
39
|
+
def initialize(secret = '')
|
40
|
+
raise 'Secret can\'t be nil' if secret.nil?
|
41
|
+
@secret = secret
|
42
|
+
end
|
41
43
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
44
|
+
def decrypt(text)
|
45
|
+
raise 'Text can\'t be nil' if text.nil?
|
46
|
+
if @secret.empty?
|
47
|
+
text
|
48
|
+
else
|
49
|
+
cpr = cipher
|
50
|
+
cpr.decrypt
|
51
|
+
cpr.key = digest
|
52
|
+
raise DecodingError unless /^[a-zA-Z0-9]+$/.match?(text)
|
53
|
+
plain = Base58.base58_to_binary(text)
|
54
|
+
raise DecodingError if plain.empty?
|
55
|
+
decrypted = cpr.update(plain)
|
56
|
+
decrypted << cpr.final
|
57
|
+
salt, body = decrypted.to_s.split(' ', 2)
|
58
|
+
raise DecodingError if salt.empty?
|
59
|
+
raise DecodingError if body.nil?
|
60
|
+
body.force_encoding('UTF-8')
|
61
|
+
body
|
62
|
+
end
|
63
|
+
rescue OpenSSL::Cipher::CipherError => e
|
64
|
+
raise DecodingError, e.message
|
60
65
|
end
|
61
|
-
rescue OpenSSL::Cipher::CipherError => e
|
62
|
-
raise DecodingError, e.message
|
63
|
-
end
|
64
66
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
67
|
+
def encrypt(text)
|
68
|
+
raise 'Text can\'t be nil' if text.nil?
|
69
|
+
if @secret.empty?
|
70
|
+
text
|
71
|
+
else
|
72
|
+
cpr = cipher
|
73
|
+
cpr.encrypt
|
74
|
+
cpr.key = digest
|
75
|
+
salt = SecureRandom.base64(Random.rand(8..32))
|
76
|
+
encrypted = cpr.update("#{salt} #{text}")
|
77
|
+
encrypted << cpr.final
|
78
|
+
Base58.binary_to_base58(encrypted)
|
79
|
+
end
|
77
80
|
end
|
78
|
-
end
|
79
81
|
|
80
|
-
|
81
|
-
|
82
|
-
|
82
|
+
def digest
|
83
|
+
Digest::SHA1.hexdigest(@secret)[0..31]
|
84
|
+
end
|
83
85
|
|
84
|
-
|
85
|
-
|
86
|
+
def cipher
|
87
|
+
OpenSSL::Cipher.new('aes-256-cbc')
|
88
|
+
end
|
86
89
|
end
|
87
90
|
end
|
data/lib/glogin/cookie.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
#
|
4
|
-
# Copyright (c) 2017-
|
4
|
+
# Copyright (c) 2017-2023 Yegor Bugayenko
|
5
5
|
#
|
6
6
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
7
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -28,7 +28,7 @@ require_relative 'codec'
|
|
28
28
|
|
29
29
|
# GLogin main module.
|
30
30
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
31
|
-
# Copyright:: Copyright (c) 2017-
|
31
|
+
# Copyright:: Copyright (c) 2017-2023 Yegor Bugayenko
|
32
32
|
# License:: MIT
|
33
33
|
module GLogin
|
34
34
|
# Split symbol inside the cookie text
|
data/lib/glogin/version.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
#
|
4
|
-
# Copyright (c) 2017-
|
4
|
+
# Copyright (c) 2017-2023 Yegor Bugayenko
|
5
5
|
#
|
6
6
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
7
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -23,8 +23,8 @@
|
|
23
23
|
|
24
24
|
# GLogin main module.
|
25
25
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
26
|
-
# Copyright:: Copyright (c) 2017-
|
26
|
+
# Copyright:: Copyright (c) 2017-2023 Yegor Bugayenko
|
27
27
|
# License:: MIT
|
28
28
|
module GLogin
|
29
|
-
VERSION = '0.
|
29
|
+
VERSION = '0.10.0'
|
30
30
|
end
|
data/lib/glogin.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
#
|
4
|
-
# Copyright (c) 2017-
|
4
|
+
# Copyright (c) 2017-2023 Yegor Bugayenko
|
5
5
|
#
|
6
6
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
7
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -28,7 +28,7 @@ require_relative 'glogin/cookie'
|
|
28
28
|
|
29
29
|
# GLogin main module.
|
30
30
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
31
|
-
# Copyright:: Copyright (c) 2017-
|
31
|
+
# Copyright:: Copyright (c) 2017-2023 Yegor Bugayenko
|
32
32
|
# License:: MIT
|
33
33
|
module GLogin
|
34
34
|
end
|
data/test/glogin/test_auth.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
#
|
4
|
-
# Copyright (c) 2017-
|
4
|
+
# Copyright (c) 2017-2023 Yegor Bugayenko
|
5
5
|
#
|
6
6
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
7
|
# of this software and associated documentation files (the 'Software'), to deal
|
data/test/glogin/test_codec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
#
|
4
|
-
# Copyright (c) 2017-
|
4
|
+
# Copyright (c) 2017-2023 Yegor Bugayenko
|
5
5
|
#
|
6
6
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
7
|
# of this software and associated documentation files (the 'Software'), to deal
|
data/test/glogin/test_cookie.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
#
|
4
|
-
# Copyright (c) 2017-
|
4
|
+
# Copyright (c) 2017-2023 Yegor Bugayenko
|
5
5
|
#
|
6
6
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
7
|
# of this software and associated documentation files (the 'Software'), to deal
|
data/test/test__helper.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
#
|
4
|
-
# Copyright (c) 2017-
|
4
|
+
# Copyright (c) 2017-2023 Yegor Bugayenko
|
5
5
|
#
|
6
6
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
7
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -25,10 +25,6 @@ $stdout.sync = true
|
|
25
25
|
|
26
26
|
require 'simplecov'
|
27
27
|
SimpleCov.start
|
28
|
-
if ENV['CI'] == 'true'
|
29
|
-
require 'codecov'
|
30
|
-
SimpleCov.formatter = SimpleCov::Formatter::Codecov
|
31
|
-
end
|
32
28
|
|
33
29
|
require 'minitest/autorun'
|
34
30
|
require_relative '../lib/glogin'
|
data/test/test_glogin.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
#
|
4
|
-
# Copyright (c) 2017-
|
4
|
+
# Copyright (c) 2017-2023 Yegor Bugayenko
|
5
5
|
#
|
6
6
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
7
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -26,7 +26,7 @@ require_relative '../lib/glogin'
|
|
26
26
|
|
27
27
|
# GLogin main module test.
|
28
28
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
29
|
-
# Copyright:: Copyright (c) 2017-
|
29
|
+
# Copyright:: Copyright (c) 2017-2023 Yegor Bugayenko
|
30
30
|
# License:: MIT
|
31
31
|
class TestGLogin < Minitest::Test
|
32
32
|
def test_basic
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glogin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: base58
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.2.3
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: codecov
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - '='
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 0.6.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.6.0
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: minitest
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,6 +108,20 @@ dependencies:
|
|
122
108
|
- - '='
|
123
109
|
- !ruby/object:Gem::Version
|
124
110
|
version: 2.11.1
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: simplecov
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 0.22.0
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 0.22.0
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: webmock
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -147,7 +147,9 @@ files:
|
|
147
147
|
- ".0pdd.yml"
|
148
148
|
- ".gitattributes"
|
149
149
|
- ".github/workflows/codecov.yml"
|
150
|
+
- ".github/workflows/pdd.yml"
|
150
151
|
- ".github/workflows/rake.yml"
|
152
|
+
- ".github/workflows/xcop.yml"
|
151
153
|
- ".gitignore"
|
152
154
|
- ".pdd"
|
153
155
|
- ".rubocop.yml"
|
@@ -191,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
191
193
|
- !ruby/object:Gem::Version
|
192
194
|
version: '0'
|
193
195
|
requirements: []
|
194
|
-
rubygems_version: 3.
|
196
|
+
rubygems_version: 3.2.15
|
195
197
|
signing_key:
|
196
198
|
specification_version: 4
|
197
199
|
summary: Login/logout via GitHub OAuth for your web app
|