backend

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2021 License: Apache-2.0 Imports: 39 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Auth0ConfigVarJWT guiconfig.GUIConfig
View Source
var JWTMiddlewareVar = jwtmiddleware.New(jwtmiddleware.Options{
	ValidationKeyGetter: func(token *jwt.Token) (interface{}, error) {

		iss := "https://" + Auth0ConfigVarJWT.Auth0Config.Domain + "/"
		checkIss := token.Claims.(jwt.MapClaims).VerifyIssuer(iss, false)
		if !checkIss {
			return token, errors.New("Invalid issuer.")
		}

		aud := Auth0ConfigVarJWT.Auth0Config.Audience
		checkAud := token.Claims.(jwt.MapClaims).VerifyAudience(aud, false)
		if !checkAud {
			return token, errors.New("Invalid audience.")
		}

		cert, err := getPemCert(token)
		if err != nil {
			return nil, fmt.Errorf("error when getting PEM certificate: %s", err)
		}

		result, _ := jwt.ParseRSAPublicKeyFromPEM([]byte(cert))
		return result, nil
	},
	SigningMethod: jwt.SigningMethodRS256,
})

Functions

func InitBotNameRegex added in v1.10.0

func InitBotNameRegex() (e error)

InitBotNameRegex initializes the regex for bot names.

func SetRoutes

func SetRoutes(r *chi.Mux, s *APIServer)

SetRoutes adds the handlers for the endpoints

func SetVersionString added in v1.12.0

func SetVersionString(guiVersion string, cliVersion string)

SetVersionString sets the version string to be displayed in the GUI

Types

type APIServer

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

APIServer is an instance of the API service

func MakeAPIServer

func MakeAPIServer(
	kos *kelpos.KelpOS,
	botConfigsPath *kelpos.OSPath,
	botLogsPath *kelpos.OSPath,
	horizonTestnetURI string,
	apiTestNet *horizonclient.Client,
	horizonPubnetURI string,
	apiPubNet *horizonclient.Client,
	ccxtRestUrl string,
	disablePubnet bool,
	enableKaas bool,
	noHeaders bool,
	quitFn func(),
	metricsTracker *plugins.MetricsTracker,
	guiConfig guiconfig.GUIConfig,
) (*APIServer, error)

MakeAPIServer is a factory method

func (*APIServer) InitBackend added in v1.11.0

func (s *APIServer) InitBackend() error

InitBackend initializes anything required to get the backend ready to serve

type ErrorResponse added in v1.8.0

type ErrorResponse struct {
	Error string `json:"error"`
}

ErrorResponse represents an error (deprecated)

type JSONWebKeys added in v1.12.0

type JSONWebKeys struct {
	Kty string   `json:"kty"`
	Kid string   `json:"kid"`
	Use string   `json:"use"`
	N   string   `json:"n"`
	E   string   `json:"e"`
	X5c []string `json:"x5c"`
}

type Jwks added in v1.12.0

type Jwks struct {
	Keys []JSONWebKeys `json:"keys"`
}

type KelpError added in v1.10.0

type KelpError struct {
	UUID       string     `json:"uuid"`
	ObjectType errorType  `json:"object_type"`
	ObjectName string     `json:"object_name"`
	Date       time.Time  `json:"date"`
	Level      errorLevel `json:"level"`
	Message    string     `json:"message"`
}

KelpError represents an error

func (*KelpError) String added in v1.10.0

func (ke *KelpError) String() string

String is the Stringer method

type KelpErrorListResponseWrapper added in v1.11.0

type KelpErrorListResponseWrapper struct {
	KelpErrorList []KelpError `json:"kelp_error_list"`
}

KelpErrorListResponseWrapper is the outer object that contains the Kelp Errors

type KelpErrorResponseWrapper added in v1.10.0

type KelpErrorResponseWrapper struct {
	KelpError KelpError `json:"kelp_error"`
}

KelpErrorResponseWrapper is the outer object that contains the Kelp Error

func (*KelpErrorResponseWrapper) String added in v1.10.0

func (kerw *KelpErrorResponseWrapper) String() string

String is the Stringer method

type RemoveKelpErrorRequest added in v1.11.0

type RemoveKelpErrorRequest struct {
	UserData     UserData `json:"user_data"`
	KelpErrorIDs []string `json:"kelp_error_ids"`
}

RemoveKelpErrorRequest is the outer object that contains the Kelp Error

type RemoveKelpErrorResponse added in v1.11.0

type RemoveKelpErrorResponse struct {
	RemovedMap map[string]bool `json:"removed_map"`
}

RemoveKelpErrorResponse is the outer object that contains the Kelp Error

type Response added in v1.12.0

type Response struct {
	Message string `json:"message"`
}

type ServerMetadataResponse added in v1.12.0

type ServerMetadataResponse struct {
	DisablePubnet bool                `json:"disable_pubnet"`
	EnableKaas    bool                `json:"enable_kaas"`
	GuiConfig     guiconfig.GUIConfig `json:"guiconfig"`
}

ServerMetadataResponse is the response from the /serverMetadata endpoint

type UserData added in v1.12.0

type UserData struct {
	ID string `json:"id"`
}

UserData is the json data passed in to represent a user

func (UserData) String added in v1.12.0

func (u UserData) String() string

String is the stringer method

Jump to

Keyboard shortcuts

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