authentication

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrGrantType = errors.New("Grant type is invalid, should be 'client_credentials', 'authorization_code' or 'refresh_token'")
View Source
var ErrNoAuthCodeOrVerifier = errors.New("Grant type 'authorization_code', should have both 'authorizationCode' and 'authorizationCodeVerifier' provided")
View Source
var ErrNoRefreshToken = errors.New("Grant type 'refresh_token', should have a refresh token provided")
View Source
var ErrUnauthorized = errors.New("Unauthorized")

ErrUnauthorized API no auth error

Functions

This section is empty.

Types

type AuthMock

type AuthMock struct {
	mock.Mock
}

AuthMock mock of auth service

func (*AuthMock) Authenticate

func (a *AuthMock) Authenticate(user, pass string) (c *Credentials, err error)

Authenticate mock of auth service

func (*AuthMock) GetToken

func (a *AuthMock) GetToken() (token string)

GetToken mock of auth service

func (*AuthMock) V2Authenticate added in v1.1.1

func (a *AuthMock) V2Authenticate(authType, authCode, authCodeVerifier, refreshToken string) (c *V2Credentials, err error)

func (*AuthMock) V2GetUserCode added in v1.1.1

func (a *AuthMock) V2GetUserCode() (uc *UserCode, err error)

V2GetUserCode mock of auth service

func (*AuthMock) Validate

func (a *AuthMock) Validate() (err error)

Validate mock of auth service

type Credentials

type Credentials struct {
	AccessToken string `json:"access_token"`
	TokenType   string `json:"token_type"`
	Scope       string `json:"scope"`
	ExpiresIn   int    `json:"expires_in"`
}

Credentials describes the API credential type

type Service

type Service interface {
	V2GetUserCode() (*UserCode, error)
	Authenticate(username, password string) (*Credentials, error)
	V2Authenticate(authType, authCode, authCodeVerifier, refreshToken string) (c *V2Credentials, err error)
	Validate() error
	GetToken() string
}

Service describes the auth service abstraction

func New

func New(adapter adapters.Http, clientId, clientSecret string, v2 bool) Service

New returns an auth service implementation

type UserCode added in v1.1.1

type UserCode struct {
	Usercode                  string `json:"userCode"`
	AuthorizationCodeVerifier string `json:"authorizationCodeVerifier"`
	VerificationURL           string `json:"verificationUrl"`
	VerificationURLComplete   string `json:"verificationUrlComplete"`
	ExpiresIn                 int    `json:"expiresIn"`
}

type V2Credentials added in v1.1.1

type V2Credentials struct {
	AccessToken  string `json:"accessToken"`
	RefreshToken string `json:"refreshToken"`
	Type         string `json:"type"`
	ExpiresIn    int    `json:"expires_in"`
}

V2Credentials describes the API credential type

Jump to

Keyboard shortcuts

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