Documentation ¶
Overview ¶
Package auth provides ability to verify API Keys, that brings an abstraction layer between applications that require API Key authentication and authentication providers.
Index ¶
- Variables
- func UUIDNextKey() string
- type APIKey
- type Authenticator
- type DocstoreAuth
- func (a *DocstoreAuth) AuthFunc(ctx context.Context, apiKey string, params map[string]string) bool
- func (a *DocstoreAuth) Close() error
- func (a *DocstoreAuth) Delete(ctx context.Context, apiKey string) error
- func (a *DocstoreAuth) Do(ctx context.Context, apiKey string, domainID string) (bool, error)
- func (a *DocstoreAuth) Generate(ctx context.Context, domID string, isGlobalAdmin bool, note string) (*APIKey, error)
- func (a *DocstoreAuth) Open() error
- type NextKeyFunc
- type SpecialAuth
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrCouldNotOpenKeyStore = errors.New("ErrCouldNotOpenKeyStore") ErrCouldNotCloseKeyStore = errors.New("ErrCouldNotCloseKeyStore") ErrCouldNotAuthenticate = errors.New("ErrCouldNotAuthenticate") ErrCouldNotDeleteKey = errors.New("ErrCouldNotDeleteKey") ErrKeyNotFound = errors.New("ErrKeyNotFound") ErrCouldNotGenerateKey = errors.New("ErrCouldNotGenerateKey") )
Errors
View Source
var NextKeyFn = UUIDNextKey
NextKeyFn generates next key and is used by DocstoreAuth. Default is UUID Version 4.
Functions ¶
func UUIDNextKey ¶
func UUIDNextKey() string
UUIDNextKey returns an UUID Version 4, without hyphens.
Types ¶
type APIKey ¶
type APIKey struct { Key string `docstore:"key"` ScopeRegisterAll bool `docstore:"scope_register_all"` // globalAdmin: You can do whatever you want. ScopeRegisterDomain bool `docstore:"scope_register_domain"` // domainAdmin: DomainID will be checked. DomainID string `docstore:"domid"` Note string `docstore:"note"` }
APIKey contains API key and scope.
type Authenticator ¶
type DocstoreAuth ¶
type DocstoreAuth struct {
// contains filtered or unexported fields
}
DocstoreAuth provides AuthFunc and is backed by docstore.
func MustNewDocstoreAuth ¶
func MustNewDocstoreAuth(conn string) *DocstoreAuth
MustNewDocstoreAuth initializes an DocstoreAuth, panics if failed to access datastore.
func (*DocstoreAuth) Delete ¶
func (a *DocstoreAuth) Delete(ctx context.Context, apiKey string) error
Delete deletes the APIKey specified by apiKey from datastore. No errors returned when the APIKey does not exist.
type SpecialAuth ¶
type SpecialAuth struct{}
SpecialAuth is a dummy Authenticator for tests.
Click to show internal directories.
Click to hide internal directories.