client

package
v0.0.0-...-65e2f22 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2018 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContextKeyClientID contextKey = "clientID"
)

Context keys.

Variables

This section is empty.

Functions

func AuthMiddleware

func AuthMiddleware(svc Service) endpoint.Middleware

AuthMiddleware returns a client token based authentication.

func HTTPToContext

func HTTPToContext(
	ctx context.Context,
	r *http.Request,
) context.Context

HTTPToContext moves the Client secret token from request header to context.

func MakeHandler

func MakeHandler(svc Service, opts ...kithttp.ServerOption) http.Handler

MakeHandler returns an http.Handler for Service.

Types

type Client

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

Client represents distinct consumers like mobile apps, SPAs or other web servers.

type List

type List []Client

List is a collection of Clients.

type PGRepo

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

PGRepo is Postgres backed Repo implementation.

func NewPostgresRepo

func NewPostgresRepo(db *sqlx.DB, options ...PGRepoOption) *PGRepo

NewPostgresRepo returns a Postgres backed Repo implementation.

func (*PGRepo) List

func (r *PGRepo) List() (List, error)

List returns all clients.

func (*PGRepo) Lookup

func (r *PGRepo) Lookup(id string) (Client, error)

Lookup returns the client stored for the given id.

func (*PGRepo) Setup

func (r *PGRepo) Setup() error

Setup prepares the PGRepo for operation.

func (*PGRepo) Store

func (r *PGRepo) Store(id, name string) (Client, error)

Store persists a new client with the given id and name.

func (*PGRepo) Teardown

func (r *PGRepo) Teardown() error

Teardown deconstructs all dependencies of the repo.

type PGRepoOption

type PGRepoOption func(*PGRepo)

PGRepoOption sets an optiomal parameter for the repo.

func PGRepoSchema

func PGRepoSchema(schema string) PGRepoOption

PGRepoSchema sets the namespacing of the Postgres tables to a non-default schema.

type PGTokenRepo

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

PGTokenRepo is a Postgres backed TokenRepo implementation.

func NewPostgresTokenRepo

func NewPostgresTokenRepo(db *sqlx.DB, options ...PGTokenRepoOption) *PGTokenRepo

NewPostgresTokenRepo returns a Postgres backed TokenRepo implementation.

func (*PGTokenRepo) GetLatest

func (r *PGTokenRepo) GetLatest(clientID string) (Token, error)

GetLatest returns the newest token for the given client id.

func (*PGTokenRepo) Lookup

func (r *PGTokenRepo) Lookup(secret string) (Token, error)

Lookup given a secret returns the associated token.

func (*PGTokenRepo) Setup

func (r *PGTokenRepo) Setup() error

Setup prepares all dependencies for the Postgres repo.

func (*PGTokenRepo) Store

func (r *PGTokenRepo) Store(clientID, secret string) (Token, error)

Store persists a new token with the given client id and secret.

func (*PGTokenRepo) Teardown

func (r *PGTokenRepo) Teardown() error

Teardown removes all dependencies of the Postgres repo.

type PGTokenRepoOption

type PGTokenRepoOption func(*PGTokenRepo)

PGTokenRepoOption sets an optiomal parameter for the token repo.

func PGTokenRepoSchema

func PGTokenRepoSchema(schema string) PGTokenRepoOption

PGTokenRepoSchema sets the namespacing of the Postgres tables to a non-default schema.

type Repo

type Repo interface {
	List() (List, error)
	Lookup(id string) (Client, error)
	Store(id, name string) (Client, error)
	// contains filtered or unexported methods
}

Repo for Client interactions.

type RepoMiddleware

type RepoMiddleware func(Repo) Repo

RepoMiddleware is a chainable behaviour modifier for Repo.

func NewRepoInstrumentMiddleware

func NewRepoInstrumentMiddleware(
	opObserve instrument.ObserveRepoFunc,
	store string,
) RepoMiddleware

NewRepoInstrumentMiddleware wraps the next Repo with Prometheus instrumenation capabilities.

func NewRepoLogMiddleware

func NewRepoLogMiddleware(logger log.Logger, store string) RepoMiddleware

NewRepoLogMiddleware wraps the next Repo with logging capabilities.

type Service

type Service interface {
	Create(name string) (Client, string, error)
	ListWithToken() (clientTokens, error)
	LookupBySecret(secret string) (Client, error)
}

Service provides Clients.

func NewService

func NewService(repo Repo, tokenRepo TokenRepo) Service

NewService provides Clients.

type Token

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

Token is the relation between a Client secret and id.

type TokenRepo

type TokenRepo interface {
	GetLatest(clientID string) (Token, error)
	Lookup(secret string) (Token, error)
	Store(clientID, secret string) (Token, error)
	// contains filtered or unexported methods
}

TokenRepo for Token interactions.

type TokenRepoMiddleware

type TokenRepoMiddleware func(next TokenRepo) TokenRepo

TokenRepoMiddleware is a chainable behaviour modifier for TokenRepo.

func NewTokenRepoInstrumentMiddleware

func NewTokenRepoInstrumentMiddleware(
	opObserve instrument.ObserveRepoFunc,
	store string,
) TokenRepoMiddleware

NewTokenRepoInstrumentMiddleware wraps the next TokenRepo with Prometheus instrumenation capabilities.

func NewTokenRepoLogMiddleware

func NewTokenRepoLogMiddleware(logger log.Logger, store string) TokenRepoMiddleware

NewTokenRepoLogMiddleware wraps the next TokenRepo with logging capabilities.

Jump to

Keyboard shortcuts

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