func cronAuthHandler(res *wcg.Response, req *wcg.Request) bool { cron := req.Header("X-Appengine-Cron") if cron == "true" { req.User = &ApiUser{ token: &models.ApiToken{ Token: "x-appengine-cron", Description: "Dummy API Token (cron user)", CreatedAt: time.Now(), }, lastLogin: time.Now(), } return true } return false }
func apiTokenAuthHandler(res *wcg.Response, req *wcg.Request) bool { token := req.Header("X-SPEEDLAND-API-Token") if token != "" { // API Access d := NewApiTokenDriver(NewAppContextFromRequest(req)) user, err := d.ApiUser(token) if err != nil || user == nil { req.Logger.Warn("API Token(%q) login failed: %v", token, err) } else { req.User = user return true } } return false }