Categorygithub.com/sid-sun/ioctl-api
module
0.0.0-20221129182629-521bf6908cb9
Repository: https://github.com/sid-sun/ioctl-api.git
Documentation: pkg.go.dev

# README

i/o/ctl


An E2E Encrypted Pastebin App

Try out here: https://bin.dronk.dev

Or, if you prefer, use the API directly: https://api.bin.dronk.dev

> echo "Hello, World!" > hello-world.txt 

> # just use curl --upload-file

> curl --upload-file hello-world.txt https://api.bin.dronk.dev

{"URL":"https://api.bin.dronk.dev/r/EmbossChemicals"}

> curl https://api.bin.dronk.dev/r/EmbossChemicals
Hello, World!

> echo "i/o/ctl is awesome!"
i/o/ctl is awesome!

Features:

  • Store and fetch encrypted and end-to-end encrypted snippets
  • Snippets get saved against an easy to remember, id like HedgingSmitten
  • Snippets are compressed using zlib
  • Use S3 as storage backend along with global CDN
  • Send snippet as formatted JSON, E2E Encrypted JSON or raw body
  • Use POST and PUT at endpoint / to save snippet
  • Use POST and PUT at endpoint /e2e to end-to-end encypted snippet
  • Get snippet using GET at endpoint /<ID> or /r/<ID> or directly from S3 / CDN
  • Snippets are by default ephemeral and stored for 7 days

Quick Start:

Prerequisites: AWS S3, Docker, Docker Compose and curl

  • git clone --depth=1 https://github.com/sid-sun/ioctl-api
  • cd snippets-api
  • edit quickstart.env and add your AWS S3 details (currently tied to AWS)
  • docker compose up -d
  • Upload a snippet
    • curl --upload-file dev.env http://localhost:8080/
    • Copy the URL field returned in JSON
  • Fetch snippet
    • curl <URL you copied>
  • docker compose down

Setup for Development:

  • git clone --depth=1 https://github.com/sid-sun/ioctl-api
  • cd snippets-api
  • go mod download
  • edit dev.env and add your AWS S3 details (currently tied to AWS)
  • Start application server
    • env $(cat dev.env | xargs -L 1) go run src/main.go

Deployment / Self-Hosting:

The easiest way to self-host is to simply run an instance of realsidsun/snippets-api on a server, and reverse-proxy it after creating a S3 Bucket on AWS and a programatic access key and secret with the following permissions:

"Action": [
    "s3:PutObject",
    "s3:GetObject",
    "s3:GetObjectAttributes",
    "s3:ListBucket",
    "s3:PutObjectAcl"
]

NOTE: Look at the Config section down below before you deploy


Cryptographic Specification

  • The Cryptographic specification is defined here

Config

Configuration is done through environment variables

General Config:

NameType / OptionsDescriptionRequiredDefault
ENVstringApplication Environmentnodev
LOG_LEVELdebug / info / warn / errorLog Level to printnodebug
OVERRIDEScomma and colon seperated mappingsoverride certain IDs for About, etcno

Example Overrides: About:BackwashLicorice,PrivacyPolicy:TranceUnsterile

Cryptographic Config:

NameType / OptionsDescriptionRequiredDefault
SALTstringCommon SALT used for ID Derivationyes
ARGON2_ID_MEMORYnumberARGON2 ID Memory / space param in MBno32
ARGON2_ID_ROUNDSnumberARGON2 ID rounds / iterations paramno32
ARGON2_ID_PARALLELISMnumberARGON2 ID parallelism paramno12
ARGON2_KEY_MEMORYnumberARGON2 KEY Memory / space param in MBno64
ARGON2_KEY_ROUNDSnumberARGON2 KEY rounds / iterations paramno12
ARGON2_KEY_PARALLELISMnumberARGON2 KEY parallelism paramno16

S3 Config:

NameTypeDescriptionRequired
S3_PROVIDERstringS3 Provider Name: S3 (default) or R2no
S3_BUCKETstringS3 Bucket Nameyes

You only need one of these (as per your S3 Provider):

AWS S3 Config:
NameTypeDescriptionRequired
AWS_ACCESS_KEYstringAWS Programmatic Access Key / IDyes
AWS_SECRET_KEYstringAssociated Programmatic Secret Keyyes
AWS_REGIONstringAWS Hosting Regionyes
CloudFlare R2 Config:
NameTypeDescriptionRequired
CLOUDFLARE_ACCOUNT_IDstringCloudflare Account IDyes
CLOUDFLARE_R2_ACCESS_KEY_IDstringCloudflare R2 API Access Keyyes
CLOUDFLARE_R2_ACCESS_KEY_SECRETstringCloudflare R2 API Access Key Secretyes

HTTP Server Config:

NameType / OptionsDescriptionRequiredDefault
HTTP_LISTEN_HOSTstringHTTP Server listen hostno127.0.0.1
HTTP_LISTEN_PORTnumberReplica Set name if using replicaset instanceno8080
HTTP_CORS_LISTcomma seperated stringsAllowed HTTP cross origins listnohttp://localhost:*
HTTP_BASE_URLstringHTTP/S frontend URL to use for formattingnohttp://localhost:8080
HTTP_API_ENDPOINTstringAPI mount Endpoint from baseno/snippets
HTTP_RETURN_FORMATjson / rawDefault URI for URL to created snippetnoraw

# Packages

No description provided by the author
No description provided by the author