Documentation
¶
Overview ¶
Package auth implements GitHub authentication for the Hive desktop app: the Wails auth service, its live (device flow + PAT) and mock backends, and the wire types the onboarding UI consumes. Desktop-only code lives under internal/desktop; the GitHub client itself is internal/github.
Index ¶
Constants ¶
const ( StateUnauthenticated = "unauthenticated" StateAuthenticated = "authenticated" )
Auth states on the wire. Strings, not enums: the frontend narrows them.
const EnvGitHubClientID = "HIVE_GITHUB_CLIENT_ID"
EnvGitHubClientID overrides the OAuth app client ID used by the device flow, e.g. to test against a different OAuth app registration.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend interface {
Status(ctx context.Context) Status
StartDeviceFlow(ctx context.Context) (DeviceFlowInfo, error)
CancelDeviceFlow()
SetToken(ctx context.Context, token string) (Status, error)
SignOut() error
}
Backend implements authentication for Service. liveAuth talks to GitHub; mockAuth drives deterministic onboarding for tests and e2e.
func NewLiveBackend ¶
func NewLiveBackend(client *github.Client, tokens github.TokenStore, onChange func()) Backend
func NewMockBackend ¶
type DeviceFlowInfo ¶
type DeviceFlowInfo struct {
UserCode string `json:"userCode"`
VerificationURI string `json:"verificationUri"`
}
DeviceFlowInfo is the pending device authorization the onboarding screen renders: the user opens VerificationURI and enters UserCode.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the Wails service exposing authentication to the frontend. State changes are pushed via the auth:updated event; the frontend re-reads Status on receipt.
func NewService ¶
func (*Service) CancelDeviceFlow ¶
func (s *Service) CancelDeviceFlow()
func (*Service) StartDeviceFlow ¶
func (s *Service) StartDeviceFlow() (DeviceFlowInfo, error)
type Status ¶
type Status struct {
State string `json:"state"` // StateUnauthenticated | StateAuthenticated
Login string `json:"login"`
Name string `json:"name"`
AvatarURL string `json:"avatarUrl"`
// Message carries a user-facing problem description (invalid stored
// token, device flow failure) without changing the state machine.
Message string `json:"message"`
}
Status is the authentication state shown to the frontend.