gitauth

package
v0.0.0-...-03d6fc4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 23, 2019 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Overview

A Go implementation of https://gerrit.googlesource.com/gcompute-tools/+/master/git-cookie-authdaemon

Index

Constants

View Source
const (
	REFRESH        = time.Minute
	RETRY_INTERVAL = 5 * time.Second
)

Variables

View Source
var (
	ErrCookiesMissing = errors.New("Unable to find a valid .gitcookies file.")

	// SCOPES are the list of valid scopes for git auth.
	SCOPES = []string{
		"https://www.googleapis.com/auth/gerritcodereview",
		"https://www.googleapis.com/auth/source.full_control",
		"https://www.googleapis.com/auth/source.read_write",
		"https://www.googleapis.com/auth/source.read_only",
	}
)

Functions

func AddAuthenticationCookie

func AddAuthenticationCookie(gitCookiesPath string, req *http.Request) error

AddAuthenticationCookie adds a git authentication cookie to the given request.

TODO(borenet): It would be nice if this could be part of an http.Client, or use an http.CookieJar in combination with the above code so that we don't have to call AddAuthenticationCookie manually all the time.

Types

type GitAuth

type GitAuth struct {
	// contains filtered or unexported fields
}

GitAuth continuously updates the git cookie.

func New

func New(tokenSource oauth2.TokenSource, filename string, config bool, email string) (*GitAuth, error)

New returns a new *GitAuth.

tokenSource - An oauth2.TokenSource authorized to access the repository, with an appropriate scope set. filename - The name of the git cookie file, e.g. "~/.git-credential-cache/cookie". config - If true then set the http.cookiefile config globally for git and set the user name and email globally if 'email' is not the empty string. email - The email address of the authorized account. Used to set the git config user.name and user.email. Can be "", in which case user.name

and user.email are not set.

If config if false then Git must be told about the location of the Cookie file, for example:

git config --global http.cookiefile ~/.git-credential-cache/cookie

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL