Documentation ¶
Index ¶
- Constants
- Variables
- func GenNonce(l int) string
- func InitHawkNonces(count int64)
- func SendPush(devRec *storage.Device, config *util.MzConfig) error
- type ClientBox
- type Handler
- func (self *Handler) Cmd(resp http.ResponseWriter, req *http.Request)
- func (self *Handler) Index(resp http.ResponseWriter, req *http.Request)
- func (self *Handler) InitDataJson(resp http.ResponseWriter, req *http.Request)
- func (r *Handler) Language(resp http.ResponseWriter, req *http.Request)
- func (self *Handler) Metrics(resp http.ResponseWriter, req *http.Request)
- func (self *Handler) OAuthCallback(resp http.ResponseWriter, req *http.Request)
- func (self *Handler) Queue(devRec *storage.Device, cmd string, args, rep *replyType) (status int, err error)
- func (self *Handler) Register(resp http.ResponseWriter, req *http.Request)
- func (self *Handler) RestQueue(resp http.ResponseWriter, req *http.Request)
- func (self *Handler) Signin(resp http.ResponseWriter, req *http.Request)
- func (self *Handler) Signout(resp http.ResponseWriter, req *http.Request)
- func (self *Handler) State(resp http.ResponseWriter, req *http.Request)
- func (self *Handler) Static(resp http.ResponseWriter, req *http.Request)
- func (self *Handler) Status(resp http.ResponseWriter, req *http.Request)
- func (self *Handler) UserDevices(resp http.ResponseWriter, req *http.Request)
- func (self *Handler) Validate(resp http.ResponseWriter, req *http.Request)
- func (self *Handler) WSSocketHandler(ws *websocket.Conn)
- type Hawk
- func (self *Hawk) AsHeader(req *http.Request, id, body, extra, secret string) string
- func (self *Hawk) Clear()
- func (self *Hawk) Compare(sig string) bool
- func (self *Hawk) GenerateSignature(req *http.Request, extra, body, secret string) (err error)
- func (self *Hawk) ParseAuthHeader(req *http.Request, logger util.Logger) (err error)
- type LangPath
- type LanguagePrefs
- type MockWSConn
- type Sock
- type WWS
- type WWSs
- type Worker
Constants ¶
const ( SESSION_NAME = "user" SESSION_LOGIN = "login" OAUTH_ENDPOINT = "https://oauth.accounts.firefox.com" CONTENT_ENDPOINT = "https://accounts.firefox.com" SESSION_USERID = "userid" SESSION_EMAIL = "email" SESSION_TOKEN = "token" SESSION_CSRFTOKEN = "csrftoken" SESSION_DEVICEID = "deviceid" )
Variables ¶
var ( ErrInvalidReply = errors.New("Invalid Command Response") ErrAuthorization = errors.New("Needs Authorization") ErrNoUser = errors.New("No User") ErrOAuth = errors.New("OAuth Error") ErrNoClient = errors.New("No Client for Update") ErrTooManyClient = errors.New("Too Many Clients for device") ErrDeviceDeleted = errors.New("Device deleted") ErrNoLanguage = errors.New("No Language json file found") )
Errors
var ErrInvalidSignature = errors.New("Header does not match signature")
var (
ErrInvalidSocket = errors.New("Invalid socket type specified")
)
var ErrNoAuth = errors.New("No Authorization Header")
var ErrNotHawkAuth = errors.New("Not a Hawk Authorization Header")
var ErrReplayedNonce = errors.New("Nonce detected. Replay?")
var HawkNonces *nonceCache
Functions ¶
func InitHawkNonces ¶
func InitHawkNonces(count int64)
Types ¶
type ClientBox ¶
var (
Clients *ClientBox
)
package globals
func NewClientBox ¶
func NewClientBox() *ClientBox
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
base handler for REST and Socket calls.
func NewHandler ¶
func (*Handler) Cmd ¶
func (self *Handler) Cmd(resp http.ResponseWriter, req *http.Request)
Handle the Cmd response from the device and pass next command if available.
func (*Handler) InitDataJson ¶
func (self *Handler) InitDataJson(resp http.ResponseWriter, req *http.Request)
Return the initData as a JSON object
func (*Handler) Metrics ¶
func (self *Handler) Metrics(resp http.ResponseWriter, req *http.Request)
Display the current metrics as a JSON snapshot
func (*Handler) OAuthCallback ¶
func (self *Handler) OAuthCallback(resp http.ResponseWriter, req *http.Request)
func (*Handler) Queue ¶
func (self *Handler) Queue(devRec *storage.Device, cmd string, args, rep *replyType) (status int, err error)
Queue the command from the Web Front End for the device.
func (*Handler) Register ¶
func (self *Handler) Register(resp http.ResponseWriter, req *http.Request)
Register a new device
func (*Handler) RestQueue ¶
func (self *Handler) RestQueue(resp http.ResponseWriter, req *http.Request)
Accept a command to queue from the REST interface
func (*Handler) State ¶
func (self *Handler) State(resp http.ResponseWriter, req *http.Request)
Show the state of the user's devices.
func (*Handler) Static ¶
func (self *Handler) Static(resp http.ResponseWriter, req *http.Request)
Handle requests for static content (should be an NGINX rule)
func (*Handler) Status ¶
func (self *Handler) Status(resp http.ResponseWriter, req *http.Request)
Show the status of the program (For Load Balancers)
func (*Handler) UserDevices ¶
func (self *Handler) UserDevices(resp http.ResponseWriter, req *http.Request)
func (*Handler) Validate ¶
func (self *Handler) Validate(resp http.ResponseWriter, req *http.Request)
Validate a given assertion (useful for client)
func (*Handler) WSSocketHandler ¶
Handle Websocket processing.
type Hawk ¶
type Hawk struct { Id string Time string Nonce string Method string Path string Host string Port string Extra string Hash string Signature string // contains filtered or unexported fields }
minimal HAWK for now (e.g. no bewit because IAGNI)
func (*Hawk) GenerateSignature ¶
Initialize self from request, extra and secret
Things to check: * Are all values being sent? (e.g. extra, time, secret) * Do the secrets match? * is the other format string formatted correctly? (two \n before extra, 0 after)
type LangPath ¶
func NewLangPath ¶
Language Path
type LanguagePrefs ¶
type LanguagePrefs []lang_loc
func (LanguagePrefs) Len ¶
func (r LanguagePrefs) Len() int
func (LanguagePrefs) Less ¶
func (r LanguagePrefs) Less(i, j int) bool
func (LanguagePrefs) Swap ¶
func (r LanguagePrefs) Swap(i, j int)
type MockWSConn ¶
== Mock Websocket Interface (used for testing)
func (*MockWSConn) Close ¶
func (*MockWSConn) Close() error
func (*MockWSConn) IsClientConn ¶
func (r *MockWSConn) IsClientConn() bool
func (*MockWSConn) Receive ¶
func (r *MockWSConn) Receive() []byte
absolute minimum of functions for what we need.
type WWS ¶
type WWS interface { Run() Close() error Born() time.Time Device() *storage.Device Handler() *Handler Logger() util.Logger Socket() Sock }
Websocket Handler function.