auth

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearToken

func ClearToken() error

ClearToken removes the authentication token from the OS credential manager

func IsAuthenticated

func IsAuthenticated() bool

IsAuthenticated checks if a valid token exists

func SaveToken

func SaveToken(githubToken string) error

SaveToken saves the GitHub access token to the OS credential manager

Types

type AuthToken

type AuthToken struct {
	// GitHub OAuth Token (used directly with MoMorph API)
	GitHubToken string `json:"github_token"`
}

AuthToken stores GitHub OAuth token for MoMorph authentication

func LoadToken

func LoadToken() (*AuthToken, error)

LoadToken loads the authentication token from the OS credential manager

func (*AuthToken) IsValid

func (t *AuthToken) IsValid() bool

IsValid checks if the GitHub token exists

type ConnectedAccount added in v0.2.0

type ConnectedAccount struct {
	ID             int    `json:"id"`
	MorpheusUserID int    `json:"morpheus_user_id"`
	Name           string `json:"name"`
	Email          string `json:"email"`
	Provider       string `json:"provider"`
	ProviderID     string `json:"provider_id"`
	PhotoURL       string `json:"photo_url"`
	CreatedAt      string `json:"created_at"`
	UpdatedAt      string `json:"updated_at"`
}

ConnectedAccount represents a connected OAuth account

type DeviceCodeResponse

type DeviceCodeResponse struct {
	DeviceCode      string `json:"device_code"`
	UserCode        string `json:"user_code"`
	VerificationURI string `json:"verification_uri"`
	ExpiresIn       int    `json:"expires_in"`
	Interval        int    `json:"interval"`
}

DeviceCodeResponse represents GitHub's device code response

func RequestDeviceCode

func RequestDeviceCode(ctx context.Context) (*DeviceCodeResponse, error)

RequestDeviceCode requests a device code from GitHub

type GitHubUser

type GitHubUser struct {
	Login     string `json:"login"`
	ID        int    `json:"id"`
	AvatarURL string `json:"avatar_url"`
	Name      string `json:"name"`
	Email     string `json:"email"`
}

GitHubUser represents a GitHub user

func GetAuthenticatedUser

func GetAuthenticatedUser(ctx context.Context, accessToken string) (*GitHubUser, error)

GetAuthenticatedUser retrieves the authenticated user's information from GitHub

type MoMorphTokenResponse

type MoMorphTokenResponse struct {
	Token string `json:"token"`
}

MoMorphTokenResponse represents the response from MoMorph token exchange Deprecated: No longer needed, use GitHub token directly

func ExchangeGitHubToken

func ExchangeGitHubToken(ctx context.Context, githubToken string) (*MoMorphTokenResponse, error)

ExchangeGitHubToken exchanges a GitHub OAuth token for a MoMorph platform token Deprecated: No longer needed, use GitHub token directly

type MoMorphUser added in v0.2.0

type MoMorphUser struct {
	ID                string
	Email             string
	Username          string
	AvatarURL         string
	CreatedAt         string
	TimeZone          string
	ConnectedAccounts []ConnectedAccount
}

MoMorphUser represents a MoMorph user from the whoami API

func GetMoMorphUser added in v0.2.0

func GetMoMorphUser(ctx context.Context, githubToken string) (*MoMorphUser, error)

GetMoMorphUser fetches the authenticated user information from MoMorph API

type TokenResponse

type TokenResponse struct {
	AccessToken string `json:"access_token"`
	TokenType   string `json:"token_type"`
	Scope       string `json:"scope"`
	Error       string `json:"error"`
	ErrorDesc   string `json:"error_description"`
}

TokenResponse represents GitHub's token response

func PollForToken

func PollForToken(ctx context.Context, deviceCode string, interval int) (*TokenResponse, error)

PollForToken polls GitHub for the access token

type WhoAmIExtra added in v0.2.0

type WhoAmIExtra struct {
	Provider string     `json:"provider"`
	User     WhoAmIUser `json:"user"`
}

WhoAmIExtra represents the extra field in whoami response

type WhoAmIResponse added in v0.2.0

type WhoAmIResponse struct {
	Subject int         `json:"subject"`
	Extra   WhoAmIExtra `json:"extra"`
}

WhoAmIResponse represents the full whoami API response

type WhoAmIUser added in v0.2.0

type WhoAmIUser struct {
	ID                int                `json:"id"`
	Email             string             `json:"email"`
	LastActiveFileKey string             `json:"last_active_file_key"`
	LastActiveAt      string             `json:"last_active_at"`
	DefaultLanguage   string             `json:"default_language"`
	TimeZone          string             `json:"time_zone"`
	CreatedAt         string             `json:"created_at"`
	UpdatedAt         string             `json:"updated_at"`
	ConnectedAccounts []ConnectedAccount `json:"connected_accounts"`
}

WhoAmIUser represents user data in the whoami response

Jump to

Keyboard shortcuts

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