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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 72c86f15831f8df5a5d22617b889445f2edc8a18b9a8cac412ecd6fae3fb10ea
4
- data.tar.gz: 9280242c989853567637bdaeaed594dcc6f728d16c0f6bf176168c4b69f3166d
3
+ metadata.gz: 23aa113e0458f6235f3a45c8e597f5305e1d692420a664fbe085c4ee0d55a6e3
4
+ data.tar.gz: 8d17e85d15c4bb738e56257a7ee483735667f83e22f5872b6b3003ee82b5e73f
5
5
  SHA512:
6
- metadata.gz: 6d4437fd9ab2f4634b248aaf9f23d4dd32bc026bfa69660a56aaf171418de27972f4304cac309dceba16171b57bead9839d9e24f350782285a69d3a191bf47af
7
- data.tar.gz: 87647de3454925e2eb32baa1d209e9eb3e1d353c922fdca6e1e6a22cf6b8d9114c971fc9a8e1feaa018aded19cf2ac91fd33a9dcd13de5c06a4a13cedb574a79
6
+ metadata.gz: d4e44314580dcac9fc29be86b76c36285dd6d8dccf47b7d7d272d8d5873ef17400da51b32008c11506bae68a64f3e947094344556ff9e4f3edb948511cb2fb3f
7
+ data.tar.gz: d51ffeff0418ea61c3dbc5529dd5cc7752e472dae6136ea0f65e965ac869a937cac74a63959d652020703f410e8d32c3fa21db8416a8f4903786b0333ef8c8f9
@@ -1,10 +1,8 @@
1
1
  assets:
2
2
  rubygems.yml: yegor256/home#assets/rubygems.yml
3
3
  install: |
4
- export GEM_HOME=~/.ruby
5
- export GEM_PATH=$GEM_HOME:$GEM_PATH
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
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2017-2019 Yegor Bugayenko
2
+ # Copyright (c) 2017-2020 Yegor Bugayenko
3
3
  #
4
4
  # Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  # 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-2019 Yegor Bugayenko
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
@@ -1,6 +1,6 @@
1
1
  (The MIT License)
2
2
 
3
- Copyright (c) 2017-2019 Yegor Bugayenko
3
+ Copyright (c) 2017-2020 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
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #
4
- # Copyright (c) 2017-2019 Yegor Bugayenko
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
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #
4
- # Copyright (c) 2017-2019 Yegor Bugayenko
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
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #
4
- # Copyright (c) 2017-2019 Yegor Bugayenko
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-2019 Yegor Bugayenko
31
+ # Copyright:: Copyright (c) 2017-2020 Yegor Bugayenko
32
32
  # License:: MIT
33
33
  module GLogin
34
34
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #
4
- # Copyright (c) 2017-2019 Yegor Bugayenko
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-2019 Yegor Bugayenko
31
+ # Copyright:: Copyright (c) 2017-2020 Yegor Bugayenko
32
32
  # License:: MIT
33
33
  module GLogin
34
34
  #
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #
4
- # Copyright (c) 2017-2019 Yegor Bugayenko
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-2019 Yegor Bugayenko
31
+ # Copyright:: Copyright (c) 2017-2020 Yegor Bugayenko
32
32
  # License:: MIT
33
33
  class GLogin::Codec
34
34
  # When can't decode.
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #
4
- # Copyright (c) 2017-2019 Yegor Bugayenko
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-2019 Yegor Bugayenko
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, 4)
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'],
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #
4
- # Copyright (c) 2017-2019 Yegor Bugayenko
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-2019 Yegor Bugayenko
26
+ # Copyright:: Copyright (c) 2017-2020 Yegor Bugayenko
27
27
  # License:: MIT
28
28
  module GLogin
29
- VERSION = '0.6.0'
29
+ VERSION = '0.7.0'
30
30
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #
4
- # Copyright (c) 2017-2019 Yegor Bugayenko
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
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #
4
- # Copyright (c) 2017-2019 Yegor Bugayenko
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
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #
4
- # Copyright (c) 2017-2019 Yegor Bugayenko
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
- "{\"login\":\"yegor256\",\
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
- 'tester', '', 'some context'
73
+ '123', '', 'some context'
71
74
  ).to_user
72
- assert_equal('tester', user[:login])
75
+ assert_equal('123', user[:id])
76
+ assert_nil(user[:login])
73
77
  assert_nil(user[:avatar])
74
78
  end
75
79
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #
4
- # Copyright (c) 2017-2019 Yegor Bugayenko
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
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #
4
- # Copyright (c) 2017-2019 Yegor Bugayenko
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-2019 Yegor Bugayenko
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.6.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: 2019-07-08 00:00:00.000000000 Z
11
+ date: 2020-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base58