Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gabriel-samfira/gopherbin
A simple pastebin written in Go
https://github.com/gabriel-samfira/gopherbin
golang paste pastebin
Last synced: about 1 month ago
JSON representation
A simple pastebin written in Go
- Host: GitHub
- URL: https://github.com/gabriel-samfira/gopherbin
- Owner: gabriel-samfira
- License: apache-2.0
- Created: 2019-12-06T16:00:13.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-05-30T11:28:20.000Z (7 months ago)
- Last Synced: 2024-08-03T15:17:28.646Z (4 months ago)
- Topics: golang, paste, pastebin
- Language: Go
- Size: 5.65 MB
- Stars: 7
- Watchers: 4
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-starred - gabriel-samfira/gopherbin - A simple pastebin written in Go (golang)
README
# Gopherbin
Welcome to Gopherbin. This project offers a simple password protected, paste-like service, that you can self host. This is an initial release, so expect bugs.
[![Get it from the Snap Store](https://snapcraft.io/static/images/badges/en/snap-store-black.svg)](https://snapcraft.io/gopherbin)
## Building
### Using Go
You will need at least Go version ```1.16```.
Gopherbin uses the embed feature in Go to optionally bundle the [Web UI](https://github.com/gabriel-samfira/gopherbin-web). You can choose to build without a web UI and simply serve the needed static files using a proper web server.
Clone Gopherbin:
```bash
git clone https://github.com/gabriel-samfira/gopherbin
```If you want to build the UI, you will need a recent version of nodejs and yarn. With those dependencies installed, simply run:
```bash
make all
```Building without a UI:
```bash
make all-noui
```### Building a docker image
```bash
# For a full list of available variables and commands run: make help# creating docker image
make build-image# start a container using image previously built
make start-container```
## Creating a database
Gopherbin can use either MySQL/MariaDB or SQLite3.
If you're planning on using MySQL, you'll need to create the database first:
```sql
create database gopherbin;
create user 'gopherbin'@'%' identified by 'superSecretPassword';
grant all on gopherbin.* to 'gopherbin'@'%';
flush privileges;
```## Configuration
The config is a simple toml.
```toml
[apiserver]
bind = "0.0.0.0"
port = 9997
use_tls = false[apiserver.jwt_auth]
# secret used to sign jwt tokens
#
secret = "beerdesOwshitvobkeshyijuchepavbiejCefJubemrirjOnJeutyucHalHushbo"
# the duration, a token will be valid for
# format is of the form 4m41s
time_to_live = "1h"# [apiserver.tls]
# certificate = "/path/to/cert.pem"
# key = "/path/to/key.pem"
# ca_certificate = "/path/to/ca_cert.pem"[database]
# Valid options are: mysql, sqlite3
backend = "sqlite3"# [database.mysql]
# username = "gopherbin"
# # This obviously also needs to be changed :-)
# password = "superSecretPassword"
# hostname = "192.168.100.10"
# database = "gopherbin"[database.sqlite3]
db_file = "/tmp/gopherbin.sql"
```## First run
Simply run the Gopherbin service. Gopherbin will create the database tables automatically:
```bash
/tmp/gopherbin -config /tmp/config.toml
```Before you can use Gopherbin, you need to create the super user. This user is the admin of the system, which can create new users and regular admins. Gopherbin will not allow anyone to log in if this user is missing. The super user can create regular administrators, that can in turn create regular users.
Anyway, let's get to it:
```bash
# Make sure you change the passwordcurl -0 -X POST http://127.0.0.1:9997/api/v1/first-run/ \
-H "Content-type: application-json" \
--data-binary @- << EOF
{
"email": "[email protected]",
"username": "john",
"full_name": "John Doe",
"password": "ubdyweercivIch"
}
EOF
```If you're running on your local machine, you should be able to access Gopherbin at:
```bash
http://127.0.0.1:9997
```Otherwise, use your own server's IP address.