forked from jmug/stoatchat
Add support for rAuth invite-only mode.
This commit is contained in:
4
Cargo.lock
generated
4
Cargo.lock
generated
@@ -2309,7 +2309,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "rauth"
|
name = "rauth"
|
||||||
version = "0.2.2"
|
version = "0.2.2"
|
||||||
source = "git+https://gitlab.insrt.uk/insert/rauth?rev=1e5f671144772a28f3faac55dd98647235736923#1e5f671144772a28f3faac55dd98647235736923"
|
source = "git+https://gitlab.insrt.uk/insert/rauth?rev=73fd602f0aba3d3689307fb1f811f211422fb4d3#73fd602f0aba3d3689307fb1f811f211422fb4d3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"handlebars",
|
"handlebars",
|
||||||
@@ -2453,7 +2453,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "revolt"
|
name = "revolt"
|
||||||
version = "0.3.3-alpha.2"
|
version = "0.3.3-alpha.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-std",
|
"async-std",
|
||||||
"async-tungstenite",
|
"async-tungstenite",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt"
|
name = "revolt"
|
||||||
version = "0.3.3-alpha.2"
|
version = "0.3.3-alpha.1"
|
||||||
authors = ["Paul Makles <paulmakles@gmail.com>"]
|
authors = ["Paul Makles <paulmakles@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
@@ -13,7 +13,7 @@ many-to-many = "0.1.2"
|
|||||||
ctrlc = { version = "3.0", features = ["termination"] }
|
ctrlc = { version = "3.0", features = ["termination"] }
|
||||||
async-std = { version = "1.8.0", features = ["tokio02", "attributes"] }
|
async-std = { version = "1.8.0", features = ["tokio02", "attributes"] }
|
||||||
async-tungstenite = { version = "0.10.0", features = ["async-std-runtime"] }
|
async-tungstenite = { version = "0.10.0", features = ["async-std-runtime"] }
|
||||||
rauth = { git = "https://gitlab.insrt.uk/insert/rauth", rev = "1e5f671144772a28f3faac55dd98647235736923" }
|
rauth = { git = "https://gitlab.insrt.uk/insert/rauth", rev = "73fd602f0aba3d3689307fb1f811f211422fb4d3" }
|
||||||
|
|
||||||
hive_pubsub = { version = "0.4.3", features = ["mongo"] }
|
hive_pubsub = { version = "0.4.3", features = ["mongo"] }
|
||||||
rocket_cors = { git = "https://github.com/insertish/rocket_cors", branch = "master" }
|
rocket_cors = { git = "https://github.com/insertish/rocket_cors", branch = "master" }
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ WORKDIR /home/rust/src
|
|||||||
RUN USER=root cargo new --bin revolt
|
RUN USER=root cargo new --bin revolt
|
||||||
WORKDIR /home/rust/src/revolt
|
WORKDIR /home/rust/src/revolt
|
||||||
COPY Cargo.toml Cargo.lock ./
|
COPY Cargo.toml Cargo.lock ./
|
||||||
|
COPY assets/templates ./assets/templates
|
||||||
COPY src ./src
|
COPY src ./src
|
||||||
RUN cargo build --release
|
RUN cargo build --release
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ use rauth::options::{EmailVerification, Options, SMTP};
|
|||||||
use rocket_cors::AllowedOrigins;
|
use rocket_cors::AllowedOrigins;
|
||||||
use rocket_prometheus::PrometheusMetrics;
|
use rocket_prometheus::PrometheusMetrics;
|
||||||
use util::variables::{
|
use util::variables::{
|
||||||
PUBLIC_URL, SMTP_FROM, SMTP_HOST, SMTP_PASSWORD, SMTP_USERNAME, USE_EMAIL, USE_PROMETHEUS, APP_URL
|
PUBLIC_URL, SMTP_FROM, SMTP_HOST, SMTP_PASSWORD, SMTP_USERNAME, USE_EMAIL, USE_PROMETHEUS, APP_URL, INVITE_ONLY
|
||||||
};
|
};
|
||||||
|
|
||||||
#[async_std::main]
|
#[async_std::main]
|
||||||
@@ -63,7 +63,12 @@ async fn launch_web() {
|
|||||||
|
|
||||||
let auth = Auth::new(
|
let auth = Auth::new(
|
||||||
database::get_collection("accounts"),
|
database::get_collection("accounts"),
|
||||||
Options::new()
|
if *INVITE_ONLY {
|
||||||
|
Options::new()
|
||||||
|
.invite_only_collection(database::get_collection("invites"))
|
||||||
|
} else {
|
||||||
|
Options::new()
|
||||||
|
}
|
||||||
.base_url(format!("{}/auth", *PUBLIC_URL))
|
.base_url(format!("{}/auth", *PUBLIC_URL))
|
||||||
.email_verification(if *USE_EMAIL {
|
.email_verification(if *USE_EMAIL {
|
||||||
EmailVerification::Enabled {
|
EmailVerification::Enabled {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use crate::util::variables::{
|
use crate::util::variables::{
|
||||||
DISABLE_REGISTRATION, EXTERNAL_WS_URL, HCAPTCHA_SITEKEY, USE_EMAIL, USE_HCAPTCHA,
|
DISABLE_REGISTRATION, EXTERNAL_WS_URL, HCAPTCHA_SITEKEY, USE_EMAIL, USE_HCAPTCHA, INVITE_ONLY
|
||||||
};
|
};
|
||||||
|
|
||||||
use mongodb::bson::doc;
|
use mongodb::bson::doc;
|
||||||
@@ -8,7 +8,7 @@ use rocket_contrib::json::JsonValue;
|
|||||||
#[get("/")]
|
#[get("/")]
|
||||||
pub async fn root() -> JsonValue {
|
pub async fn root() -> JsonValue {
|
||||||
json!({
|
json!({
|
||||||
"revolt": "0.3.3-alpha.2",
|
"revolt": "0.3.3-alpha.1",
|
||||||
"features": {
|
"features": {
|
||||||
"registration": !*DISABLE_REGISTRATION,
|
"registration": !*DISABLE_REGISTRATION,
|
||||||
"captcha": {
|
"captcha": {
|
||||||
@@ -16,6 +16,7 @@ pub async fn root() -> JsonValue {
|
|||||||
"key": HCAPTCHA_SITEKEY.to_string()
|
"key": HCAPTCHA_SITEKEY.to_string()
|
||||||
},
|
},
|
||||||
"email": *USE_EMAIL,
|
"email": *USE_EMAIL,
|
||||||
|
"invite_only": *INVITE_ONLY
|
||||||
},
|
},
|
||||||
"ws": *EXTERNAL_WS_URL,
|
"ws": *EXTERNAL_WS_URL,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,17 +1,2 @@
|
|||||||
use rand::{distributions::Alphanumeric, Rng};
|
|
||||||
use std::collections::HashSet;
|
|
||||||
use std::iter::FromIterator;
|
|
||||||
|
|
||||||
pub mod result;
|
pub mod result;
|
||||||
pub mod variables;
|
pub mod variables;
|
||||||
|
|
||||||
pub fn vec_to_set<T: Clone + Eq + std::hash::Hash>(data: &[T]) -> HashSet<T> {
|
|
||||||
HashSet::from_iter(data.iter().cloned())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn gen_token(l: usize) -> String {
|
|
||||||
rand::thread_rng()
|
|
||||||
.sample_iter(&Alphanumeric)
|
|
||||||
.take(l)
|
|
||||||
.collect::<String>()
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ lazy_static! {
|
|||||||
|
|
||||||
// Application Flags
|
// Application Flags
|
||||||
pub static ref DISABLE_REGISTRATION: bool = env::var("REVOLT_DISABLE_REGISTRATION").map_or(false, |v| v == "1");
|
pub static ref DISABLE_REGISTRATION: bool = env::var("REVOLT_DISABLE_REGISTRATION").map_or(false, |v| v == "1");
|
||||||
|
pub static ref INVITE_ONLY: bool = env::var("REVOLT_INVITE_ONLY").map_or(false, |v| v == "1");
|
||||||
pub static ref USE_EMAIL: bool = env::var("REVOLT_USE_EMAIL_VERIFICATION").map_or(
|
pub static ref USE_EMAIL: bool = env::var("REVOLT_USE_EMAIL_VERIFICATION").map_or(
|
||||||
env::var("REVOLT_SMTP_HOST").is_ok()
|
env::var("REVOLT_SMTP_HOST").is_ok()
|
||||||
&& env::var("REVOLT_SMTP_USERNAME").is_ok()
|
&& env::var("REVOLT_SMTP_USERNAME").is_ok()
|
||||||
|
|||||||
Reference in New Issue
Block a user