auth

package
v0.0.76 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	API_URL  = "api_url"
	API_KEY  = "api_key"
	ENV_NAME = "name"

	ENVIRONMENTS_CONFIG_PATH = "envs"
	AUTH_CONFIG_PATH         = "auth"

	CURRENT_ENV = "current_env"
)
View Source
const API_CLOUD_SUBDOMAIN = "://api."
View Source
const API_PATH = "/api/v2"

Variables

View Source
var (
	// just for backward compatibility, will use just current_env and envs in the future
	API_KEY_CONFIG_PATH = getAuthPath(API_KEY)
	API_URL_CONFIG_PATH = getAuthPath(API_URL)
)
View Source
var ErrNotLoggedIn = fmt.Errorf("not logged in")

Functions

func AskForApiKey added in v0.0.74

func AskForApiKey() (string, error)

func AskForUrl added in v0.0.74

func AskForUrl(defaultUrl string) (string, error)

func AskForUserNameAndPassword added in v0.0.74

func AskForUserNameAndPassword(userName, password string) (string, string, error)

func AskIfOpenBrowser added in v0.0.74

func AskIfOpenBrowser() (bool, error)

func AskIfUseLogin added in v0.0.74

func AskIfUseLogin() (bool, error)

func ChangeToUIUrl added in v0.0.76

func ChangeToUIUrl(apiUrl string) string

func CheckLoggedIn

func CheckLoggedIn() error

func EnvNameFromUrl added in v0.0.43

func EnvNameFromUrl(url string) string

func GetWhoami added in v0.0.43

func GetWhoami(ctx context.Context) (*tensorleapapi.UserData, error)

func IsApiBaseUrlSet

func IsApiBaseUrlSet() bool

func IsLocalUrl added in v0.0.45

func IsLocalUrl(url string) bool

func Login

func Login(env *Env) (err error)

func LoginAndGetAuthToken added in v0.0.74

func LoginAndGetAuthToken(apiUrl, username, password string) (string, error)

func LoginAndGetAuthTokenWithBrowser added in v0.0.74

func LoginAndGetAuthTokenWithBrowser(ctx context.Context, apiUrl string) (string, error)

func Logout

func Logout(envName string) error

func NormalizeAPIUrl added in v0.0.74

func NormalizeAPIUrl(url string) (string, error)

func PrintWhoami added in v0.0.43

func PrintWhoami(ctx context.Context) error

func SelectAndSetEnv added in v0.0.43

func SelectAndSetEnv(envName string) error

Types

type ApiKeyResponse added in v0.0.74

type ApiKeyResponse struct {
	ApiKey string `json:"apiKey"`
}

the response is a json with key apiToken

type Env added in v0.0.43

type Env struct {
	Name   string
	ApiUrl string
	ApiKey string
}

func GetCurrentEnv added in v0.0.43

func GetCurrentEnv() *Env

func GetEnvAuth added in v0.0.43

func GetEnvAuth(name string) (*Env, error)

func GetEnvs added in v0.0.43

func GetEnvs() []Env

func NewEnv added in v0.0.43

func NewEnv(name, apiUrl, apiKey string) *Env

func SelectEnv added in v0.0.43

func SelectEnv(msg string, envName string) (*Env, error)

func (*Env) AuthContext added in v0.0.43

func (a *Env) AuthContext(ctx context.Context) context.Context

func (*Env) PrintWhoami added in v0.0.43

func (a *Env) PrintWhoami(ctx context.Context) error

type TokenResponse added in v0.0.74

type TokenResponse struct {
	AccessToken  string `json:"access_token"`
	TokenType    string `json:"token_type"`
	ExpiresIn    int    `json:"expires_in"`
	RefreshToken string `json:"refresh_token"`
}

Jump to

Keyboard shortcuts

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