Back to godoc.org

Package service

v0.9.0
Latest Go to latest
Published: Apr 7, 2020 | License: MIT | Module: github.com/ofte-auth/dogpark

Index

Package Files

Constants

const (
	CollectionPendingFIDORegistration = "fidoPendingReg"
	CollectionPendingFIDOLogin        = "fidoPendingLogin"
)

Consts for auth services

Variables

var (
	ErrPrincipalRevoked = errors.New("principal rekoked")
)

Error constants

func ErrorHandler

func ErrorHandler(next http.Handler) http.Handler

ErrorHandler is middleware to log and process HTTP errors.

func OptionDB

func OptionDB(db db.DB) func(*Service) error

OptionDB set a DB connection option.

func OptionGeoResolver

func OptionGeoResolver(geo geo.Resolver) func(*Service) error

OptionGeoResolver sets a geo resolver.

func OptionKV

func OptionKV(kv store.Manager) func(*Service) error

OptionKV set a KV manager option.

func OptionMessageBroker

func OptionMessageBroker(broker broker.Broker) func(*Service) error

OptionMessageBroker sets a broker client option.

func OptionParams

func OptionParams(params map[string]string) func(*Service) error

OptionParams sets a key,value option. Multiple can be set.

func OptionRP

func OptionRP(rpDisplayName, rpID, rpOrigin string) func(*Service) error

OptionRP sets relying party configation options.

func UpdateFIDOMetadata

func UpdateFIDOMetadata(db db.DB, id, mdsToken string) error

UpdateFIDOMetadata pulls metadata from the FIDO Alliance Metadata Service and associates it with the AAGUID (`id`).

type APIError

type APIError struct {
	Code   int    `json:"code"`
	Err    error  `json:"error"`
	Detail string `json:"detail,omitempty"`
}

APIError defines a API error.

func NewAPIError

func NewAPIError(code int, err error, detail string) *APIError

NewAPIError returns a new API error. If `source` is true, source code is also written to stdout.

func (*APIError) BindHTTPRequest

func (e *APIError) BindHTTPRequest(r *http.Request)

BindHTTPRequest binds an API error to a HTTP Request's context.

func (*APIError) Error

func (e *APIError) Error() string

func (*APIError) MarshalJSON

func (e *APIError) MarshalJSON() ([]byte, error)

MarshalJSON ...

type Admin

type Admin interface {
	Principal(context.Context, string) (*model.Principal, error)
	AddPrincipal(context.Context, map[string]string) (*model.Principal, error)
	UpdatePrincipal(context.Context, string, map[string]string) (*model.Principal, string, error)
	PrincipalByUsername(context.Context, string) (*model.Principal, error)
	Principals(context.Context, *util.APIParams) ([]*model.Principal, int64, error)

	FIDOKey(context.Context, string) (*model.FIDOKey, error)
	UpdateFIDOKey(context.Context, string, map[string]string) (*model.FIDOKey, string, error)
	DeleteFIDOKey(context.Context, string) error
	FIDOKeys(context.Context, *util.APIParams) ([]*model.FIDOKey, int64, error)

	AAGUID(context.Context, string) (*model.AAGUID, error)
	AddAAGUID(context.Context, map[string]string) (*model.AAGUID, error)
	UpdateAAGUID(context.Context, string, map[string]string) (*model.AAGUID, string, error)
	AAGUIDs(context.Context, *util.APIParams) ([]*model.AAGUID, int64, error)
	AAGUIDWhitelist(context.Context) (util.StringSet, error)
	AAGUIDBlacklist(context.Context) (util.StringSet, error)

	Session(context.Context, string) (*model.Session, error)
	Sessions(context.Context, *util.APIParams) ([]*model.Session, int64, error)
	KillSession(context.Context, string) (*model.Session, error)

	LogByID(context.Context, int64) (*model.AuditEntry, error)
	Logs(context.Context, *util.APIParams) ([]*model.AuditEntry, int64, error)

	Stop()
}

Admin defines the admin service interface.

func NewAdminService

func NewAdminService(ctx context.Context, options ...func(*Service) error) (Admin, error)

NewAdminService ...

type Auth

type Auth interface {
	GetOrCreatePrincipal(context.Context, map[string]string) (*model.Principal, *APIError)
	StartFIDORegistration(context.Context, string) (*protocol.CredentialCreation, *APIError)
	FinishFIDORegistration(context.Context, string, *http.Request) (*model.FIDOKey, *APIError)
	StartFIDOLogin(context.Context, string) (*protocol.CredentialAssertion, *APIError)
	FinishFIDOLogin(context.Context, string, *http.Request) (*model.Principal, *APIError)

	Stop()
}

Auth defines the auth service interface.

func NewAuthService

func NewAuthService(ctx context.Context, options ...func(*Service) error) (Auth, error)

NewAuthService creates a new instance.

type ContextKey

type ContextKey int

ContextKey is a type for context key values.

const (
	ContextError ContextKey = iota
	ContextIPAddr
	ContextUserAgent
)

Consts for context keys

type Service

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

Service represents a base structure for services.

func (Service) Audit

func (s Service) Audit(ctx context.Context, group, action string, p *model.Principal, key *model.FIDOKey, auditError error)

Audit sends auditing data to configured endpoints.

func (Service) Stop

func (s Service) Stop()

Stop closes all open handles.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier