authentication

package
v0.0.0-...-7426b64 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: BSD-3-Clause Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const ApiTokenConfigKey = "apiToken"

Variables

This section is empty.

Functions

func LegacyClose

func LegacyClose()

func Reset

func Reset()

Reset clears the cache

Types

type Auth

type Auth struct {
	// contains filtered or unexported fields
}

Auth is the base structure used to record the authenticated state

func LegacyGet

func LegacyGet() (*Auth, error)

LegacyGet returns a cached version of Auth

func New

func New(cfg Configurable) *Auth

New creates a new version of Auth

func (*Auth) Authenticate

func (s *Auth) Authenticate() error

Authenticate will try to authenticate using stored credentials

func (*Auth) AuthenticateWithDevice

func (s *Auth) AuthenticateWithDevice(deviceCode strfmt.UUID) (apiKey string, err error)

func (*Auth) AuthenticateWithDevicePolling

func (s *Auth) AuthenticateWithDevicePolling(deviceCode strfmt.UUID, interval time.Duration) (string, error)

func (*Auth) AuthenticateWithModel

func (s *Auth) AuthenticateWithModel(credentials *mono_models.Credentials) error

AuthenticateWithModel will try to authenticate using the given swagger model

func (*Auth) AuthenticateWithToken

func (s *Auth) AuthenticateWithToken(token string) error

AuthenticateWithToken will try to authenticate using the given token

func (*Auth) Authenticated

func (s *Auth) Authenticated() bool

Authenticated checks whether we are currently authenticated

func (*Auth) AvailableAPIToken

func (s *Auth) AvailableAPIToken() (v string)

func (*Auth) BearerToken

func (s *Auth) BearerToken() string

BearerToken returns the current bearerToken

func (*Auth) CanWrite

func (s *Auth) CanWrite(organization string) bool

func (*Auth) Client

func (s *Auth) Client() (*mono_client.Mono, error)

Client will return an API client that has authentication set up

func (*Auth) ClientAuth

func (s *Auth) ClientAuth() runtime.ClientAuthInfoWriter

ClientAuth returns the auth type required by swagger api calls

func (*Auth) Close

func (s *Auth) Close() error

func (*Auth) CreateToken

func (s *Auth) CreateToken() error

CreateToken will create an API token for the current authenticated user

func (*Auth) Email

func (s *Auth) Email() string

Email return the email of the authenticated user

func (*Auth) Logout

func (s *Auth) Logout() error

Logout will destroy any session tokens and reset the current Auth instance

func (*Auth) NewAPIKey

func (s *Auth) NewAPIKey(name string) (string, error)

NewAPIKey returns a new api key from the backend or the relevant failure.

func (*Auth) Refresh

func (s *Auth) Refresh() error

func (*Auth) SaveToken

func (s *Auth) SaveToken(token string) error

SaveToken will save an API token

func (*Auth) Sync

func (s *Auth) Sync() error

Sync will ensure that the authenticated state is in sync with what is in the config database. This is mainly useful if you want to instrument the auth package without creating unnecessary API calls.

func (*Auth) SyncRequired

func (s *Auth) SyncRequired() bool

func (*Auth) UserID

func (s *Auth) UserID() *strfmt.UUID

UserID returns the user ID for the currently authenticated user, or nil if not authenticated

func (*Auth) WhoAmI

func (s *Auth) WhoAmI() string

WhoAmI returns the username of the currently authenticated user, or an empty string if not authenticated

type Configurable

type Configurable interface {
	Set(string, interface{}) error
	GetString(string) string
	Close() error
}

type ErrTokenRequired

type ErrTokenRequired struct{ *locale.LocalizedError }

type ErrUnauthorized

type ErrUnauthorized struct{ *locale.LocalizedError }

Jump to

Keyboard shortcuts

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