glogin 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rultor.yml +2 -5
- data/.simplecov +1 -1
- data/Gemfile +1 -1
- data/LICENSE.txt +1 -1
- data/Rakefile +1 -1
- data/glogin.gemspec +1 -1
- data/lib/glogin.rb +2 -2
- data/lib/glogin/auth.rb +2 -2
- data/lib/glogin/codec.rb +2 -2
- data/lib/glogin/cookie.rb +10 -4
- data/lib/glogin/version.rb +3 -3
- data/test/glogin/test_auth.rb +1 -1
- data/test/glogin/test_codec.rb +1 -1
- data/test/glogin/test_cookie.rb +10 -6
- data/test/test__helper.rb +1 -1
- data/test/test_glogin.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23aa113e0458f6235f3a45c8e597f5305e1d692420a664fbe085c4ee0d55a6e3
|
4
|
+
data.tar.gz: 8d17e85d15c4bb738e56257a7ee483735667f83e22f5872b6b3003ee82b5e73f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4e44314580dcac9fc29be86b76c36285dd6d8dccf47b7d7d272d8d5873ef17400da51b32008c11506bae68a64f3e947094344556ff9e4f3edb948511cb2fb3f
|
7
|
+
data.tar.gz: d51ffeff0418ea61c3dbc5529dd5cc7752e472dae6136ea0f65e965ac869a937cac74a63959d652020703f410e8d32c3fa21db8416a8f4903786b0333ef8c8f9
|
data/.rultor.yml
CHANGED
@@ -1,10 +1,8 @@
|
|
1
1
|
assets:
|
2
2
|
rubygems.yml: yegor256/home#assets/rubygems.yml
|
3
3
|
install: |
|
4
|
-
|
5
|
-
|
6
|
-
sudo gem install pdd -v 0.20.5
|
7
|
-
bundle install
|
4
|
+
pdd -f /dev/null
|
5
|
+
sudo bundle install --no-color "--gemfile=$(pwd)/Gemfile"
|
8
6
|
release:
|
9
7
|
script: |-
|
10
8
|
bundle exec rake
|
@@ -18,7 +16,6 @@ release:
|
|
18
16
|
merge:
|
19
17
|
script: |-
|
20
18
|
bundle exec rake
|
21
|
-
pdd -f /dev/null
|
22
19
|
deploy:
|
23
20
|
script: |-
|
24
21
|
echo "There is nothing to deploy"
|
data/.simplecov
CHANGED
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-2020 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/LICENSE.txt
CHANGED
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-2020 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,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
#
|
4
|
-
# Copyright (c) 2017-
|
4
|
+
# Copyright (c) 2017-2020 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/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-2020 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-2020 Yegor Bugayenko
|
32
32
|
# License:: MIT
|
33
33
|
module GLogin
|
34
34
|
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-2020 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-2020 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-2020 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 'base58'
|
|
28
28
|
|
29
29
|
# Codec.
|
30
30
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
31
|
-
# Copyright:: Copyright (c) 2017-
|
31
|
+
# Copyright:: Copyright (c) 2017-2020 Yegor Bugayenko
|
32
32
|
# License:: MIT
|
33
33
|
class GLogin::Codec
|
34
34
|
# When can't decode.
|
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-2020 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-2020 Yegor Bugayenko
|
32
32
|
# License:: MIT
|
33
33
|
module GLogin
|
34
34
|
# Split symbol inside the cookie text
|
@@ -55,14 +55,14 @@ module GLogin
|
|
55
55
|
# to catch in your applicaiton and ignore the login attempt.
|
56
56
|
def to_user
|
57
57
|
plain = Codec.new(@secret).decrypt(@text)
|
58
|
-
login, avatar, bearer, ctx = plain.split(GLogin::SPLIT,
|
58
|
+
id, login, avatar, bearer, ctx = plain.split(GLogin::SPLIT, 5)
|
59
59
|
if !@secret.empty? && ctx.to_s != @context
|
60
60
|
raise(
|
61
61
|
GLogin::Codec::DecodingError,
|
62
62
|
"Context '#{@context}' expected, but '#{ctx}' found"
|
63
63
|
)
|
64
64
|
end
|
65
|
-
{ login: login, avatar: avatar, bearer: bearer }
|
65
|
+
{ id: id, login: login, avatar: avatar, bearer: bearer }
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
@@ -77,6 +77,11 @@ module GLogin
|
|
77
77
|
@context = context.to_s
|
78
78
|
end
|
79
79
|
|
80
|
+
# GitHub id of the authenticated user
|
81
|
+
def id
|
82
|
+
@json['id']
|
83
|
+
end
|
84
|
+
|
80
85
|
# GitHub login name of the authenticated user
|
81
86
|
def login
|
82
87
|
@json['login']
|
@@ -91,6 +96,7 @@ module GLogin
|
|
91
96
|
def to_s
|
92
97
|
Codec.new(@secret).encrypt(
|
93
98
|
[
|
99
|
+
id,
|
94
100
|
login,
|
95
101
|
avatar_url,
|
96
102
|
@json['bearer'],
|
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-2020 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-2020 Yegor Bugayenko
|
27
27
|
# License:: MIT
|
28
28
|
module GLogin
|
29
|
-
VERSION = '0.
|
29
|
+
VERSION = '0.7.0'
|
30
30
|
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-2020 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-2020 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-2020 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
|
@@ -30,7 +30,8 @@ class TestCookie < Minitest::Test
|
|
30
30
|
user = GLogin::Cookie::Closed.new(
|
31
31
|
GLogin::Cookie::Open.new(
|
32
32
|
JSON.parse(
|
33
|
-
"{\"
|
33
|
+
"{\"id\":\"123\",
|
34
|
+
\"login\":\"yegor256\",
|
34
35
|
\"avatar_url\":\"https://avatars1.githubusercontent.com/u/526301\"}"
|
35
36
|
),
|
36
37
|
secret
|
@@ -46,30 +47,33 @@ class TestCookie < Minitest::Test
|
|
46
47
|
context = '127.0.0.1'
|
47
48
|
user = GLogin::Cookie::Closed.new(
|
48
49
|
GLogin::Cookie::Open.new(
|
49
|
-
JSON.parse('{"login":"jeffrey","avatar_url":"#"}'),
|
50
|
+
JSON.parse('{"id":"123","login":"jeffrey","avatar_url":"#"}'),
|
50
51
|
secret,
|
51
52
|
context
|
52
53
|
).to_s,
|
53
54
|
secret,
|
54
55
|
context
|
55
56
|
).to_user
|
57
|
+
assert_equal(user[:id], '123')
|
56
58
|
assert_equal(user[:login], 'jeffrey')
|
57
59
|
assert_equal(user[:avatar], '#')
|
58
60
|
end
|
59
61
|
|
60
62
|
def test_decrypts_in_test_mode
|
61
63
|
user = GLogin::Cookie::Closed.new(
|
62
|
-
'test|http://example.com', ''
|
64
|
+
'123|test|http://example.com', ''
|
63
65
|
).to_user
|
66
|
+
assert_equal(user[:id], '123')
|
64
67
|
assert_equal(user[:login], 'test')
|
65
68
|
assert_equal(user[:avatar], 'http://example.com')
|
66
69
|
end
|
67
70
|
|
68
71
|
def test_decrypts_in_test_mode_with_context
|
69
72
|
user = GLogin::Cookie::Closed.new(
|
70
|
-
'
|
73
|
+
'123', '', 'some context'
|
71
74
|
).to_user
|
72
|
-
assert_equal('
|
75
|
+
assert_equal('123', user[:id])
|
76
|
+
assert_nil(user[:login])
|
73
77
|
assert_nil(user[:avatar])
|
74
78
|
end
|
75
79
|
|
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-2020 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_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-2020 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-2020 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.7.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: 2020-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: base58
|