github-authentication 1.0.2 → 1.2.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/tests.yml +29 -13
- data/.rubocop.yml +3 -2
- data/.ruby-version +1 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +64 -43
- data/Rakefile +1 -0
- data/bin/rake +4 -2
- data/bin/rubocop +4 -2
- data/exe/git-credential-github-app +17 -12
- data/github-authentication.gemspec +8 -7
- data/lib/github_authentication/cache.rb +2 -2
- data/lib/github_authentication/environment.rb +38 -0
- data/lib/github_authentication/generator/app.rb +2 -2
- data/lib/github_authentication/git_credential_helper.rb +7 -15
- data/lib/github_authentication/http.rb +3 -4
- data/lib/github_authentication/object_cache.rb +2 -2
- data/lib/github_authentication/provider.rb +3 -5
- data/lib/github_authentication/retriable.rb +3 -3
- data/lib/github_authentication/token.rb +9 -7
- data/lib/github_authentication/version.rb +1 -1
- data/lib/github_authentication.rb +1 -0
- metadata +34 -49
- data/.travis.yml +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc7a5e8c75f0a6c1eff271d772031e5d18850dd6bb7d2387908d5186558e1396
|
4
|
+
data.tar.gz: fdd8a299c44fa0d0a4336af31d0568ab0b6f9d71111fa0fa3a3157b04a9356c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cef00e4c97906f4e6a988ec830ed5462a3f146365b2abebdd0284fee99e243c5ca5db618642eb7fffb004d24080fce2294a2875043fbe947d01c70a751177466
|
7
|
+
data.tar.gz: 4fe79c4825cb493039a315aaeda5f982616bee4b411909d931ef7e20938a55b5b0f1b5ea99781b02e2c1f17cba6ae4af950659a73e8b2661f15fc087a0c459f5
|
data/.github/workflows/tests.yml
CHANGED
@@ -3,31 +3,47 @@ name: Tests
|
|
3
3
|
on: [push]
|
4
4
|
|
5
5
|
jobs:
|
6
|
+
lint:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
|
9
|
+
strategy:
|
10
|
+
fail-fast: false
|
11
|
+
steps:
|
12
|
+
- uses: actions/checkout@v4
|
13
|
+
|
14
|
+
- name: Set up Ruby
|
15
|
+
uses: ruby/setup-ruby@v1
|
16
|
+
with:
|
17
|
+
bundler-cache: true
|
18
|
+
|
19
|
+
- name: Lint Ruby
|
20
|
+
run: |
|
21
|
+
bin/rubocop
|
22
|
+
|
6
23
|
ruby-tests:
|
7
24
|
runs-on: ubuntu-latest
|
8
25
|
|
9
26
|
strategy:
|
27
|
+
fail-fast: false
|
10
28
|
matrix:
|
11
|
-
ruby: [ '2.
|
29
|
+
ruby: [ '2.7', '3.0', '3.1', '3.2', '3.3' ]
|
12
30
|
steps:
|
13
|
-
- uses: actions/checkout@
|
14
|
-
|
15
|
-
uses: actions/setup-ruby@v1
|
16
|
-
with:
|
17
|
-
ruby-version: ${{ matrix.ruby }}
|
31
|
+
- uses: actions/checkout@v4
|
32
|
+
|
18
33
|
- name: Setup timezone
|
19
34
|
uses: zcong1993/setup-timezone@master
|
20
35
|
with:
|
21
36
|
timezone: UTC
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
37
|
+
|
38
|
+
- name: Set up Ruby ${{ matrix.ruby }}
|
39
|
+
uses: ruby/setup-ruby@v1
|
40
|
+
with:
|
41
|
+
ruby-version: ${{ matrix.ruby }}
|
42
|
+
bundler-cache: true
|
43
|
+
bundler: latest
|
44
|
+
|
27
45
|
- name: Run Ruby tests
|
28
46
|
run: |
|
29
|
-
gem install bundler
|
30
|
-
bundle install --jobs 4 --retry 3
|
31
47
|
bin/rake test
|
32
48
|
env:
|
33
49
|
SUITE: ruby
|
data/.rubocop.yml
CHANGED
@@ -2,8 +2,7 @@ inherit_gem:
|
|
2
2
|
rubocop-shopify: rubocop.yml
|
3
3
|
|
4
4
|
AllCops:
|
5
|
-
|
6
|
-
CacheRootDirectory: tmp/rubocop
|
5
|
+
CacheRootDirectory: tmp/rubocop-cache
|
7
6
|
UseCache: true
|
8
7
|
|
9
8
|
Style/MethodCallWithArgsParentheses:
|
@@ -18,6 +17,8 @@ Style/MethodCallWithArgsParentheses:
|
|
18
17
|
- refute_nil
|
19
18
|
- assert_kind_of
|
20
19
|
- refute_kind_of
|
20
|
+
- assert_predicate
|
21
|
+
- refute_predicate
|
21
22
|
|
22
23
|
Naming/FileName:
|
23
24
|
Exclude:
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.3.0
|
data/CHANGELOG.md
ADDED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,75 +1,96 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
github-authentication (1.0
|
4
|
+
github-authentication (1.2.0)
|
5
5
|
jwt (~> 2.2)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activesupport (
|
10
|
+
activesupport (7.1.2)
|
11
|
+
base64
|
12
|
+
bigdecimal
|
11
13
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
14
|
+
connection_pool (>= 2.2.5)
|
15
|
+
drb
|
12
16
|
i18n (>= 1.6, < 2)
|
13
17
|
minitest (>= 5.1)
|
18
|
+
mutex_m
|
14
19
|
tzinfo (~> 2.0)
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
addressable (2.8.5)
|
21
|
+
public_suffix (>= 2.0.2, < 6.0)
|
22
|
+
ast (2.4.2)
|
23
|
+
base64 (0.2.0)
|
24
|
+
bigdecimal (3.1.4)
|
25
|
+
concurrent-ruby (1.2.2)
|
26
|
+
connection_pool (2.4.1)
|
27
|
+
crack (0.4.5)
|
28
|
+
rexml
|
29
|
+
drb (2.2.0)
|
30
|
+
ruby2_keywords
|
22
31
|
hashdiff (1.0.1)
|
23
|
-
i18n (1.
|
32
|
+
i18n (1.14.1)
|
24
33
|
concurrent-ruby (~> 1.0)
|
25
|
-
|
26
|
-
jwt (2.
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
json (2.7.1)
|
35
|
+
jwt (2.7.1)
|
36
|
+
language_server-protocol (3.17.0.3)
|
37
|
+
minitest (5.20.0)
|
38
|
+
mocha (2.1.0)
|
39
|
+
ruby2_keywords (>= 0.0.5)
|
40
|
+
mutex_m (0.2.0)
|
41
|
+
parallel (1.24.0)
|
42
|
+
parser (3.3.0.5)
|
43
|
+
ast (~> 2.4.1)
|
44
|
+
racc
|
45
|
+
public_suffix (5.0.4)
|
46
|
+
racc (1.7.3)
|
47
|
+
rainbow (3.1.1)
|
48
|
+
rake (13.1.0)
|
49
|
+
regexp_parser (2.9.0)
|
50
|
+
rexml (3.2.6)
|
51
|
+
rubocop (1.62.1)
|
52
|
+
json (~> 2.3)
|
53
|
+
language_server-protocol (>= 3.17.0)
|
38
54
|
parallel (~> 1.10)
|
39
|
-
parser (>=
|
55
|
+
parser (>= 3.3.0.2)
|
40
56
|
rainbow (>= 2.2.2, < 4.0)
|
41
|
-
|
57
|
+
regexp_parser (>= 1.8, < 3.0)
|
58
|
+
rexml (>= 3.2.5, < 4.0)
|
59
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
42
60
|
ruby-progressbar (~> 1.7)
|
43
|
-
unicode-display_width (>=
|
44
|
-
rubocop-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
61
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
62
|
+
rubocop-ast (1.31.2)
|
63
|
+
parser (>= 3.3.0.4)
|
64
|
+
rubocop-shopify (2.14.0)
|
65
|
+
rubocop (~> 1.51)
|
66
|
+
ruby-progressbar (1.13.0)
|
67
|
+
ruby2_keywords (0.0.5)
|
68
|
+
timecop (0.9.8)
|
69
|
+
tzinfo (2.0.6)
|
50
70
|
concurrent-ruby (~> 1.0)
|
51
|
-
unicode-display_width (
|
52
|
-
vcr (
|
53
|
-
webmock (3.
|
54
|
-
addressable (>= 2.
|
71
|
+
unicode-display_width (2.5.0)
|
72
|
+
vcr (6.2.0)
|
73
|
+
webmock (3.19.1)
|
74
|
+
addressable (>= 2.8.0)
|
55
75
|
crack (>= 0.3.2)
|
56
76
|
hashdiff (>= 0.4.0, < 2.0.0)
|
57
|
-
zeitwerk (2.4.2)
|
58
77
|
|
59
78
|
PLATFORMS
|
60
|
-
|
79
|
+
arm64-darwin-21
|
80
|
+
arm64-darwin-22
|
81
|
+
arm64-darwin-23
|
82
|
+
x86_64-linux
|
61
83
|
|
62
84
|
DEPENDENCIES
|
63
85
|
activesupport
|
64
86
|
github-authentication!
|
65
87
|
minitest (~> 5.0)
|
66
|
-
mocha (~>
|
67
|
-
rake (~>
|
68
|
-
rubocop (~> 0.52)
|
88
|
+
mocha (~> 2)
|
89
|
+
rake (~> 13)
|
69
90
|
rubocop-shopify
|
70
91
|
timecop (~> 0.9)
|
71
|
-
vcr (~>
|
92
|
+
vcr (~> 6.2)
|
72
93
|
webmock (~> 3.8)
|
73
94
|
|
74
95
|
BUNDLED WITH
|
75
|
-
2.
|
96
|
+
2.3.8
|
data/Rakefile
CHANGED
data/bin/rake
CHANGED
@@ -9,8 +9,10 @@
|
|
9
9
|
#
|
10
10
|
|
11
11
|
require "pathname"
|
12
|
-
ENV["BUNDLE_GEMFILE"] ||= File.expand_path(
|
13
|
-
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path(
|
13
|
+
"../../Gemfile",
|
14
|
+
Pathname.new(__FILE__).realpath,
|
15
|
+
)
|
14
16
|
|
15
17
|
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
18
|
|
data/bin/rubocop
CHANGED
@@ -9,8 +9,10 @@
|
|
9
9
|
#
|
10
10
|
|
11
11
|
require "pathname"
|
12
|
-
ENV["BUNDLE_GEMFILE"] ||= File.expand_path(
|
13
|
-
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path(
|
13
|
+
"../../Gemfile",
|
14
|
+
Pathname.new(__FILE__).realpath,
|
15
|
+
)
|
14
16
|
|
15
17
|
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
18
|
|
@@ -1,30 +1,35 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require
|
4
|
+
require "github_authentication"
|
5
5
|
|
6
6
|
begin
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
7
|
+
require "active_support"
|
8
|
+
require "active_support/cache"
|
9
|
+
require "active_support/notifications"
|
10
10
|
rescue LoadError
|
11
11
|
warn("Active Support is required for the credential helper")
|
12
12
|
exit(2)
|
13
13
|
end
|
14
14
|
|
15
15
|
case ARGV[0]
|
16
|
-
when
|
16
|
+
when "get"
|
17
|
+
description = $stdin.each_line.map { |line| line.split("=", 2).map(&:strip) }.to_h
|
18
|
+
org = description.fetch("path", "").split("/").first
|
19
|
+
environment = GithubAuthentication::Environment.new(org: org)
|
20
|
+
|
17
21
|
exit_status = GithubAuthentication::GitCredentialHelper.new(
|
18
|
-
pem:
|
19
|
-
app_id:
|
20
|
-
installation_id:
|
21
|
-
storage:
|
22
|
+
pem: environment.pem,
|
23
|
+
app_id: environment.app_id,
|
24
|
+
installation_id: environment.installation_id,
|
25
|
+
storage: environment.storage,
|
26
|
+
description: description,
|
22
27
|
).handle_get
|
23
28
|
exit(exit_status)
|
24
|
-
when
|
29
|
+
when "store"
|
25
30
|
# We maintain our own internal storage, so no-op any `store` requests
|
26
|
-
when nil,
|
27
|
-
warn(
|
31
|
+
when nil, ""
|
32
|
+
warn("Supported operations: get, store")
|
28
33
|
exit(1)
|
29
34
|
else
|
30
35
|
warn("Unknown argument: #{ARGV[0]}")
|
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
|
|
28
28
|
|
29
29
|
# Specify which files should be added to the gem when it is released.
|
30
30
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
31
|
-
spec.files = Dir.chdir(File.expand_path(
|
31
|
+
spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
|
32
32
|
%x(git ls-files -z).split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
33
33
|
end
|
34
34
|
spec.bindir = "exe"
|
@@ -37,13 +37,14 @@ Gem::Specification.new do |spec|
|
|
37
37
|
|
38
38
|
spec.add_dependency("jwt", "~> 2.2")
|
39
39
|
|
40
|
-
spec.
|
40
|
+
spec.required_ruby_version = ">= 2.7.0"
|
41
|
+
|
42
|
+
spec.add_development_dependency("activesupport")
|
41
43
|
spec.add_development_dependency("minitest", "~> 5.0")
|
44
|
+
spec.add_development_dependency("mocha", "~> 2")
|
45
|
+
spec.add_development_dependency("rake", "~> 13")
|
46
|
+
spec.add_development_dependency("rubocop-shopify")
|
42
47
|
spec.add_development_dependency("timecop", "~> 0.9")
|
43
|
-
spec.add_development_dependency("
|
48
|
+
spec.add_development_dependency("vcr", "~> 6.2")
|
44
49
|
spec.add_development_dependency("webmock", "~> 3.8")
|
45
|
-
spec.add_development_dependency("vcr", "~> 5.1")
|
46
|
-
spec.add_development_dependency("rubocop", "~> 0.52")
|
47
|
-
spec.add_development_dependency("rubocop-shopify")
|
48
|
-
spec.add_development_dependency("activesupport")
|
49
50
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "github_authentication/token"
|
4
4
|
|
5
5
|
module GithubAuthentication
|
6
6
|
class Cache
|
7
7
|
# storage = ActiveSupport::Cache
|
8
|
-
def initialize(storage:, key:
|
8
|
+
def initialize(storage:, key: "")
|
9
9
|
@storage = storage
|
10
10
|
@key = "github:authentication:#{key}"
|
11
11
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/core_ext/object/blank.rb"
|
4
|
+
|
5
|
+
module GithubAuthentication
|
6
|
+
class Environment
|
7
|
+
def initialize(org:, env: ENV)
|
8
|
+
@org = org.presence
|
9
|
+
@env = env
|
10
|
+
end
|
11
|
+
|
12
|
+
def pem
|
13
|
+
File.read(resolve("GITHUB_APP_KEYFILE"))
|
14
|
+
end
|
15
|
+
|
16
|
+
def app_id
|
17
|
+
resolve("GITHUB_APP_ID")
|
18
|
+
end
|
19
|
+
|
20
|
+
def installation_id
|
21
|
+
resolve("GITHUB_APP_INSTALLATION_ID")
|
22
|
+
end
|
23
|
+
|
24
|
+
def storage
|
25
|
+
ActiveSupport::Cache::FileStore.new(resolve("GITHUB_APP_CREDENTIAL_STORAGE_PATH"))
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def resolve(suffix)
|
31
|
+
if @org
|
32
|
+
@env["#{@org.upcase}_#{suffix}"] || @env.fetch(suffix)
|
33
|
+
else
|
34
|
+
@env.fetch(suffix)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -2,25 +2,23 @@
|
|
2
2
|
|
3
3
|
module GithubAuthentication
|
4
4
|
class GitCredentialHelper
|
5
|
-
def initialize(pem:, installation_id:, app_id:, storage: nil
|
5
|
+
def initialize(pem:, installation_id:, app_id:, description:, storage: nil)
|
6
6
|
@pem = pem
|
7
7
|
@installation_id = installation_id
|
8
8
|
@app_id = app_id
|
9
|
+
@description = description
|
9
10
|
@storage = storage
|
10
|
-
@stdin = stdin
|
11
11
|
end
|
12
12
|
|
13
13
|
def handle_get
|
14
|
-
description
|
15
|
-
|
16
|
-
unless description['protocol'] == 'https' && description['host'] == 'github.com'
|
17
|
-
warn("Unsupported description: #{description}")
|
14
|
+
unless @description["protocol"] == "https" && @description["host"] == "github.com"
|
15
|
+
warn("Unsupported description: #{@description}")
|
18
16
|
return 2
|
19
17
|
end
|
20
18
|
|
21
19
|
token = provider.token(seconds_ttl: min_cache_ttl)
|
22
20
|
puts("password=#{token}")
|
23
|
-
puts(
|
21
|
+
puts("username=api")
|
24
22
|
|
25
23
|
0
|
26
24
|
end
|
@@ -32,16 +30,10 @@ module GithubAuthentication
|
|
32
30
|
10 * 60
|
33
31
|
end
|
34
32
|
|
35
|
-
def parse_stdin
|
36
|
-
# Credential description is written to STDIN in line delimited key=value form,
|
37
|
-
# see https://git-scm.com/docs/git-credential#IOFMT
|
38
|
-
@stdin.each_line.map { |line| line.split('=', 2).map(&:strip) }.to_h
|
39
|
-
end
|
40
|
-
|
41
33
|
def provider
|
42
34
|
@provider ||= Provider.new(
|
43
35
|
generator: generator,
|
44
|
-
cache: Cache.new(storage: @storage || ObjectCache.new)
|
36
|
+
cache: Cache.new(storage: @storage || ObjectCache.new),
|
45
37
|
)
|
46
38
|
end
|
47
39
|
|
@@ -49,7 +41,7 @@ module GithubAuthentication
|
|
49
41
|
@generator ||= Generator::App.new(
|
50
42
|
pem: @pem,
|
51
43
|
app_id: @app_id,
|
52
|
-
installation_id: @installation_id
|
44
|
+
installation_id: @installation_id,
|
53
45
|
)
|
54
46
|
end
|
55
47
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "net/http"
|
4
|
+
require "timeout"
|
5
5
|
|
6
|
-
require
|
6
|
+
require "github_authentication/retriable"
|
7
7
|
|
8
8
|
module GithubAuthentication
|
9
9
|
module Http
|
@@ -17,7 +17,6 @@ module GithubAuthentication
|
|
17
17
|
http.use_ssl = true
|
18
18
|
http.start
|
19
19
|
begin
|
20
|
-
|
21
20
|
request = Net::HTTP::Post.new(uri.request_uri)
|
22
21
|
yield(request) if block_given?
|
23
22
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "github_authentication/token"
|
4
4
|
|
5
5
|
module GithubAuthentication
|
6
6
|
class ObjectCache
|
@@ -14,7 +14,7 @@ module GithubAuthentication
|
|
14
14
|
options = @cache[key][:options]
|
15
15
|
if options.key?(:expires_at) && Time.now.utc > options[:expires_at]
|
16
16
|
@cache.delete(key)
|
17
|
-
return
|
17
|
+
return
|
18
18
|
end
|
19
19
|
|
20
20
|
@cache[key][:value]
|
@@ -1,28 +1,26 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require "mutex_m.rb"
|
3
2
|
|
4
|
-
require
|
3
|
+
require "github_authentication/retriable"
|
5
4
|
|
6
5
|
module GithubAuthentication
|
7
6
|
class Provider
|
8
7
|
include Retriable
|
9
|
-
include Mutex_m
|
10
8
|
|
11
9
|
Error = Class.new(StandardError)
|
12
10
|
TokenGeneratorError = Class.new(Error)
|
13
11
|
|
14
12
|
def initialize(generator:, cache:)
|
15
|
-
super()
|
16
13
|
@token = nil
|
17
14
|
@generator = generator
|
18
15
|
@cache = cache
|
16
|
+
@mutex = Mutex.new
|
19
17
|
end
|
20
18
|
|
21
19
|
def token(seconds_ttl: 5 * 60)
|
22
20
|
return @token if @token&.valid_for?(seconds_ttl)
|
23
21
|
|
24
22
|
with_retries(TokenGeneratorError) do
|
25
|
-
|
23
|
+
@mutex.synchronize do
|
26
24
|
return @token if @token&.valid_for?(seconds_ttl)
|
27
25
|
|
28
26
|
if (@token = @cache.read)
|
@@ -9,12 +9,12 @@ module GithubAuthentication
|
|
9
9
|
begin
|
10
10
|
return_value = yield(attempt, previous_failure)
|
11
11
|
rescue *exceptions => exception
|
12
|
-
raise
|
12
|
+
raise if attempt >= max_attempts
|
13
13
|
|
14
14
|
sleep_after_attempt(
|
15
15
|
attempt: attempt,
|
16
16
|
base_sleep_time: sleep_between_attempts,
|
17
|
-
exponential_backoff: exponential_backoff
|
17
|
+
exponential_backoff: exponential_backoff,
|
18
18
|
)
|
19
19
|
|
20
20
|
attempt += 1
|
@@ -28,7 +28,7 @@ module GithubAuthentication
|
|
28
28
|
private
|
29
29
|
|
30
30
|
def sleep_after_attempt(attempt:, base_sleep_time:, exponential_backoff:)
|
31
|
-
return
|
31
|
+
return if base_sleep_time <= 0
|
32
32
|
|
33
33
|
time_to_sleep = if exponential_backoff
|
34
34
|
calculate_exponential_backoff(attempt: attempt, base_sleep_time: base_sleep_time)
|
@@ -1,18 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "json"
|
4
4
|
|
5
5
|
module GithubAuthentication
|
6
6
|
class Token
|
7
7
|
attr_reader :expires_at
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
class << self
|
10
|
+
def from_json(data)
|
11
|
+
return if data.nil?
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
token, expires_at = JSON.parse(data).values_at("token", "expires_at")
|
14
|
+
new(token, Time.iso8601(expires_at))
|
15
|
+
rescue JSON::ParserError
|
16
|
+
nil
|
17
|
+
end
|
16
18
|
end
|
17
19
|
|
18
20
|
def initialize(token, expires_at)
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: github-authentication
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Frederik Dudzik
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: jwt
|
@@ -25,19 +24,19 @@ dependencies:
|
|
25
24
|
- !ruby/object:Gem::Version
|
26
25
|
version: '2.2'
|
27
26
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
27
|
+
name: activesupport
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
30
29
|
requirements:
|
31
|
-
- - "
|
30
|
+
- - ">="
|
32
31
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
32
|
+
version: '0'
|
34
33
|
type: :development
|
35
34
|
prerelease: false
|
36
35
|
version_requirements: !ruby/object:Gem::Requirement
|
37
36
|
requirements:
|
38
|
-
- - "
|
37
|
+
- - ">="
|
39
38
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
39
|
+
version: '0'
|
41
40
|
- !ruby/object:Gem::Dependency
|
42
41
|
name: minitest
|
43
42
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,103 +52,89 @@ dependencies:
|
|
53
52
|
- !ruby/object:Gem::Version
|
54
53
|
version: '5.0'
|
55
54
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
55
|
+
name: mocha
|
57
56
|
requirement: !ruby/object:Gem::Requirement
|
58
57
|
requirements:
|
59
58
|
- - "~>"
|
60
59
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
60
|
+
version: '2'
|
62
61
|
type: :development
|
63
62
|
prerelease: false
|
64
63
|
version_requirements: !ruby/object:Gem::Requirement
|
65
64
|
requirements:
|
66
65
|
- - "~>"
|
67
66
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
67
|
+
version: '2'
|
69
68
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
69
|
+
name: rake
|
71
70
|
requirement: !ruby/object:Gem::Requirement
|
72
71
|
requirements:
|
73
72
|
- - "~>"
|
74
73
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
74
|
+
version: '13'
|
76
75
|
type: :development
|
77
76
|
prerelease: false
|
78
77
|
version_requirements: !ruby/object:Gem::Requirement
|
79
78
|
requirements:
|
80
79
|
- - "~>"
|
81
80
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
81
|
+
version: '13'
|
83
82
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
83
|
+
name: rubocop-shopify
|
85
84
|
requirement: !ruby/object:Gem::Requirement
|
86
85
|
requirements:
|
87
|
-
- - "
|
86
|
+
- - ">="
|
88
87
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
88
|
+
version: '0'
|
90
89
|
type: :development
|
91
90
|
prerelease: false
|
92
91
|
version_requirements: !ruby/object:Gem::Requirement
|
93
92
|
requirements:
|
94
|
-
- - "
|
93
|
+
- - ">="
|
95
94
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
95
|
+
version: '0'
|
97
96
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
97
|
+
name: timecop
|
99
98
|
requirement: !ruby/object:Gem::Requirement
|
100
99
|
requirements:
|
101
100
|
- - "~>"
|
102
101
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
102
|
+
version: '0.9'
|
104
103
|
type: :development
|
105
104
|
prerelease: false
|
106
105
|
version_requirements: !ruby/object:Gem::Requirement
|
107
106
|
requirements:
|
108
107
|
- - "~>"
|
109
108
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
109
|
+
version: '0.9'
|
111
110
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
111
|
+
name: vcr
|
113
112
|
requirement: !ruby/object:Gem::Requirement
|
114
113
|
requirements:
|
115
114
|
- - "~>"
|
116
115
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
116
|
+
version: '6.2'
|
118
117
|
type: :development
|
119
118
|
prerelease: false
|
120
119
|
version_requirements: !ruby/object:Gem::Requirement
|
121
120
|
requirements:
|
122
121
|
- - "~>"
|
123
122
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
123
|
+
version: '6.2'
|
125
124
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - ">="
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '0'
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - ">="
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '0'
|
139
|
-
- !ruby/object:Gem::Dependency
|
140
|
-
name: activesupport
|
125
|
+
name: webmock
|
141
126
|
requirement: !ruby/object:Gem::Requirement
|
142
127
|
requirements:
|
143
|
-
- - "
|
128
|
+
- - "~>"
|
144
129
|
- !ruby/object:Gem::Version
|
145
|
-
version: '
|
130
|
+
version: '3.8'
|
146
131
|
type: :development
|
147
132
|
prerelease: false
|
148
133
|
version_requirements: !ruby/object:Gem::Requirement
|
149
134
|
requirements:
|
150
|
-
- - "
|
135
|
+
- - "~>"
|
151
136
|
- !ruby/object:Gem::Version
|
152
|
-
version: '
|
137
|
+
version: '3.8'
|
153
138
|
description: Authenticate with GitHub
|
154
139
|
email:
|
155
140
|
- frederik.dudzik@shopify.com
|
@@ -161,7 +146,8 @@ files:
|
|
161
146
|
- ".github/workflows/tests.yml"
|
162
147
|
- ".gitignore"
|
163
148
|
- ".rubocop.yml"
|
164
|
-
- ".
|
149
|
+
- ".ruby-version"
|
150
|
+
- CHANGELOG.md
|
165
151
|
- Gemfile
|
166
152
|
- Gemfile.lock
|
167
153
|
- LICENSE.txt
|
@@ -177,6 +163,7 @@ files:
|
|
177
163
|
- lib/github-authentication.rb
|
178
164
|
- lib/github_authentication.rb
|
179
165
|
- lib/github_authentication/cache.rb
|
166
|
+
- lib/github_authentication/environment.rb
|
180
167
|
- lib/github_authentication/generator.rb
|
181
168
|
- lib/github_authentication/generator/app.rb
|
182
169
|
- lib/github_authentication/generator/personal.rb
|
@@ -194,7 +181,6 @@ metadata:
|
|
194
181
|
homepage_uri: https://github.com/Shopify/github-authentication
|
195
182
|
source_code_uri: https://github.com/Shopify/github-authentication
|
196
183
|
allowed_push_host: https://rubygems.org
|
197
|
-
post_install_message:
|
198
184
|
rdoc_options: []
|
199
185
|
require_paths:
|
200
186
|
- lib
|
@@ -202,15 +188,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
202
188
|
requirements:
|
203
189
|
- - ">="
|
204
190
|
- !ruby/object:Gem::Version
|
205
|
-
version:
|
191
|
+
version: 2.7.0
|
206
192
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
207
193
|
requirements:
|
208
194
|
- - ">="
|
209
195
|
- !ruby/object:Gem::Version
|
210
196
|
version: '0'
|
211
197
|
requirements: []
|
212
|
-
rubygems_version: 3.
|
213
|
-
signing_key:
|
198
|
+
rubygems_version: 3.7.1
|
214
199
|
specification_version: 4
|
215
200
|
summary: GitHub Authetication
|
216
201
|
test_files: []
|