http

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderTokenID   = "X-Auth-Id"
	HeaderTokenName = "X-Auth-Name"
	HeaderUserID    = "X-User-Id"
)

Variables

View Source
var (
	// ErrInvalidToken returned, if ApiKey/X-Api-Key is not valid.
	ErrInvalidToken = httputil.NewError(http.StatusUnauthorized, "auth.token.is_not_valid")

	// ErrTokenRevoked returned, if ApiKey/X-Api-Key was temporary disabled.
	ErrTokenRevoked = httputil.NewError(http.StatusUnauthorized, "auth.token.revoked")

	// ErrAccessDenied returned, if ip address is blacklisted.
	ErrAccessDenied = httputil.NewError(http.StatusForbidden, "auth.access_denied")
)
View Source
var (
	ErrUnauthorized = httputil.NewError(http.StatusUnauthorized, "user.not_authorized")
)

Functions

func SessionCheckerMiddleware added in v0.0.23

func SessionCheckerMiddleware(checker domain.SessionChecker) mux.MiddlewareFunc

func Start

func Start(ctx context.Context, addr string, conf *config.Settings, pub eventapi.Publisher, store domain.Store, svc domain.UserService, checker domain.SessionChecker) error

Start starts the server with specified store.

func UserIDFromContext added in v0.0.21

func UserIDFromContext(ctx context.Context) string

func WithUserID added in v0.0.21

func WithUserID(ctx context.Context, id string) context.Context

Types

type AuthHandler added in v0.0.21

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

type CreateTokenRequest added in v0.0.21

type CreateTokenRequest struct {
	Name string `json:"name"`
}

type HeaderKey added in v0.0.21

type HeaderKey int
const (
	UserIDHeaderKey HeaderKey = iota
)

Jump to

Keyboard shortcuts

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