Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrConflict indicates usage of the existing email during account // registration. ErrConflict = errors.New("email already taken") // ErrMalformedEntity indicates malformed entity specification (e.g. // invalid username or password). ErrMalformedEntity = errors.New("malformed entity specification") // when accessing a protected resource. ErrUnauthorizedAccess = errors.New("missing or invalid credentials provided") // ErrNotFound indicates a non-existent entity request. ErrNotFound = errors.New("non-existent entity") )
Functions ¶
This section is empty.
Types ¶
type Hasher ¶
type Hasher interface { // Hash generates the hashed string from plain-text. Hash(string) (string, error) // Compare compares plain-text version to the hashed one. An error should // indicate failed comparison. Compare(string, string) error }
Hasher specifies an API for generating hashes of an arbitrary textual content.
type IdentityProvider ¶
type IdentityProvider interface { // TemporaryKey generates the temporary access token. TemporaryKey(string) (string, error) // Identity extracts the entity identifier given its secret key. Identity(string) (string, error) }
IdentityProvider specifies an API for identity management via security tokens.
type Service ¶
type Service interface { // Register creates new user account. In case of the failed registration, a // non-nil error value is returned. Register(context.Context, User) error // Login authenticates the user given its credentials. Successful // authentication generates new access token. Failed invocations are // identified by the non-nil error values in the response. Login(context.Context, User) (string, error) // Identify validates user's token. If token is valid, user's id // is returned. If token is invalid, or invocation failed for some // other reason, non-nil error values are returned in response. Identify(string) (string, error) }
Service specifies an API that must be fullfiled by the domain service implementation, and all of its decorators (e.g. logging & metrics).
func New ¶
func New(users UserRepository, hasher Hasher, idp IdentityProvider) Service
New instantiates the users service implementation.
type User ¶
User represents a Mainflux user account. Each user is identified given its email and password.
type UserRepository ¶
type UserRepository interface { // Save persists the user account. A non-nil error is returned to indicate // operation failure. Save(context.Context, User) error // RetrieveByID retrieves user by its unique identifier (i.e. email). RetrieveByID(context.Context, string) (User, error) }
UserRepository specifies an account persistence API.
Directories ¶
Path | Synopsis |
---|---|
Package api contains API-related concerns: endpoint definitions, middlewares and all resource representations.
|
Package api contains API-related concerns: endpoint definitions, middlewares and all resource representations. |
grpc
Package grpc contains implementation of users service gRPC API.
|
Package grpc contains implementation of users service gRPC API. |
http
Package http contains implementation of users service HTTP API.
|
Package http contains implementation of users service HTTP API. |
Package bcrypt provides a hasher implementation utilising bcrypt.
|
Package bcrypt provides a hasher implementation utilising bcrypt. |
Package jwt provides a JWT identity provider.
|
Package jwt provides a JWT identity provider. |
Package postgres contains repository implementations using PostgreSQL as the underlying database.
|
Package postgres contains repository implementations using PostgreSQL as the underlying database. |
Package tracing contains middlewares that will add spans to existing traces.
|
Package tracing contains middlewares that will add spans to existing traces. |
Click to show internal directories.
Click to hide internal directories.