config

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTokenMissingRequiredScopes is thrown when the token is missing required scopes.
	ErrTokenMissingRequiredScopes = errors.New("token is missing required scopes")

	// ErrInvalidToken is thrown when the token is invalid.
	ErrInvalidToken = errors.New("token is invalid")
)
View Source
var ErrConfigFileMissing = errors.New("config.json file is missing")

ErrConfigFileMissing is thrown when the config.json file is missing.

View Source
var ErrNoAuthenticatedTenants = errors.New("not logged in. Try `auth0 login`")

ErrNoAuthenticatedTenants is thrown when the config file has no authenticated tenants.

Functions

This section is empty.

Types

type Config

type Config struct {
	InstallID     string  `json:"install_id,omitempty"`
	DefaultTenant string  `json:"default_tenant"`
	Tenants       Tenants `json:"tenants"`
	// contains filtered or unexported fields
}

Config holds cli configuration settings.

func (*Config) AddTenant

func (c *Config) AddTenant(tenant Tenant) error

AddTenant adds a tenant to the config. This is called after a login has completed.

func (*Config) GetTenant

func (c *Config) GetTenant(tenantName string) (Tenant, error)

GetTenant retrieves all the tenant information from the config.

func (*Config) Initialize

func (c *Config) Initialize() error

Initialize will load the config settings into memory.

func (*Config) IsLoggedInWithTenant

func (c *Config) IsLoggedInWithTenant(tenantName string) bool

IsLoggedInWithTenant checks if we're logged in with the given tenant.

func (*Config) ListAllTenants

func (c *Config) ListAllTenants() ([]Tenant, error)

ListAllTenants retrieves a list with all configured tenants.

func (*Config) RemoveTenant

func (c *Config) RemoveTenant(tenant string) error

RemoveTenant removes a tenant from the config. This is called after a logout has completed.

func (*Config) SetDefaultAppIDForTenant

func (c *Config) SetDefaultAppIDForTenant(tenantName, appID string) error

SetDefaultAppIDForTenant saves the new default app id for the tenant to the disk.

func (*Config) SetDefaultTenant

func (c *Config) SetDefaultTenant(tenantName string) error

SetDefaultTenant saves the new default tenant to the disk.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks to see if the config is not corrupted, and we have an authenticated tenant saved. If we have at least one tenant saved but the DefaultTenant is empty, it will attempt to set the first available tenant as the DefaultTenant and save to disk.

type Tenant

type Tenant struct {
	Name         string    `json:"name"`
	Domain       string    `json:"domain"`
	AccessToken  string    `json:"access_token,omitempty"`
	Scopes       []string  `json:"scopes,omitempty"`
	ExpiresAt    time.Time `json:"expires_at"`
	DefaultAppID string    `json:"default_app_id,omitempty"`
	ClientID     string    `json:"client_id"`
}

Tenant keeps track of auth0 config for the tenant.

func (*Tenant) CheckAuthenticationStatus

func (t *Tenant) CheckAuthenticationStatus() error

CheckAuthenticationStatus checks to see if the tenant in the config has all the required scopes and that the access token is not expired.

func (*Tenant) GetAccessToken

func (t *Tenant) GetAccessToken() string

GetAccessToken retrieves the tenant's access token.

func (*Tenant) GetExtraRequestedScopes

func (t *Tenant) GetExtraRequestedScopes() []string

GetExtraRequestedScopes retrieves any extra scopes requested for the tenant when logging in through the device code flow.

func (*Tenant) HasAllRequiredScopes

func (t *Tenant) HasAllRequiredScopes() bool

HasAllRequiredScopes returns true if the tenant has all the required scopes, false otherwise.

func (*Tenant) HasExpiredToken

func (t *Tenant) HasExpiredToken() bool

HasExpiredToken checks whether the tenant has an expired token.

func (*Tenant) IsAuthenticatedWithClientCredentials

func (t *Tenant) IsAuthenticatedWithClientCredentials() bool

IsAuthenticatedWithClientCredentials checks to see if the tenant has been authenticated through client credentials.

func (*Tenant) IsAuthenticatedWithDeviceCodeFlow

func (t *Tenant) IsAuthenticatedWithDeviceCodeFlow() bool

IsAuthenticatedWithDeviceCodeFlow checks to see if the tenant has been authenticated through device code flow.

func (*Tenant) RegenerateAccessToken

func (t *Tenant) RegenerateAccessToken(ctx context.Context) error

RegenerateAccessToken regenerates the access token for the tenant.

type Tenants

type Tenants map[string]Tenant

Tenants keeps track of all the tenants we logged into. The key is the tenant domain.

Jump to

Keyboard shortcuts

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