auth_ui

package
v3.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2025 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotURLSafe = errors.New("not a valid url safe string")
	ErrRequired   = errors.New("can not be empty")
)
View Source
var Theme = huh.ThemeBase16()

Functions

This section is empty.

Types

type CLI

type CLI struct{}

CLI is the archaic fallback UI for auth.

func (*CLI) ConfirmationCode

func (*CLI) ConfirmationCode(email string) (code int, err error)

func (*CLI) RequestCreds

func (*CLI) RequestCreds(w io.Writer, workspace string) (email string, passwd string, err error)

func (*CLI) RequestLoginType

func (cl *CLI) RequestLoginType(w io.Writer) (LoginType, error)

func (*CLI) RequestWorkspace

func (cl *CLI) RequestWorkspace(w io.Writer) (string, error)

func (*CLI) Stop

func (*CLI) Stop()

type Huh

type Huh struct{}

Huh is the Auth UI that uses the huh library to provide a terminal UI.

func (*Huh) ConfirmationCode

func (*Huh) ConfirmationCode(email string) (int, error)

ConfirmationCode asks the user to input the confirmation code, does some validation on it and returns it as an int.

func (*Huh) RequestCreds

func (*Huh) RequestCreds(ctx context.Context, w io.Writer, workspace string) (email string, passwd string, err error)

func (*Huh) RequestLoginType

func (*Huh) RequestLoginType(ctx context.Context, w io.Writer, workspace string) (LoginOpts, error)

func (*Huh) RequestWorkspace

func (h *Huh) RequestWorkspace(w io.Writer) (string, error)

func (*Huh) Stop

func (*Huh) Stop()

type LoginOpts

type LoginOpts struct {
	Workspace   string
	Type        LoginType
	BrowserPath string
}

type LoginType

type LoginType int8

LoginType is the login type, that is used to choose the authentication flow, for example login headlessly or interactively.

const (
	// LInteractive is the SSO login type (Google, Apple, etc).
	LInteractive LoginType = iota
	// LHeadless is the email/password login type.
	LHeadless
	// LUserBrowser is the google auth option
	LUserBrowser
	// LCancel should be returned if the user cancels the login intent.
	LCancel
)

Jump to

Keyboard shortcuts

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