Documentation ¶
Index ¶
- Constants
- Variables
- func GenNonce(l int) string
- func SendPush(devRec *storage.Device, config *util.MzConfig) error
- 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 (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.HekaLogger) (err error)
- type WWS
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") )
Errors
var ( // using a map of maps here because it's less hassle than iterating // over a list. Need to investigate if there's significant memory loss Clients = make(map[string]map[string]*WWS) )
package globals
var ErrInvalidSignature = errors.New("Header does not match signature")
var ErrNoAuth = errors.New("No Authorization Header")
var ErrNotHawkAuth = errors.New("Not a Hawk Authorization Header")
Functions ¶
Types ¶
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)
func (*Hawk) ParseAuthHeader ¶
Initialize self from the AuthHeader