Pastebin

Documentation
Login
PASTEBIN(1)                                                        PASTEBIN(1)

NAME
     pastebin – Simplistic web pastebin

SYNOPSIS
     pastebin configfile

DESCRIPTION
     pastebin is a simple web pastebin, that can be used in HTTP or CGI mode.
     People can post without any restriction (except a size limit).

     An API, accessible via an API key, let the administrator manage the
     pastebin (purge old pastes, list pastes, delete a single paste).

CONFIGURATION FILE
     pastebin configuration file is made of key/value pairs:

   baseurl
     Specify the base url of this pastebin server (required). This value is
     used to generate valid pastes URL. When pastebin is used behind an http
     proxy, the public URL should be specified here.

     Example:
           baseurl: https://domain.test/pastebin

     Using the value above, the pastes URL will have the following form:
           https://domain.test/pastebin/e2bd5143bd

     And the administator API will be available as:
           https://domain.test/pastebin/api/...

   dbpath
     Specify the location of the sqlite3 database (required). The database is
     created automatically if not present.

     Example:
           dbpath: /var/db/pastebin.sqlite3

   sizelimit
     Specify the POST size limit in megabytes. If this value is missing, POST
     are unlimited.

     Example:
           sizelimit: 10

   apikeyhash
     SHA1 hash of the API key to access the admin API. If this field is
     missing, the admin API is disabled.

     Example:
           apikeyhash: 64faf5d0b1dc311fd0f94af64f6c296a03045571

   httpport
     Specify the port to bind for HTTP connections. If the value is 0,
     pastebin work in CGI mode. Default value is 8080.

     Example:
           httpport: 80

SAMPLE HTTP CONFIG
     Here goes a complete configuration in HTTP mode:

           $ cat pastebin.cfg
           baseurl: https://domain.test/pastebin
           dbpath: /var/db/pastebin.sqlite3
           apikeyhash: 64faf5d0b1dc311fd0f94af64f6c296a03045571
           sizelimit: 10

     And the pastebin server can be started this way:

           $ pastebin pastebin.cfg

SAMPLE CGI CONFIG
     A CGI script can be setup in a single file, using pastebin as a shebang
     interpreter, and the rest of the file for configuration pragmas:

           $ cat pastebin.cgi
           #!/usr/local/bin/pastebin
           baseurl: https://domain.test/pastebin.cgi
           dbpath: /var/db/pastebin.sqlite3
           apikey: 64faf5d0b1dc311fd0f94af64f6c296a03045571
           sizelimit: 10
           httpport: 0

     Then, a web server has to be configured to serve this CGI script.

USAGE
     The pastebin can be used from a web browser:

           $ firefox https://domain.test/pastebin

     or from the command line:

           $ curl -F 'data=<-' https://domain.test/pastebin < image.jpg
           https://domain.test/pastebin/1bbe793662

ADMIN API
     Pastebin provide a small API to manage pastes.

   GET <baseurl>/api/pastes
     List pastes in JSON format.

     Example:

           $ curl -H "Authorization: Apikey your-api-key" \
                   https://domain.test/pastebin/api/list
           [
             {
               "url": "https://domain.test/pastebin/46dbac46ae",
               "inserttime": "2019-10-28T15:38:10Z",
               "mimetype": "text/plain; charset=UTF-8"
             },
             {
               "url": "https://domain.test/pastebin/1085a72014",
               "inserttime": "2019-11-04T12:45:10Z",
               "mimetype": "application/json"
             }
           ]

   DELETE <baseurl>/api/pastes/<pasteid>
     Delete a single paste. The <pasteid> argument must be the 10
     characters hexadecimal value assigned to a paste.

     Example:

           $ curl -H "Authorization: Apikey your-api-key" \
                   -X DELETE \
                   https://domain.test/pastebin/api/pastes/1085a72014

   DELETE <baseurl>/api/pastes/purge/<ndays>
     Purge pastes older than <ndays> days.

     Example:

           $ curl -H "Authorization: Apikey your-api-key" \
                   -X DELETE \
                   https://domain.test/pastebin/api/pastes/purge/10

AUTHOR
     Gerome Fournier <jef@foutaise.org>.

                                 November 2019