Documentation ¶
Index ¶
- Constants
- func AuthMiddleware(svc Service) endpoint.Middleware
- func HTTPToContext(ctx context.Context, r *http.Request) context.Context
- func MakeHandler(svc Service, opts ...kithttp.ServerOption) http.Handler
- type Client
- type List
- type PGRepo
- type PGRepoOption
- type PGTokenRepo
- type PGTokenRepoOption
- type Repo
- type RepoMiddleware
- type Service
- type Token
- type TokenRepo
- type TokenRepoMiddleware
Constants ¶
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 ¶
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 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.
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 ¶
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 ¶
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 ¶
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.