Class: GithubAuthentication::GitCredentialHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/github_authentication/git_credential_helper.rb

Instance Method Summary collapse

Constructor Details

#initialize(provider:, description:) ⇒ GitCredentialHelper

Returns a new instance of GitCredentialHelper.



5
6
7
8
# File 'lib/github_authentication/git_credential_helper.rb', line 5

def initialize(provider:, description:)
  @provider = provider
  @description = description
end

Instance Method Details

#handle_getObject



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/github_authentication/git_credential_helper.rb', line 10

def handle_get
  unless @description["protocol"] == "https" && @description["host"] == "github.com"
    warn("Unsupported description: #{@description}")
    return 2
  end

  token = @provider.token(seconds_ttl: min_cache_ttl)
  puts("password=#{token}")
  puts("username=api")

  0
end