wmf

package
v0.0.0-...-42df541 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2014 License: MPL-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
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

View Source
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

View Source
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

View Source
var ErrInvalidSignature = errors.New("Header does not match signature")
View Source
var ErrNoAuth = errors.New("No Authorization Header")
View Source
var ErrNotHawkAuth = errors.New("Not a Hawk Authorization Header")

Functions

func GenNonce

func GenNonce(l int) string

Generate a nonce l bytes long (if l == 0, 6 bytes)

func SendPush

func SendPush(devRec *storage.Device, config *util.MzConfig) error

Types

type Handler

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

base handler for REST and Socket calls.

func NewHandler

func NewHandler(config *util.MzConfig, logger *util.HekaLogger, metrics *util.Metrics) *Handler

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) Index

func (self *Handler) Index(resp http.ResponseWriter, req *http.Request)

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) Signin

func (self *Handler) Signin(resp http.ResponseWriter, req *http.Request)

func (*Handler) Signout

func (self *Handler) Signout(resp http.ResponseWriter, req *http.Request)

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

func (self *Handler) WSSocketHandler(ws *websocket.Conn)

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) AsHeader

func (self *Hawk) AsHeader(req *http.Request, id, body, extra, secret string) string

Return a Hawk Authorization header

func (*Hawk) Clear

func (self *Hawk) Clear()

Clear the stickier bits

func (*Hawk) Compare

func (self *Hawk) Compare(sig string) bool

Compare a signature value against the generated Signature.

func (*Hawk) GenerateSignature

func (self *Hawk) GenerateSignature(req *http.Request, extra, body, secret string) (err error)

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

func (self *Hawk) ParseAuthHeader(req *http.Request, logger *util.HekaLogger) (err error)

Initialize self from the AuthHeader

type WWS

type WWS struct {
	Socket  *websocket.Conn
	Logger  *util.HekaLogger
	Handler *Handler
	Device  *storage.Device
	Born    time.Time
	Quit    bool
	// contains filtered or unexported fields
}

Websocket Handler function.

func (*WWS) Run

func (self *WWS) Run()

Workhorse function.

Directories

Path Synopsis
This file manages schema modification.
This file manages schema modification.

Jump to

Keyboard shortcuts

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