auth

package
v1.0.0-rc.5 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2020 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func MakeAuthenticateEndpoint

func MakeAuthenticateEndpoint(s Service) endpoint.Endpoint

MakeAuthenticateEndpoint returns an endpoint via the passed service.

func MakeCreateAccountEndpoint

func MakeCreateAccountEndpoint(s Service) endpoint.Endpoint

MakeCreateAccountEndpoint returns an endpoint via the passed service.

func MakeListEndpoint

func MakeListEndpoint(s Service) endpoint.Endpoint

MakeListEndpoint returns an endpoint that invokes List on the service.

func MakeReadEndpoint

func MakeReadEndpoint(s Service) endpoint.Endpoint

MakeReadEndpoint returns an endpoint that invokes Read on the service.

Types

type AccountDTO

type AccountDTO struct {
	ID    uuid.UUID `json:"id"`
	Login string    `json:"login"`
}

type AccountRepository

type AccountRepository interface {
	Exists(login string) (bool, error)
	FindByLogin(login string) (*domain.Account, error)
	FindByID(id uuid.UUID) (*domain.Account, error)
	Insert(account *domain.Account) error
	Update(account *domain.Account) error
	FindAllWithFilter(offset int64, limit int, f filter) ([]domain.Account, error)
}

type AccountRepositoryImpl

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

repository represent account db account Repository.

func NewAccountRepository

func NewAccountRepository(db database.QueryerExecer) *AccountRepositoryImpl

NewAccountRepository is constructor.

func (AccountRepositoryImpl) Exists

func (r AccountRepositoryImpl) Exists(login string) (bool, error)

Exists checks existing account.

func (AccountRepositoryImpl) FindAllWithFilter

func (r AccountRepositoryImpl) FindAllWithFilter(offset int64, limit int, f filter) ([]domain.Account, error)

FindAllWithFilter finds accounts by filter.

func (AccountRepositoryImpl) FindByID

func (r AccountRepositoryImpl) FindByID(id uuid.UUID) (account *domain.Account, err error)

FindByID finds account by id.

func (AccountRepositoryImpl) FindByLogin

func (r AccountRepositoryImpl) FindByLogin(login string) (account *domain.Account, err error)

FindByLogin finds account by login.

func (AccountRepositoryImpl) Insert

func (r AccountRepositoryImpl) Insert(account *domain.Account) error

func (AccountRepositoryImpl) Update

func (r AccountRepositoryImpl) Update(account *domain.Account) error

type CreateDTO

type CreateDTO struct {
	Login    string `json:"login"`
	Password string `json:"password"`
}

type Endpoints

type Endpoints struct {
	CreateAccountEndpoint endpoint.Endpoint
	AuthenticateEndpoint  endpoint.Endpoint
	ReadEndpoint          endpoint.Endpoint
	ListEndpoint          endpoint.Endpoint
}

func MakeServerEndpoints

func MakeServerEndpoints(s Service, params auth.EndpointParams) Endpoints

MakeServerEndpoints returns an Endpoints struct where each endpoint invokes the corresponding method on the provided service. Useful in a profilesvc server.

type HTTPHandlerParams

type HTTPHandlerParams struct {
	Logger *logrus.Entry
}

HTTPHandlerParams provides params for handlers service options.

type HTTPHandlerSet

type HTTPHandlerSet struct {
	CreateAccountHandler       http.Handler
	ReadAccountHandler         http.Handler
	ListAccountHandler         http.Handler
	AuthenticateAccountHandler http.Handler
}

HTTPHandlerSet contains all service http handlers to register it in mux.router later.

func NewHTTPHandlerSet

func NewHTTPHandlerSet(endpoints Endpoints, params HTTPHandlerParams) HTTPHandlerSet

NewHTTPHandlerSet returns a http handler set for registration in the mux.Router later

func (*HTTPHandlerSet) Register

func (h *HTTPHandlerSet) Register(m *mux.Router)

Register add handlers to mux.Router with theirs paths.

type LoginDTO

type LoginDTO struct {
	Login    string
	Password string
}

type Service

type Service interface {
	List(ctx context.Context, limit int, offset int64, filter filter) ([]domain.Account, error)
	Create(ctx context.Context, dto CreateDTO) (result *domain.Account, err error)
	Read(ctx context.Context, id uuid.UUID) (result *domain.Account, err error)
	Authenticate(ctx context.Context, dto LoginDTO) (token string, err error)
}

func NewService

func NewService(
	tokenCreator token.Creator,
	repository AccountRepository,
	hasher passwordhash.PasswordHasher,
	uuidGenerator uuid.Generator,
) Service

Jump to

Keyboard shortcuts

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