Exemplo n.º 1
0
func ahAuthHandler(res *wcg.Response, req *wcg.Request) bool {
	if strings.HasPrefix(req.URL().Path, "/_ah/") {
		req.User = &ApiUser{
			token: &models.ApiToken{
				Token:       "x-appengine-ah",
				Description: "Dummy API Token (_ah user)",
				CreatedAt:   time.Now(),
			},
			lastLogin: time.Now(),
		}
		return true
	}
	return false
}
Exemplo n.º 2
0
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
}
Exemplo n.º 3
0
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
}