auth

package
v0.26.1 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const RouterAppURL = "https://app.nullify.ai"

RouterAppURL is the dashboard URL for users who sign in through the router.

View Source
const RouterHost = "nullify.ai"

RouterHost is the bare host of the Nullify router, which serves sign-in but not tenant data.

Variables

View Source
var ErrNoDataHost = errors.New("no installation selected for nullify.ai - run 'nullify auth login' or 'nullify auth switch --installation <name>'")

ErrNoDataHost reports that the router credentials have no selected installation.

View Source
var ErrNotRefreshable = errors.New("no refresh token stored")

ErrNotRefreshable reports that the stored credentials for a host carry no refresh token, so no amount of retrying will produce a new access token.

Functions

func CheckSession added in v0.26.0

func CheckSession(ctx context.Context, host string) error

CheckSession returns an error unless host has a valid token and, for the router, a selected installation.

func CredentialKey added in v0.13.0

func CredentialKey(host string) string

CredentialKey normalizes a host to its bare form (without "api." prefix) so that credentials are stored and looked up consistently regardless of whether the caller passes "acme.nullify.ai" or "api.acme.nullify.ai".

func DataHost added in v0.26.0

func DataHost(authHost string) (string, error)

DataHost returns the host that serves data for the credentials stored under authHost.

func DeleteHostCredentials

func DeleteHostCredentials(host string) error

func ForceRefreshToken added in v0.25.3

func ForceRefreshToken(ctx context.Context, host string) (string, error)

ForceRefreshToken exchanges the stored refresh token for a new access token regardless of the recorded expiry. GetValidToken only refreshes once ExpiresAt has elapsed, which leaves callers no way to recover from a token the server rejects while the CLI still believes it is valid -- revocation, a killed session, or a local clock running behind the server's.

func GetValidToken

func GetValidToken(ctx context.Context, host string) (string, error)

func IsRouterHost added in v0.26.0

func IsRouterHost(host string) bool

IsRouterHost reports whether host is a bare, "api." or "app." form of the router host.

func Login

func Login(ctx context.Context, host string, picker InstallationPicker) error

Login signs in to host in the browser. For the router host it also selects the installation that serves data.

func Logout

func Logout(host string) error

func OpenBrowser added in v0.13.0

func OpenBrowser(url string) error

OpenBrowser opens the given URL in the user's default browser.

func SaveConfig

func SaveConfig(cfg *Config) error

func SaveCredentials

func SaveCredentials(creds Credentials) error

func SaveHostCredentials

func SaveHostCredentials(host string, hostCreds HostCredentials) error

Types

type Config

type Config struct {
	Host string `json:"host"`
}

func LoadConfig

func LoadConfig() (*Config, error)

type Credentials

type Credentials map[string]HostCredentials

func LoadCredentials

func LoadCredentials() (Credentials, error)

type HostCredentials

type HostCredentials struct {
	AccessToken     string            `json:"access_token"`
	RefreshToken    string            `json:"refresh_token"`
	ExpiresAt       int64             `json:"expires_at"`
	QueryParameters map[string]string `json:"query_parameters,omitempty"`
	DataHost        string            `json:"data_host,omitempty"`
	Installation    string            `json:"installation,omitempty"`
}

type Installation added in v0.26.0

type Installation struct {
	Name            string
	DataHost        string
	QueryParameters map[string]string
}

Installation is a tenant installation that the router can route the user to.

func SwitchInstallation added in v0.26.0

func SwitchInstallation(ctx context.Context, name string) (Installation, error)

SwitchInstallation selects the named installation for the stored router credentials and makes the router the default host.

type InstallationPicker added in v0.26.0

type InstallationPicker struct {
	Name        string
	Interactive bool
	In          io.Reader
	Out         io.Writer
}

InstallationPicker selects one installation by name, by prompt, or automatically when only one exists.

func (InstallationPicker) Pick added in v0.26.0

func (p InstallationPicker) Pick(installs []Installation) (Installation, error)

Pick returns the selected installation from installs.

Jump to

Keyboard shortcuts

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