auth

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2020 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAuthNotFound is the error returned when Auth is not found in the user's config location
	ErrAuthNotFound = errors.New("auth not found")
	// ErrAuthEndpointChanged is the error returned when an Auth's endpoint has changed
	ErrAuthEndpointChanged = errors.New("auth endpoint changed")
	// ErrTokenExpired is the error returned when a token has expired
	ErrTokenExpired = errors.New("token expired")
)

Functions

func DeleteAuth

func DeleteAuth() error

DeleteAuth deletes the Auth config from the user's config location

Types

type Auth

type Auth struct {
	Endpoint     string `json:"endpoint"`
	AuthToken    string `json:"authToken"`
	RefreshToken string `json:"refreshToken"`
}

Auth represents an authentication info

func NewAuth

func NewAuth(endpoint string) *Auth

NewAuth creates a new Auth

func VerifyAuth

func VerifyAuth(endpoint string) (au *Auth, er error)

VerifyAuth verifies the Auth config from the user's config location and returns it. When the specified endpoint is empty, the endpoint itself will not be checked. When ErrTokenExpired is returned, the Auth is returned and non-nil

func (*Auth) Load

func (a *Auth) Load() error

Load loads the Auth config from the user's config location

func (*Auth) RenewAuthToken

func (a *Auth) RenewAuthToken(ctx context.Context) error

RenewAuthToken renews the `authToken` with the `refreshToken`

func (*Auth) Save

func (a *Auth) Save() error

Save saves the Auth config to the user's config location

func (*Auth) SignInWithEmail

func (a *Auth) SignInWithEmail(ctx context.Context, email, pwd string) error

SignInWithEmail signs in ProvenDB with email

func (*Auth) SignInWithOauth

func (a *Auth) SignInWithOauth(ctx context.Context, provider string) error

SignInWithOauth signs in ProvenDB with OAuth

Jump to

Keyboard shortcuts

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