Code Monkey home page Code Monkey logo

yabin's Introduction

YABin: Yet Another Pastebin

GitHub Sponsor GitHub License Stars Demo Website

ko-fi

Demo

Demo Video

Why (yet) another pastebin?

Well, cause no pastebin I could find had ALL of the following features:

  • Modern and minimal UI (This site's design was inspired by bin).
  • Optional end-to-end encryption (we're using AES-256-GCM) with optional password protection (using PBKDF2).
  • Syntax highlighting (using Prism) that supports 297 languages.
  • API support to create and get pastes from command line.
  • View raw pastes. Normally, encrypted pastebins do not have this. With this site, you can either get the Base64-encoded encrypted paste, or decrypt it on the server side (even with the password) and get the raw paste.
  • Keyboard shortcuts!
  • And of course, being fully open-source and easily self-hostable.
  • Ability to edit pastes after creation, and a dashboard for viewing all your pastes.
  • NEW Feature to use custom path names.
  • Comes with a CLI tool to create and read pastes from the command line!

API Documentation

See API.md.

CLI Usage

Installation and Usage

pip install yabin
yabin create
yabin read "<URL>"

See cli/README.md for detailed instructions and library usage.

How to Host

Requirements: Node.js (tested on 18+, should work with 14+), and a SQL database (tested on PostgreSQL, should work with MySQL and SQLite).

Right now, my instance is using PostgreSQL on Vercel.

.env Configuration

By default, it is configured to use PostgreSQL. However, it can be run using any SQL DB such as SQLite or MySQL. To use other backends, please update the provider in schema.prisma.

  • DB_NAME is the database name;
  • DB_HOST database host (defaults to 'db', but can be changed to aything like localhost)
  • DB_USER database user
  • DB_PORT database port 5432
  • DB_PASSWORD the database user password
  • DATABASE_URL you don't need to modify this variable (thanks to dotenv-expand). keep it though!

Remember to modify SALT to something secure if you plan on using user accounts.

You can disable or enable public registration by modifying the PUBLIC_REGISTRATION_ENABLED variable to true or false.

You can enable custom paste paths for everyone with the variable PUBLIC_CUSTOM_PATHS_ENABLED. If it is false, only users who are logged in can use custom paths.

You can disable anonymous pastes by setting PUBLIC_ANONYMOUS_PASTES_ENABLED to false.

By default, if no e-mail services are configured, all user accounts will be marked as validated. To enable e-mail validation, please configure the MAIL_* variables.

Locally

yarn install
cp .env.example .env
# Modify .env to add the database URL and other parameters
yarn dev

Using Docker

docker run --env-file .env -it -p 3000:3000 yureien/yabin:latest
# Or with Docker Compose
# Remember to change the DB password!
docker compose up

Fun fact: At a point of time, my instance used to be hosted in a Kubernetes cluster

Other Serverless Environments (Cloudflare Workers, Netlify etc.)

I have not yet tested this, but this is made with SvelteKit. Please take a look at the SvelteKit documentation for more information. If there are any issues, please open an issue, and I will put up a proper guide on how to deploy on such environmments.

My instance uses Vercel. Checkout the vercel branch for the Vercel configuration.

Public Instances

If you host one and want to make it public, just open an issue and I will add it here!

  1. bin.sohamsen.me Website Status

yabin's People

Contributors

ashmit-coder avatar corno-manso avatar dependabot[bot] avatar melkor333 avatar paulkim26 avatar yureien avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

yabin's Issues

Add a shell script

The API is already available. A shell script needs to be created to easily upload pastes and fetch pastes. Should preferably support encryption/decryption and password protection.

Support for custom paths for paste

Enable using custom paths for pastes instead of a random string. A new textbox (with proper validation) can be added to the home page for this.

Bonus points: Add a flag in the .env file so that custom paths can be enabled for everyone, only for registered users or disabled globally.

Email Validation during registration blocks valid emails

Reproduction Steps:

  1. Navigate to /register
  2. Enter an email address that either:
  1. Fill out the other fields, then click "Register."

Expected Result:
An email is sent and the "Please check your e-mail for verification link" message is shown onscreen.

Actual Result:
No email is sent, and a different message, "Invalid email address" is shown onscreen.


I believe the culprit is https://github.com/Yureien/YABin/blob/main/src/lib/server/validate.ts#L1:

const emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/g;

Some other valid addresses that are considered invalid (that someone might theoretically want to be able to register with, particularly if YABin is deployed on their own network) include:

There are also a ton of "valid" addresses that it does not allow, but that are so rare as to probably not worth accounting for, like "user name"@example.com

Addressing the specific issues I ran into, with minimal changes, could be achieved with the following three character change (NOTE: The removal of the g flag is because the regex is stateful when it is set, and that is undesirable):

const emailRegex = /^[\w-+.]+@([\w-]+\.)+[\w-]{2,}$/;

Alternatively, here's a more complex regex that correctly handles more types of invalid addresses:

const emailRegex = /^([\w%+-]+\.)*[\w%+-]+@([A-Z0-9-]+\.)+[A-Z0-9-]{2,}$/i;

This doesn't validate the @[IP address ending in a single digit octet] or @localhost emails, but my understanding is those are extremely rare, anyway, and they're not validated by the current regex, anyway, so it isn't a regression. It correctly prohibits the username part from ending with a period and allows % in the username portion, which is technically allowed (but I've never seen it used). It also correctly prohibits underscores in the domain portion.

Yet another option would be to use an established library like validator, email-validator, isemail, etc.. It looks like the validator library is the most used, very configurable, and seems to be actively developed, but it also has a decent number of open issues related to email validation. It also provides several other validators that you don't need. The other two libraries haven't had a new version pushed in 5+ years, but they still get 500k downloads weekly. From my perspective, that's probably overkill.

Dashboard for users

Create a dashboard page which will have the following features:

  • Ability to edit/view/delete own pastes
  • Ability to set defaults such as expiry, should pastes be encrypted by default, etc.
  • Change password/user details page

A separate MR can be created for all the above ideas!

Add CLI support for authentication

Right now, the CLI cannot edit pastes and has no concept of authentication. A login feature can be added and future pastes will be saved with that userId. Additionally, this can enable editing of pastes from the CLI.

Sending big file on docker deployment fails

Hey there,

I have an issue where sending a rather big file via CLI fails with error: Expecting value: line 1 column 1 (char 0).

The issue does not happen when sending the file to bin.sohamsen.me.

yabin -b https://bin.sohamsen.me create report_file.txt
report_file.txt
https://bin.sohamsen.me/ti44j

Tried both with and without reverse proxy.

Smaller files with a few lines work as expected.

Is there a way to enable some debugging in docker logs or are there some settings that could be adjusted?

Cheers

Does the plan support editing and custom paths?

Considering adding editing feature? For example, paste belongs to me, and I have its password, so I can change its content at any time, so that it can be used as a content link.

It would be great if you can add a custom path feature (with the editing function).

Of course, this is just my request for personal idealization.

YABin is so well now that I've hosted it myself.

Option to disable anonymous pastes

Thanks for this project - I've tried a few pastebins and this seems the most usable and with most of the features I need.

I've deployed a public instance but I'd like to restrict creating pastes to logged-in users that only I as admin can create accounts for. As a related point, the PUBLIC_REGISRATION_ENABLED option (note the typo!), when disabled, removes both the login button and the register button. I'd like to remove the register button but keep the login facility, which would be needed for pasting - actually the login page is still accessible but the lack of link means the URL must be entered manually.

Login page accessible even after login

Current behaviour:

  • The user can go back to the /login route by the back button or by entering the url.

Expected behaviour:

  • The user should be redirected to the main page when attempting to go to the login page.

Update documentation

The documentation does not mention all the steps necessary to run the project localy. As we also need to add the migrations to the database and then run them so changing it might be helpful for faster setup of new contributers.

Burn after read & encryption problem

I have issue with"burn after read" as when it's checked, the file opens immediately upon saving on the current page, making it impossible for anyone other than the author to read it because the link expires right after creation. The second issue is that if "encrypted" is checked and the password isn't entered, a lot of random characters appear in the link. In my opinion, there should be an option for default disabling of this for EVERYONE rather than in the settings for just one user, for example, the option to disable it would be in the .env or Docker config.

Some Questions

  1. Is it possible to set an expire date / X days (hours etc.) from creation
  2. Login options to manage links / paste
  3. Will everything be wiped when you restart for example the docker container

Maybe you can explain these things a bit more in the Readme :-D

Thanks for the good work!

Forget password page

Implement a page to reset the password (via email).

Do not show this page if MAIL_ENABLED is set to false.

Bonus points: If MAIL_ENABLED is set to false, create a new environment variable such as RECOVERY_KEY which will instead be used to reset the password.

Werid behavior of API

  1. cannot create a new paste using the same initVector
    If you run the command below, you will encounter an error like {"message":"Internal Error"}. But if you change the initVector variable, a new paste can be created without problems.
curl -H "Content-Type: application/json" -X POST -d '{"content": "Ciallo~(∠・ω< )⌒★", "config": {"language": "plaintext", "encrypted": true, "expiresAfter": 3600, "burnAfterRead": false}, "passwordProtected": false, "initVector": "27DIWK00yDiGx003"}' https://bin.sohamsen.me/api/paste
  1. meaning of encrypted and passwordProtected
    It seems like on the API side, encrypted and passwordProtected have no effect on enhancing data security, cause it always return full information of a paste.
curl "https://bin.sohamsen.me/api/paste?key=121o2
# {"success":true,"data":{"key":"121o2","content":"Ciallo~(∠・ω< )⌒★","encrypted":true,"passwordProtected":true,"initVector":"27DIWK00yDiGx004","language":"plaintext"}}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.