aboutsummaryrefslogtreecommitdiff
path: root/templates/index.tpl
blob: 10ede3583ad1e6e8772b9486f3a6458fcace2725 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
{{template "base" .}}

{{define "title"}}Simple Pastebin{{end}}

{{define "content"}}
<h1>Simple pastebin</h1>

This is a simple pastebin that effectively only has API access.

Usernames are hard coded into the configuration file. The format is simple:

<pre><code>Users:
  username:
    Password: "password"
</code></pre>

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:

<pre><code>$ 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"}
$ 
</code></pre>

To add a paste use `/new`:

<pre><code>$ 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"}
$ 
</code></pre>

Viewing the json is pretty easy:

<pre><code>$ 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"}
$ 
</code></pre>

{{end}}