Class: GithubAuthentication::GitCredentialHelper

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

Instance Method Summary collapse

Constructor Details

#initialize(pem:, installation_id:, app_id:, storage: nil, stdin: $stdin) ⇒ GitCredentialHelper

Returns a new instance of GitCredentialHelper.



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

def initialize(pem:, installation_id:, app_id:, storage: nil, stdin: $stdin)
  @pem = pem
  @installation_id = installation_id
  @app_id = app_id
  @storage = storage
  @stdin = stdin
end

Instance Method Details

#handle_getObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/github_authentication/git_credential_helper.rb', line 13

def handle_get
  description = parse_stdin

  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