Esempio n. 1
0
// Handle authentication by access_token
func (t TokenAuthHandler) Handle(handler requestHandler) requestHandler {
	return func(w http.ResponseWriter, r *http.Request) {
		token := authtoken.Token(t.login, t.password, t.salt)

		if r.URL.Query().Get("access_token") == token {
			handler(w, r)
		} else {
			http.Error(w, "Authentication required", http.StatusUnauthorized)
		}
	}
}
Esempio n. 2
0
// Token prints the token generated for the config credentials
func Token(c *cli.Context) {
	configPath := c.GlobalString("config")

	config, err := parseConfig(configPath)

	if err != nil {
		log.Fatalf("Error parsing the config : %s", err)
		return
	}

	fmt.Print(string(authtoken.Token(config.HTTP.Login, config.HTTP.Password, config.HTTP.Salt)))
}