{{template "base" .}} {{define "title"}}Simple Pastebin{{end}} {{define "content"}}

Simple pastebin

This is a simple pastebin that effectively only has API access. Usernames are hard coded into the configuration file. The format is simple:
Users:
  username:
    Password: "password"
If there are any non empty `Password` fields they will be replaced with the hash on first run. Run a request to `/login` to receieve a token:
$ curl -D /dev/fd/2 -d '{"Username": "mitch", "Password": "secret"}' localhost:6130/login
HTTP/1.1 200 OK
Authorization: Bearer eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2Mjk2MjY4ODMsInN1YiI6Im1pdGNoIn0.8t5IU8WCVWwMozWyufGqFFmKF1mggLI7V8U1tX-u3yllTalbQRgG2PrxPQeVU9pAM6fuapmydXXZYGpehezqDw
Content-Type: application/json
Date: Sat, 21 Aug 2021 22:08:03 GMT
Content-Length: 180

{"token":"eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2Mjk2MjY4ODMsInN1YiI6Im1pdGNoIn0.8t5IU8WCVWwMozWyufGqFFmKF1mggLI7V8U1tX-u3yllTalbQRgG2PrxPQeVU9pAM6fuapmydXXZYGpehezqDw"}
$ 
To add a paste use `/new`:
$ export token=eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2Mjk2MjY4ODMsInN1YiI6Im1pdGNoIn0.8t5IU8WCVWwMozWyufGqFFmKF1mggLI7V8U1tX-u3yllTalbQRgG2PrxPQeVU9pAM6fuapmydXXZYGpehezqDw
$ curl -D /dev/fd/2 -X POST -d '
	{
		"Title": "My title!",
		"Tags": {"code": null, "c": null},
		"Content": "This is my test content.\n\n\n"
	}' -H "Authorization: Bearer $token" localhost:6130/new
HTTP/1.1 200 OK
Content-Type: application/json
Date: Sat, 21 Aug 2021 22:20:53 GMT
Content-Length: 46

{"id":"YAv-lFYh9xpnP6ZZ0-Hu_w","status":"ok"}
$ 
Viewing the json is pretty easy:
$ curl localhost:6130/view/json/YAv-lFYh9xpnP6ZZ0-Hu_w
{"Id":"YAv-lFYh9xpnP6ZZ0-Hu_w","Title":"My
title!","Tags":{"c":{},"code":{}},"Content":"This is my test content.\n\n\n"}
$ 
{{end}}