diff --git a/Cargo.toml b/Cargo.toml index 6d00ee3..85a4ffa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,11 +15,18 @@ path = "src/rbs/main.rs" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +# Backend web framework rocket = "0.5.0-rc.1" +# ORM diesel = { version = "1.4.7", features = ["postgres"] } diesel_migrations = "1.4.0" +# To properly compile libpq statically openssl = "0.10.36" +# For password hashing & verification +rust-argon2 = "0.8.3" +rand = "0.8.4" +# Used to provide Rocket routes with database connections [dependencies.rocket_sync_db_pools] version = "0.1.0-rc.1" default_features = false diff --git a/migrations/2021-08-20-110251_users-and-auth/down.sql b/migrations/2021-08-20-110251_users-and-auth/down.sql new file mode 100644 index 0000000..291a97c --- /dev/null +++ b/migrations/2021-08-20-110251_users-and-auth/down.sql @@ -0,0 +1 @@ +-- This file should undo anything in `up.sql` \ No newline at end of file diff --git a/migrations/2021-08-20-110251_users-and-auth/up.sql b/migrations/2021-08-20-110251_users-and-auth/up.sql new file mode 100644 index 0000000..8852c19 --- /dev/null +++ b/migrations/2021-08-20-110251_users-and-auth/up.sql @@ -0,0 +1,17 @@ +-- Users +CREATE TABLE users ( + id uuid DEFAULT gen_random_uuid() PRIMARY KEY, + + username varchar(32) UNIQUE NOT NULL, + password text NOT NULL +); + +-- Permissions that a user can have +CREATE TABLE permissions ( + id uuid DEFAULT gen_random_uuid() PRIMARY KEY, + + user_id uuid REFERENCES users (id) NOT NULL, + name varchar NOT NULL, + + UNIQUE (user_id, name) +); diff --git a/src/rbs/main.rs b/src/rbs/main.rs index 9b67662..e0186ce 100644 --- a/src/rbs/main.rs +++ b/src/rbs/main.rs @@ -2,11 +2,8 @@ // compilation succeeds extern crate openssl; -#[macro_use] -extern crate rocket; - -#[macro_use] -extern crate diesel_migrations; +#[macro_use] extern crate rocket; +#[macro_use] extern crate diesel_migrations; use rocket::{fairing::AdHoc, Build, Rocket}; use rocket_sync_db_pools::{database, diesel};