client

package
v0.0.0-...-6b846f9 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const PasswordLength = 32

Variables

View Source
var (
	ErrNilClient             = errors.New("client is nil")
	ErrInvalidClientID       = errors.New("client id is invalid")
	ErrInvalidDeviceID       = errors.New("device id is invalid")
	ErrClientNotFound        = errors.New("client is not found")
	ErrDeviceNotFound        = errors.New("device is not found")
	ErrRelationNotFound      = errors.New("relation is not found")
	ErrRelationAlreadyExists = errors.New("relation already exists")
	ErrNilDatabase           = errors.New("data is nil")
	ErrNilStore              = errors.New("store is nil")
	ErrNoName                = errors.New("name cannot be empty")
	ErrEmptyEntropy          = errors.New("entropy is empty")
	ErrNilPasswordManager    = errors.New("password is nil")
	ErrDuplicateURL          = errors.New("duplicate url")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	Name         string    `db:"name" json:"name"`
	ID           uuid.UUID `db:"id" json:"id"`
	RegisteredAt time.Time `db:"registered_at" json:"registered_at"`
	ExpireAt     time.Time `db:"expire_at" json:"expire_at"`
	Flags        Flags     `db:"flags" json:"flags"`
	ReturnURLs   []url.URL `db:"urls" json:"urls"`

	sync.RWMutex
	// contains filtered or unexported fields
}

Client represents any external client that interfaces with this API

func New

func New(name string, flags Flags) (c *Client, err error)

func (*Client) AddURL

func (c *Client) AddURL(uri url.URL) (err error)

func (*Client) HasURL

func (c *Client) HasURL(uri url.URL) bool

func (*Client) IsConfidential

func (c *Client) IsConfidential() bool

func (*Client) IsEnabled

func (c *Client) IsEnabled() bool

func (*Client) IsExpired

func (c *Client) IsExpired() bool

func (*Client) Validate

func (c *Client) Validate() error

type Flags

type Flags uint8

Flags represent client flags

const (
	FEnabled Flags = 1 << iota
	FConfidential
	FPassword
	FPKI
	FMutualTLS
	FDynamic
)

type Manager

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

func NewManager

func NewManager(s Store) *Manager

func (*Manager) ClientByID

func (m *Manager) ClientByID(ctx context.Context, clientID uuid.UUID) (c *Client, err error)

func (*Manager) CreateClient

func (m *Manager) CreateClient(ctx context.Context, name string, flags Flags) (c *Client, err error)

func (*Manager) CreatePassword

func (m *Manager) CreatePassword(ctx context.Context, clientID uuid.UUID) (raw []byte, err error)

func (*Manager) DeleteClientByID

func (m *Manager) DeleteClientByID(ctx context.Context, clientID uuid.UUID) (err error)

func (*Manager) Logger

func (m *Manager) Logger() *zap.Logger

func (*Manager) MatchSecret

func (m *Manager) MatchSecret(ctx context.Context, clientID uuid.UUID, rawpass []byte) (ok bool, err error)

func (*Manager) SetLogger

func (m *Manager) SetLogger(logger *zap.Logger) error

func (*Manager) SetPasswordManager

func (m *Manager) SetPasswordManager(pm password.Manager) error

type SQLStore

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

func (*SQLStore) DeleteClientByID

func (s *SQLStore) DeleteClientByID(ctx context.Context, clientID uuid.UUID) (err error)

func (*SQLStore) FetchAllClients

func (s *SQLStore) FetchAllClients(ctx context.Context) (gs []*Client, err error)

func (*SQLStore) FetchClientByID

func (s *SQLStore) FetchClientByID(ctx context.Context, clientID uuid.UUID) (*Client, error)

func (*SQLStore) UpsertClient

func (s *SQLStore) UpsertClient(ctx context.Context, c *Client) (_ *Client, err error)

type Store

type Store interface {
	UpsertClient(ctx context.Context, c *Client) (*Client, error)
	FetchClientByID(ctx context.Context, clientID uuid.UUID) (c *Client, err error)
	FetchAllClients(ctx context.Context) (cs []*Client, err error)
	DeleteClientByID(ctx context.Context, clientID uuid.UUID) error
}

func NewMemoryStore

func NewMemoryStore() Store

func NewSQLStore

func NewSQLStore(db *pgx.Conn) (Store, error)

Jump to

Keyboard shortcuts

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