#bellhop #dummy #requires #assets #cookies

nightly bellhop-auth-dummy

Authentication plugin for bellhop that only requires an email

2 releases

0.2.1 Mar 28, 2019
0.2.0 Jan 8, 2019

#3 in #bellhop


Used in bellhop-demo

Apache-2.0

105KB
2.5K SLoC

Rust 2K SLoC // 0.0% comments SQL 346 SLoC // 0.1% comments Handlebars 282 SLoC // 0.0% comments JavaScript 72 SLoC

Bellhop

Bellhop is a web application for reserving different assets, like machines or IP addresses


Introduction

Purpose

Are you part of a team of ten that shares three testing environments? Do you keep a spreadsheet of who's using what IP addresses? Need a way to keep track of who's borrowing which virtual machine?

If you answered yes to any of those questions, Bellhop might be able to help. Bellhop is a super simple asset reservation tool that keeps track of who's using what, until when.

For more information, including a live demo, checkout bellhop.rs.

Project Structure

  • bellhop/ - The core library that implements most of Bellhop's features.
  • bellhop-demo/ - A runnable example that demos adding hooks and starting the server.
  • bellhop-hook-email/ - A hook that sends an email when your lease is expiring.
  • bellhop-hook-jenkins/ - A hook that starts a Jenkins job for each event.
  • bellhop-auth-dummy/ - Authentication plugin that only requires an email address.
  • bellhop-auth-header/ - Authentication plugin that creates users based on a header.

Design

Bellhop is designed to be heavily customized and installed internally. Additional functionality can be added by writing hooks (like bellhop-hook-jenkins.) Authentication is customizable as well, with pluggable modules like bellhop-auth-header.

Usage

At this point, Bellhop is more like a set of crates you assemble yourself into a web application than a web application itself.

A good starting point is getting bellhop-demo running, then using that as an example to build your own deployment.

First Time Setup

The following instructions are roughly tailored for Ubuntu, but should be relatively similar regardless of the platform. Bellhop is regularly compiled for Ubuntu and OS X, and should compile on Windows as well.

Installing Rust

The project requires the latest Rust nightly. You can install that with rustup:

$ curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain nightly

Installing PostgreSQL

Bellhop uses PostgreSQL as its database. Any version greater than or equal to 9.5 should work.

Ubuntu/Debian

# Install the server and client libraries.
$ sudo apt install postgresql-9.5 postgresql-client libpq-dev

# Create a user, identified with a password.
$ sudo -u postgres createuser -P bellhop

# Create a new database owned by the same user.
$ sudo -u postgres createdb -O bellhop bellhop

OS X (Homebrew)

Install Homebrew at https://brew.sh/

# Install the server and client libraries.
brew install postgres
brew services start postgresql

# Create a user, identified with a password.
createuser -P bellhop

# Create a new database owned by the same user.
createdb -O bellhop bellhop

Installing Diesel

To perform database migrations, you'll need to install diesel_cli:

$ cargo install diesel_cli --no-default-features --features postgres

Obtain Bellhop

The easiest way to grab all the components is to clone the Bellhop repository:

$ git clone https://github.com/bellhop-rs/bellhop

Perform Migrations

The core application, as well as some hooks, will have database migrations that need to be applied for the application to function.

# Make sure to update this line with the password supplied earlier.
$ export DATABASE_URL=postgres://bellhop:<password>@localhost/bellhop

# Apply the core application's migrations. Note: `bellhop` refers to this repo's `bellhop` subdirectory.
$ cd bellhop
$ diesel migration run

# Apply any hook's migrations.
$ cd ../bellhop-hook-jenkins
$ diesel migration run

Run Bellhop, Finally

To run Bellhop in "demo" mode:

$ cargo run --bin bellhop-demo

Note that bellhop-demo doesn't require any kind of passwords to log in. It really isn't suitable for production use without some customization.

Development

Generating bellhop-client

bellhop-client is generated with openapi-generator.

To regenerate the API client library:

$ openapi-generator generate \
   -i bellhop/openapi/bellhop.yaml \
   -g rust \
   -o bellhop-client \
   --skip-validate-spec \
   --library reqwest \
   --additional-properties packageName=bellhop-client

License

Bellhop is licensed under:

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Bellhop by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.


lib.rs:

An implementation of bellhop::auth::Auth that authenticates a user based on their email address (and only their email address.)

Uses HTTP cookies to store the logged in user.

Routes

Provides a couple routes:

  • /auth/dummy/login: Handles logging in.
  • /auth/dummy/logout: Deletes the stored cookie.

Catchers

Provides one error catcher:

  • 401 Unauthorized: Redirects to /auth/dummy/login.

Example

use bellhop::Bellhop;
use bellhop_auth_dummy::Dummy;

fn main() {
    Bellhop::default()
        .auth(Dummy)
        .start()
}

Dependencies

~18–29MB
~463K SLoC