server

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2022 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RunID string

Functions

func APIMux

func APIMux() (*chi.Mux, error)

APIMux gives the REST API

func APINotFound

func APINotFound(w http.ResponseWriter, r *http.Request)

func AddAdminUser

func AddAdminUser(w http.ResponseWriter, r *http.Request)

func AuthMux

func AuthMux(a *Auth) (*chi.Mux, error)

func ClearUpdates

func ClearUpdates(w http.ResponseWriter, r *http.Request)

func CreateApp

func CreateApp(w http.ResponseWriter, r *http.Request)

func CreateObject

func CreateObject(w http.ResponseWriter, r *http.Request)

func CreateUser

func CreateUser(w http.ResponseWriter, r *http.Request)

func DeleteApp

func DeleteApp(w http.ResponseWriter, r *http.Request)

func DeleteObject

func DeleteObject(w http.ResponseWriter, r *http.Request)

func DeleteUser

func DeleteUser(w http.ResponseWriter, r *http.Request)

func DeleteUserSession

func DeleteUserSession(w http.ResponseWriter, r *http.Request)

func EventWebsocket

func EventWebsocket(w http.ResponseWriter, r *http.Request)

func FireEvent

func FireEvent(w http.ResponseWriter, r *http.Request)

func FrontendMux

func FrontendMux() (*chi.Mux, error)

FrontendMux represents the frontend

func GetAdminUsers

func GetAdminUsers(w http.ResponseWriter, r *http.Request)

func GetAllPlugins

func GetAllPlugins(w http.ResponseWriter, r *http.Request)

func GetAppScope

func GetAppScope(w http.ResponseWriter, r *http.Request)

func GetConfigFile

func GetConfigFile(w http.ResponseWriter, r *http.Request)

func GetObjectScope

func GetObjectScope(w http.ResponseWriter, r *http.Request)

func GetPluginApps

func GetPluginApps(w http.ResponseWriter, r *http.Request)

func GetPluginReadme

func GetPluginReadme(w http.ResponseWriter, r *http.Request)

func GetUConfig

func GetUConfig(w http.ResponseWriter, r *http.Request)

func GetUpdateOptions

func GetUpdateOptions(w http.ResponseWriter, r *http.Request)

func GetUpdateStatus

func GetUpdateStatus(w http.ResponseWriter, r *http.Request)

func GetUpdates

func GetUpdates(w http.ResponseWriter, r *http.Request)

func GetUserSettingSchemas

func GetUserSettingSchemas(w http.ResponseWriter, r *http.Request)

func GetVersion

func GetVersion(w http.ResponseWriter, r *http.Request)

func HandleTemplate added in v0.5.1

func HandleTemplate(fname string, fbytes []byte) (http.HandlerFunc, error)

func ListApps

func ListApps(w http.ResponseWriter, r *http.Request)

func ListObjects

func ListObjects(w http.ResponseWriter, r *http.Request)

func ListUserSessions

func ListUserSessions(w http.ResponseWriter, r *http.Request)

func ListUsers

func ListUsers(w http.ResponseWriter, r *http.Request)

func NewStaticHandler added in v0.5.1

func NewStaticHandler(root http.FileSystem, nocache bool) http.Handler

NewStaticHandler tries to serve the original files, but if they are not found, it will serve a compressed version of the file. Usually this is reversed, but in heedy, the build process actually *removes* the original files, so when the compressed files exist, the originals are not present. It also sets up the correct caching headers for static files

func PatchUConfig

func PatchUConfig(w http.ResponseWriter, r *http.Request)

func PostConfigFile

func PostConfigFile(w http.ResponseWriter, r *http.Request)

func PostPlugin

func PostPlugin(w http.ResponseWriter, r *http.Request)

func PostUpdateOptions

func PostUpdateOptions(w http.ResponseWriter, r *http.Request)

func ReadApp

func ReadApp(w http.ResponseWriter, r *http.Request)

func ReadObject

func ReadObject(w http.ResponseWriter, r *http.Request)

func ReadUser

func ReadUser(w http.ResponseWriter, r *http.Request)

func ReadUserPluginSettings

func ReadUserPluginSettings(w http.ResponseWriter, r *http.Request)

func ReadUserSettings

func ReadUserSettings(w http.ResponseWriter, r *http.Request)

func RemoveAdminUser

func RemoveAdminUser(w http.ResponseWriter, r *http.Request)

func Run

func Run(a *assets.Assets, o *RunOptions) error

func Setup

func Setup(sc SetupContext) error

Setup runs the setup server. All of the arguments are optional - include empty strings for the directory and configFile if they are not given, and nil for configuration if no settings were given. This will load the default config, overwritten with configFile, overwritten with c, and use that as the "defaults" for fields given to the user.

func SetupCreate

func SetupCreate(sc SetupContext) error

func UpdateApp

func UpdateApp(w http.ResponseWriter, r *http.Request)

func UpdateObject

func UpdateObject(w http.ResponseWriter, r *http.Request)

func UpdateUser

func UpdateUser(w http.ResponseWriter, r *http.Request)

func UpdateUserPluginSettings

func UpdateUserPluginSettings(w http.ResponseWriter, r *http.Request)

func VerboseLoggingMiddleware

func VerboseLoggingMiddleware(h http.Handler, log *logrus.Entry) http.Handler

VerboseLoggingMiddleware performs extremely verbose logging - including all incoming requests and responses. This can be activated using --vvv on the server

Types

type Auth

type Auth struct {
	DB *database.AdminDB
	// contains filtered or unexported fields
}

Auth handles the oauth flow

func NewAuth

func NewAuth(db *database.AdminDB) *Auth

NewAuth creates a new oauth flow handler using an admin DB

func (*Auth) Authenticate

func (a *Auth) Authenticate(w http.ResponseWriter, r *http.Request) (database.DB, error)

func (*Auth) RequestCode

func (a *Auth) RequestCode(r *http.Request) (*CodeRequest, error)

RequestCode returns the information relevant to an authorization code request

func (*Auth) ServeCode

func (a *Auth) ServeCode(w http.ResponseWriter, r *http.Request)

ServeCode handles a post request to the code endpoint

func (*Auth) ServeToken

func (a *Auth) ServeToken(w http.ResponseWriter, r *http.Request)

ServeToken handles a post request to the token endpoint. It handles password grants and authorization code requests

type CodeRequest

type CodeRequest struct {
	// These are parameters of an authorization request on Oauth2
	// https://www.oauth.com/oauth2-servers/authorization/the-authorization-request/
	ClientID    string `json:"client_id,omitempty"`
	RedirectURI string `json:"redirect_uri,omitempty"`
	State       string `json:"state,omitempty"`
	Scope       string `json:"scope,omitempty"`

	// The app object to create - if clientID is not set
	App *database.App
}

CodeRequest is sent in by the client trying to create a app. It is identical to a standard oauth request authorization code request if the client is known. If it is an unknown client, allows the client to request creation of a specific app on its behalf.

type FrontendContext added in v0.5.1

type FrontendContext struct {
	User     *database.User                    `json:"user"`
	Settings map[string]map[string]interface{} `json:"settings"`
	Admin    bool                              `json:"admin"`
	Plugins  []frontendPlugin                  `json:"plugins"`
	Preload  []string                          `json:"preload"`
	Verbose  bool                              `json:"verbose"`
	DevMode  bool                              `json:"dev_mode"`
	RunID    string                            `json:"run_id"`
}

func GetFrontendContext added in v0.5.1

func GetFrontendContext(ctx *rest.Context) (*FrontendContext, error)

type RequestHandler

type RequestHandler struct {
	Plugins *plugins.PluginManager

	// The auth system also allows special token-based access. This is specifically built
	// to support plugins. Each request that is forwarded through the plugin system
	// is first authenticated here, and given an auth token. Plugins can then make requests
	// with that auth token which will have the same permissions, and be linked to the original
	// request.
	sync.RWMutex
	// contains filtered or unexported fields
}

RequestHandler is a middleware that authenticates requests and generates a Context object containing the info necessary to complete the request. It also handles generating and parsing the relevant X-Heedy headers that are used for interaction with plugin backend servers.

func NewRequestHandler

func NewRequestHandler(auth *Auth, p *plugins.PluginManager) *RequestHandler

NewRequestHandler generates a new Auth middleware

func (*RequestHandler) Request

func (a *RequestHandler) Request(c *rest.Context, method, path string, body interface{}, header map[string]string) (io.Reader, error)

func (*RequestHandler) ServeHTTP

func (a *RequestHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP - http.Handler implementation

type RunOptions

type RunOptions struct {
}

RunOptions give special options for running

type SetupContext

type SetupContext struct {
	assets.CreateOptions
	User SetupUser `json:"user,omitempty"`
}

This is the context that is passed to creator function

type SetupTemplate added in v0.5.1

type SetupTemplate struct {
	Directory string    `json:"directory"`
	URL       string    `json:"url"`
	Addr      string    `json:"addr"`
	User      SetupUser `json:"user"`
}

type SetupUser

type SetupUser struct {
	UserName string `json:"username"`
	Name     string `json:"name"`
	Password string `json:"password"`
}

type WebsocketEventHandler

type WebsocketEventHandler struct {
	Ws           *websocket.Conn
	R            *http.Request
	Heartbeat    time.Duration
	WriteTimeout time.Duration
	Haderror     chan error

	sync.Mutex
	// contains filtered or unexported fields
}

func (*WebsocketEventHandler) Close added in v0.5.1

func (eh *WebsocketEventHandler) Close()

func (*WebsocketEventHandler) Fire

func (eh *WebsocketEventHandler) Fire(e *events.Event)

func (*WebsocketEventHandler) ResetHeartbeat added in v0.5.1

func (eh *WebsocketEventHandler) ResetHeartbeat()

Jump to

Keyboard shortcuts

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