Documentation
¶
Overview ¶
Package githubauth owns GitHub.com device authorization and credentials.
Index ¶
- Constants
- Variables
- func ServeCredentialHelper(ctx context.Context, input io.Reader, output io.Writer) error
- type Credential
- type Device
- type Manager
- func (m *Manager) AccountForToken(token string) int64
- func (m *Manager) Cancel(ctx context.Context, id string) error
- func (m *Manager) Disconnect(ctx context.Context) error
- func (m *Manager) Health() error
- func (m *Manager) IdentityContext(ctx context.Context) (context.Context, func())
- func (m *Manager) ObserveResponse(token string, status int, headers http.Header)
- func (m *Manager) Poll(ctx context.Context, id string) (Status, error)
- func (m *Manager) Revision() uint64
- func (m *Manager) Start(ctx context.Context) (Device, error)
- func (m *Manager) Status(ctx context.Context) (Status, error)
- func (m *Manager) Token(ctx context.Context) (token string, returnedErr error)
- func (m *Manager) WithIdentity(ctx context.Context, publish func() error) error
- type Options
- type ProcessStore
- type Status
- type Store
Constants ¶
const ClientID = "Ov23liFSMjrhof9WQlOi"
const Scopes = "repo read:org"
Variables ¶
var ErrNotConnected = errors.New("GitHub is not connected")
var ErrPermissions = errors.New("check repository access and GitHub authorization permissions")
var ErrReconnect = errors.New("GitHub authorization expired or was revoked; reconnect GitHub")
var ErrRequest = errors.New("GitHub authentication request failed; try again")
var ErrSSO = errors.New("authorize baum for your organization's GitHub SSO and retry")
var ErrScopes = errors.New("GitHub authorization requires repo and read:org access")
var ErrStore = errors.New("GitHub credential store unavailable; unlock your operating system credential store and try again")
Functions ¶
func ServeCredentialHelper ¶
ServeCredentialHelper is only for the hidden CLI helper. The native store runs synchronously here; ProcessStore owns this process's deadline and waits for termination before releasing its caller's serialization lock.
Types ¶
type Credential ¶
type Credential struct {
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token,omitempty"`
ExpiresAt int64 `json:"expires_at,omitempty"`
RefreshExpiresAt int64 `json:"refresh_expires_at,omitempty"`
Login string `json:"login"`
ID int64 `json:"id"`
}
Credential is daemon-only state and must never be exposed by a public API. JSON is reserved for persistence in the operating system credential store.
func (Credential) GoString ¶
func (Credential) GoString() string
func (Credential) String ¶
func (Credential) String() string
String and GoString keep routine diagnostics from disclosing credentials.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager serializes credential refresh, persistence and account replacement. Poll performs at most one exchange; callers can poll freely without exceeding GitHub's requested interval. Only one device authorization is active at a time.
func NewWithOptions ¶
func (*Manager) AccountForToken ¶
AccountForToken identifies only the credential most recently issued by Token. A late lookup for an older token never inherits the replacement account ID.
func (*Manager) IdentityContext ¶
IdentityContext cancels evidence work when the selected account changes. Token refresh does not cancel work because it retains the same identity.
func (*Manager) ObserveResponse ¶
ObserveResponse ignores late failures for a credential no longer in use. Upstream bodies and header values are never retained or exposed.
type Options ¶
type Options struct{ Transport http.RoundTripper }
type ProcessStore ¶
type ProcessStore struct{ Executable string }
ProcessStore bounds native credential-store prompts by running them in a helper process. Secrets travel only through private pipes, never argv or env. Every operation waits for the helper to exit before returning, so cancellation cannot leave a detached save racing a later disconnect.
func (ProcessStore) Load ¶
func (s ProcessStore) Load(ctx context.Context) (Credential, error)
func (ProcessStore) Save ¶
func (s ProcessStore) Save(ctx context.Context, c Credential) error