bpaste

command module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 25, 2022 License: ISC Imports: 17 Imported by: 0

README

Brutally simple pastebin

Brutally simple pastebin in go, utilizing almost nothing but the standard library.

API:

GET /view/<id>		# Returns the contents of the paste at that ID
			# Content type is set to text/plain regardless.
			# Never requires authentication

POST /new		# Create a new paste from the content in the HTTP body.
			# No parsing is done server side.
			# HTTP response body will contain the ID followed by a
			# single newline
			# If configured, will require http basic auth in order
			# to use this endpoint

GET /list		# List all of the pastes
			# If configured, will require http basic auth in order
			# to use this endpoint

Examples:

Create a new paste:

curl -X POST --data-binary @/path/to/file http://localhost:6130/new

Display a paste

curl http://localhost:6130/view/<id>

Each paste is a file, a random id assigned at creation. There's no way to edit or change a paste. The only way to delete it is to remove it from the filesystem manually.

Installation

If you have go already installed and properly configured on your system and would like to mess with it:

go install riedstra.dev/mitch/bpaste@latest

Will install it.

Configuration

By default if it doesn't detect any users it will run without authentication. It warns you of this. You do not want this running on a public network segment without auth.

To setup authentication supply environment variables in the form of:

USER_<username>=<hash>

You can generate a hash interactive from the server executable:

$ go run . -genhash
Enter password:
Again:
hash: $2a$10$MdpHOxqyaxVwX7tBmch/MOnuq5jgcy7ciCUGwixVR43SchyDtxLVW
$

So, to allow Mitch to utilize that password:

$ export USER_mitch='$2a$10$MdpHOxqyaxVwX7tBmch/MOnuq5jgcy7ciCUGwixVR43SchyDtxLVW'

The server will print the users it finds on startup:

$ go run main.go -s storage/
Found user: sally
Found user: bob
Found user: mitch
Found user: ted
listening on:  :6130

Production configuration

Put it behind Nginx, Caddy or some other HTTPS capable proxy. Make SURE user authentication is configured.

The details of that reverse proxy configuration are beyond the scope of this readme.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL