auth..
This commit is contained in:
		| @ -62,6 +62,7 @@ func main() { | |||||||
| 	req, err := http.NewRequest("POST", outURL, in) | 	req, err := http.NewRequest("POST", outURL, in) | ||||||
| 	fail(err) | 	fail(err) | ||||||
|  |  | ||||||
|  | 	req.Header.Set("Authorization", "Bearer "+*token) | ||||||
| 	req.Header.Set("X-Content-SHA1", sha1Hex) | 	req.Header.Set("X-Content-SHA1", sha1Hex) | ||||||
|  |  | ||||||
| 	log.Print("uploading...") | 	log.Print("uploading...") | ||||||
|  | |||||||
| @ -58,6 +58,11 @@ func handleHTTP(w http.ResponseWriter, req *http.Request) { | |||||||
| 		http.ServeFile(w, req, filePath) | 		http.ServeFile(w, req, filePath) | ||||||
|  |  | ||||||
| 	case "POST": | 	case "POST": | ||||||
|  | 		if req.Header.Get("Authorization") != ("Bearer " + *uploadToken) { | ||||||
|  | 			http.Error(w, "unauthorized", http.StatusUnauthorized) | ||||||
|  | 			return | ||||||
|  | 		} | ||||||
|  |  | ||||||
| 		tmpOut := filepath.Join(filepath.Dir(filePath), "."+filepath.Base(filePath)) | 		tmpOut := filepath.Join(filepath.Dir(filePath), "."+filepath.Base(filePath)) | ||||||
|  |  | ||||||
| 		if err := os.MkdirAll(filepath.Dir(filePath), 0755); err != nil { | 		if err := os.MkdirAll(filepath.Dir(filePath), 0755); err != nil { | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user