api

package
v0.0.0-...-3beece8 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2018 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContextErrorKey       userCtxKeyType = "Error"
	ContextAccessTokenKey userCtxKeyType = "accessToken"
)

Variables

View Source
var (
	// ErrInvalidRequest  request error
	ErrInvalidRequest = errors.New("Invalid Request")
	// ErrContextRequest error found in context in field ContextErrorKey
	ErrContextRequest = errors.New("Context Error")
)
View Source
var (
	// ErrUnauthorized not authorized error 401
	ErrUnauthorized = errors.New("Unauthorized")
)

Functions

func BindJSON

func BindJSON(data io.Reader, dest interface{}) error

BindJSON binds request body to the dest struct

func ExtractToken

func ExtractToken(r *http.Request) (string, bool)

ExtractToken extracts jwt token from the header "Authorization" field with Bearer

func MakeChangePasswordEndpoint

func MakeChangePasswordEndpoint(s UserService) endpoint.Endpoint

func MakeConfirmForgotPasswordEndpoint

func MakeConfirmForgotPasswordEndpoint(s UserService) endpoint.Endpoint

func MakeConfirmSignUpEndpoint

func MakeConfirmSignUpEndpoint(s UserService) endpoint.Endpoint

func MakeForgotPasswordEndpoint

func MakeForgotPasswordEndpoint(s UserService) endpoint.Endpoint

func MakeGetUserEndpoint

func MakeGetUserEndpoint(s UserService) endpoint.Endpoint

func MakeHTTPHandler

func MakeHTTPHandler(e EndPoints, logger log.Logger, tracer stdopentracing.Tracer) *mux.Router

MakeHTTPHandler creates routes in the API

func MakeJwtCheckMiddleware

func MakeJwtCheckMiddleware() endpoint.Middleware

FIXME: this is not being used... TO BE DELETED

func MakeSignInEndpoint

func MakeSignInEndpoint(s UserService) endpoint.Endpoint

func MakeSignUpEndpoint

func MakeSignUpEndpoint(s UserService) endpoint.Endpoint

func MakeValidateTokenEndpoint

func MakeValidateTokenEndpoint(s UserService) endpoint.Endpoint

Types

type EndPoints

type EndPoints struct {
	SignUpEndpoint                endpoint.Endpoint
	SignInEndpoint                endpoint.Endpoint
	GetUserEndpoint               endpoint.Endpoint
	ConfirmSignUpEndpoint         endpoint.Endpoint
	ForgotPasswordEndpoint        endpoint.Endpoint
	ConfirmForgotPasswordEndpoint endpoint.Endpoint
	ChangePasswordEndpoint        endpoint.Endpoint
	ValidateTokenEndpoint         endpoint.Endpoint // NOTE: for API gateway to use only(?)
}

func MakeEndpoints

func MakeEndpoints(s UserService, tracer stdopentracing.Tracer) EndPoints

type Middleware

type Middleware func(UserService) UserService

Middleware decorates a service.

func LoggingMiddleware

func LoggingMiddleware(logger log.Logger) Middleware

LoggingMiddleware logs method calls, parameters, results, and elapsed time.

type UserService

type UserService interface {
	SignUp(username, password, confirmPass, email string) (*cogIdp.SignUpOutput, error) // register user
	SignIn(username, password string) (*cogIdp.InitiateAuthOutput, error)               // InitiateAuth or AdminInitiateAuth ? TODO: return token string
	GetUser(username string) (*cogIdp.AdminGetUserOutput, error)                        // AdminGetUser or GetUser ?
	ConfirmSingUp(code, username string) (*cogIdp.ConfirmSignUpOutput, error)
	ForgotPassword(username string) (*cogIdp.ForgotPasswordOutput, error)
	ConfirmForgotPassword(newPass, code, username string) (*cogIdp.ConfirmForgotPasswordOutput, error)
	ChangePassword(accessToken, prevPass, newPass string) (*cogIdp.ChangePasswordOutput, error)
	ValidateJwtToken(tokenStr string) (models.AuthenticatedUser, error)
}

func NewInstrumentingService

func NewInstrumentingService(requestCount metrics.Counter, requestLatency metrics.Histogram, s UserService) UserService

NewInstrumentingService returns an instance of an instrumenting UserService.

func NewUserService

func NewUserService() UserService

Jump to

Keyboard shortcuts

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