Documentation ¶
Index ¶
- func Authentication(logger log.Logger, signKey string, userRepo api.VulcanitoStore) endpoint.Middleware
- func EndpointLogging(logger log.Logger, name string, db api.VulcanitoStore) endpoint.Middleware
- func NotWhitelisted(logger log.Logger) endpoint.Middleware
- func ValidateUUIDs(repo api.VulcanitoStore, globalEntities *global.Entities, logger log.Logger) endpoint.Middleware
- type AuthorizeMiddleware
- type Authorizer
- type MetricsMiddleware
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Authentication ¶
func Authentication(logger log.Logger, signKey string, userRepo api.VulcanitoStore) endpoint.Middleware
Authentication retrieves information about: 1 - The token used in the current request 2 - Information about the user associated with this token
And also 3 - Validates if the token is active for the current user
If the authentication succeeds, the email fied is added to the context.
func EndpointLogging ¶
func EndpointLogging(logger log.Logger, name string, db api.VulcanitoStore) endpoint.Middleware
func NotWhitelisted ¶
func NotWhitelisted(logger log.Logger) endpoint.Middleware
func ValidateUUIDs ¶
func ValidateUUIDs(repo api.VulcanitoStore, globalEntities *global.Entities, logger log.Logger) endpoint.Middleware
ValidateUUIDs returns a middleware that inspects the request struct in search for ID parameters in the request path and validates their compliance with UUID format and/or some exceptions.
We are using the "reflect" package to inspect the request struct, looking for fields that have `urlvar` tags with suffix `_id`, for example:
type UpdateTeamJSONRequest struct { ID string `urlvar:"team_id"` Name string `json:"name"` Description string `json:"description"` }
There are some special cases to UUID validation.
- global entities: Global entities are special values that can be specified by the client and are expanded into other values before the service layer processes the request (e.g.: periodic-full-scan).
- team_id urlvar values can be set with the team name: This middleware will inspect for that option and replace the team name for its UUID in the original request path.
- user_id urlvar values can be set with the user email: This middleware will inspect for that option and replace the user email for its UUID in the original request path.
Types ¶
type AuthorizeMiddleware ¶
AuthorizeMiddleware implements the authorization over an endpoint.
func NewAuthorizationMiddleware ¶
func NewAuthorizationMiddleware(auth Authorizer, logger log.Logger) AuthorizeMiddleware
NewAuthorizationMiddleware creates a new authorization middleware using the provided authorizer.
type Authorizer ¶
type Authorizer interface { // AuthTenant receives the context and returns an object representing the // tenant the user is trying to access to. // If the user is not authorized the function must return a nil tenant. // If the user is allowed to do anything on that tenant, e.g. a super admin, // the function must return true in the second parameter. AuthTenant(ctx context.Context, request interface{}) (tenant interface{}, passThrough bool, err error) // AuthRol grants or denies access to a resource depending on the rol of the user. AuthRol(ctx context.Context, tenant interface{}) (bool, error) }
Authorizer provides defines the funcs that the clients of the middleware must provide.
type MetricsMiddleware ¶
type MetricsMiddleware interface {
Measure(next kitendpoint.Endpoint) kitendpoint.Endpoint
}
MetricsMiddleware implements a metrics middleware over an endpoint.
func NewMetricsMiddleware ¶
func NewMetricsMiddleware(metricsClient metrics.Client) MetricsMiddleware
NewMetricsMiddleware creates a new metrics middleware pushing the metrics through the given metrics client.