Start sign out

This commit is contained in:
eraden 2024-01-27 22:15:03 +01:00
parent df64f13952
commit 93155b6cbf
6 changed files with 287 additions and 40 deletions

285
Cargo.lock generated
View File

@ -12,7 +12,7 @@ dependencies = [
"actix-rt",
"actix_derive",
"bitflags 2.4.2",
"bytes",
"bytes 1.5.0",
"crossbeam-channel",
"futures-core",
"futures-sink",
@ -34,7 +34,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "617a8268e3537fe1d8c9ead925fca49ef6400927ee7bc26750e90ecee14ce4b8"
dependencies = [
"bitflags 1.3.2",
"bytes",
"bytes 1.5.0",
"futures-core",
"futures-sink",
"memchr",
@ -59,7 +59,7 @@ dependencies = [
"base64 0.21.7",
"bitflags 2.4.2",
"brotli",
"bytes",
"bytes 1.5.0",
"bytestring",
"derive_more",
"encoding_rs",
@ -224,7 +224,7 @@ dependencies = [
"actix-utils",
"actix-web-codegen",
"ahash 0.8.7",
"bytes",
"bytes 1.5.0",
"bytestring",
"cfg-if",
"cookie 0.16.2",
@ -709,6 +709,12 @@ version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
[[package]]
name = "bytes"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38"
[[package]]
name = "bytes"
version = "1.5.0"
@ -721,7 +727,7 @@ version = "1.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "74d80203ea6b29df88012294f62733de21cfeab47f17b41af3a38bc30a03ee72"
dependencies = [
"bytes",
"bytes 1.5.0",
]
[[package]]
@ -774,7 +780,7 @@ version = "4.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "35ed6e9d84f0b51a7f52daf1c7d71dd136fd7a3f41a8462b8cdb8c78d920fad4"
dependencies = [
"bytes",
"bytes 1.5.0",
"futures-core",
"memchr",
"pin-project-lite",
@ -936,6 +942,7 @@ checksum = "3c0333d8849afe78a4c8102a429a446bfdd055832af071945520e835ae2d841e"
dependencies = [
"cc",
"libc",
"libnghttp2-sys",
"libz-sys",
"openssl-sys",
"pkg-config",
@ -1016,6 +1023,16 @@ dependencies = [
"tokio",
]
[[package]]
name = "debugid"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef552e6f588e446098f6ba40d89ac146c8c7b64aade83c051ee00bb5d2bc18d"
dependencies = [
"serde",
"uuid",
]
[[package]]
name = "der"
version = "0.7.8"
@ -1262,6 +1279,17 @@ dependencies = [
"miniz_oxide",
]
[[package]]
name = "flume"
version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1bebadab126f8120d410b677ed95eee4ba6eb7c6dd8e34a5ec88a08050e26132"
dependencies = [
"futures-core",
"futures-sink",
"spinning_top",
]
[[package]]
name = "flume"
version = "0.11.0"
@ -1469,7 +1497,7 @@ version = "0.3.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9"
dependencies = [
"bytes",
"bytes 1.5.0",
"fnv",
"futures-core",
"futures-sink",
@ -1558,13 +1586,24 @@ dependencies = [
"windows-sys 0.52.0",
]
[[package]]
name = "hostname"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c731c3e10504cc8ed35cfe2f1db4c9274c3d35fa486e3b31df46f068ef3e867"
dependencies = [
"libc",
"match_cfg",
"winapi",
]
[[package]]
name = "http"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb"
dependencies = [
"bytes",
"bytes 1.5.0",
"fnv",
"itoa",
]
@ -1596,7 +1635,7 @@ checksum = "f8df9e8012e8cdc33f30da6adb796ea2feae97667f22c35155e64012aeb3b620"
dependencies = [
"async-sleep",
"http-api-client",
"isahc",
"isahc 1.7.2",
]
[[package]]
@ -1605,7 +1644,7 @@ version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2"
dependencies = [
"bytes",
"bytes 1.5.0",
"http",
"pin-project-lite",
]
@ -1628,7 +1667,7 @@ version = "0.14.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80"
dependencies = [
"bytes",
"bytes 1.5.0",
"futures-channel",
"futures-core",
"futures-util",
@ -1666,7 +1705,7 @@ version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905"
dependencies = [
"bytes",
"bytes 1.5.0",
"hyper",
"native-tls",
"tokio",
@ -1770,6 +1809,31 @@ version = "2.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3"
[[package]]
name = "isahc"
version = "0.9.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2948a0ce43e2c2ef11d7edf6816508998d99e13badd1150be0914205df9388a"
dependencies = [
"bytes 0.5.6",
"crossbeam-utils",
"curl",
"curl-sys",
"encoding_rs",
"flume 0.9.2",
"futures-lite",
"http",
"log",
"mime",
"once_cell",
"slab",
"sluice",
"tracing",
"tracing-futures",
"url",
"waker-fn",
]
[[package]]
name = "isahc"
version = "1.7.2"
@ -1850,6 +1914,7 @@ dependencies = [
"rumqttc",
"rust-s3",
"sea-orm",
"sentry",
"serde",
"serde-aux",
"serde-email",
@ -1980,6 +2045,16 @@ version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058"
[[package]]
name = "libnghttp2-sys"
version = "0.1.8+1.55.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fae956c192dadcdb5dace96db71fa0b827333cce7c7b38dc71446f024d8a340"
dependencies = [
"cc",
"libc",
]
[[package]]
name = "libredox"
version = "0.0.1"
@ -2068,6 +2143,12 @@ dependencies = [
"linked-hash-map",
]
[[package]]
name = "match_cfg"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4"
[[package]]
name = "matchers"
version = "0.1.0"
@ -2476,6 +2557,17 @@ dependencies = [
"hashbrown 0.12.3",
]
[[package]]
name = "os_info"
version = "3.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "006e42d5b888366f1880eda20371fedde764ed2213dc8496f49622fa0c99cd5e"
dependencies = [
"log",
"serde",
"winapi",
]
[[package]]
name = "ouroboros"
version = "0.17.2"
@ -2872,7 +2964,7 @@ checksum = "c580d9cbbe1d1b479e8d67cf9daf6a62c957e6846048408b80b43ac3f6af84cd"
dependencies = [
"arc-swap",
"async-trait",
"bytes",
"bytes 1.5.0",
"combine",
"futures",
"futures-rustls",
@ -2900,7 +2992,7 @@ version = "0.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ade7331dca1833e4fba8e4ccc6f85bd9b0d1a3536025bfd9ad867cf825a075d"
dependencies = [
"bytes",
"bytes 1.5.0",
"futures-channel",
"futures-sink",
"futures-util",
@ -3003,7 +3095,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37b1ae8d9ac08420c66222fb9096fc5de435c3c48542bc5336c51892cffafb41"
dependencies = [
"base64 0.21.7",
"bytes",
"bytes 1.5.0",
"encoding_rs",
"futures-core",
"futures-util",
@ -3080,7 +3172,7 @@ checksum = "527a97cdfef66f65998b5f3b637c26f5a5ec09cc52a3f9932313ac645f4190f5"
dependencies = [
"bitvec",
"bytecheck",
"bytes",
"bytes 1.5.0",
"hashbrown 0.12.3",
"ptr_meta",
"rend",
@ -3127,8 +3219,8 @@ version = "0.23.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d8941c6791801b667d52bfe9ff4fc7c968d4f3f9ae8ae7abdaaa1c966feafc8"
dependencies = [
"bytes",
"flume",
"bytes 1.5.0",
"flume 0.11.0",
"futures-util",
"log",
"rustls-native-certs",
@ -3159,7 +3251,7 @@ dependencies = [
"aws-creds",
"aws-region",
"base64 0.13.1",
"bytes",
"bytes 1.5.0",
"cfg-if",
"futures",
"futures-io",
@ -3192,7 +3284,7 @@ checksum = "06676aec5ccb8fc1da723cc8c0f9a46549f21ebb8753d3915c6c41db1e7f1dc4"
dependencies = [
"arrayvec",
"borsh",
"bytes",
"bytes 1.5.0",
"num-traits",
"rand",
"rkyv",
@ -3295,7 +3387,7 @@ version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a98f186c7a2f3abbffb802984b7f1dfd65dac8be1aafdaabbca4137f53f0dff7"
dependencies = [
"bytes",
"bytes 1.5.0",
"rxml_validation",
"smartstring",
]
@ -3478,6 +3570,114 @@ dependencies = [
"serde",
]
[[package]]
name = "sentry"
version = "0.32.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab18211f62fb890f27c9bb04861f76e4be35e4c2fcbfc2d98afa37aadebb16f1"
dependencies = [
"isahc 0.9.14",
"reqwest",
"rustls 0.21.10",
"sentry-backtrace",
"sentry-contexts",
"sentry-core",
"sentry-log",
"sentry-panic",
"sentry-tracing",
"tokio",
"ureq",
"webpki-roots 0.25.3",
]
[[package]]
name = "sentry-backtrace"
version = "0.32.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf018ff7d5ce5b23165a9cbfee60b270a55ae219bc9eebef2a3b6039356dd7e5"
dependencies = [
"backtrace",
"once_cell",
"regex",
"sentry-core",
]
[[package]]
name = "sentry-contexts"
version = "0.32.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d934df6f9a17b8c15b829860d9d6d39e78126b5b970b365ccbd817bc0fe82c9"
dependencies = [
"hostname",
"libc",
"os_info",
"rustc_version",
"sentry-core",
"uname",
]
[[package]]
name = "sentry-core"
version = "0.32.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e362d3fb1c5de5124bf1681086eaca7adf6a8c4283a7e1545359c729f9128ff"
dependencies = [
"once_cell",
"rand",
"sentry-types",
"serde",
"serde_json",
]
[[package]]
name = "sentry-log"
version = "0.32.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f7574422f662fe062a2ef7d027659ad8745e05fb815770887aeb08e2fb92cf6"
dependencies = [
"log",
"sentry-core",
]
[[package]]
name = "sentry-panic"
version = "0.32.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0224e7a8e2bd8a32d96804acb8243d6d6e073fed55618afbdabae8249a964d8"
dependencies = [
"sentry-backtrace",
"sentry-core",
]
[[package]]
name = "sentry-tracing"
version = "0.32.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "087bed8c616d176a9c6b662a8155e5f23b40dc9e1fa96d0bd5fb56e8636a9275"
dependencies = [
"sentry-backtrace",
"sentry-core",
"tracing-core",
"tracing-subscriber",
]
[[package]]
name = "sentry-types"
version = "0.32.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb4f0e37945b7a8ce7faebc310af92442e2d7c5aa7ef5b42fe6daa98ee133f65"
dependencies = [
"debugid",
"hex",
"rand",
"serde",
"serde_json",
"thiserror",
"time",
"url",
"uuid",
]
[[package]]
name = "serde"
version = "1.0.195"
@ -3749,6 +3949,15 @@ dependencies = [
"lock_api",
]
[[package]]
name = "spinning_top"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b9eb1a2f4c41445a3a0ff9abc5221c5fcd28e1f13cd7c0397706f9ac938ddb0"
dependencies = [
"lock_api",
]
[[package]]
name = "spki"
version = "0.7.3"
@ -3793,7 +4002,7 @@ dependencies = [
"atoi",
"bigdecimal",
"byteorder",
"bytes",
"bytes 1.5.0",
"chrono",
"crc",
"crossbeam-queue",
@ -3879,7 +4088,7 @@ dependencies = [
"bigdecimal",
"bitflags 2.4.2",
"byteorder",
"bytes",
"bytes 1.5.0",
"chrono",
"crc",
"digest",
@ -3968,7 +4177,7 @@ checksum = "210976b7d948c7ba9fced8ca835b11cbb2d677c59c79de41ac0d397e14547490"
dependencies = [
"atoi",
"chrono",
"flume",
"flume 0.11.0",
"futures-channel",
"futures-core",
"futures-executor",
@ -4202,7 +4411,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104"
dependencies = [
"backtrace",
"bytes",
"bytes 1.5.0",
"libc",
"mio",
"num_cpus",
@ -4310,7 +4519,7 @@ version = "0.7.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15"
dependencies = [
"bytes",
"bytes 1.5.0",
"futures-core",
"futures-sink",
"pin-project-lite",
@ -4456,6 +4665,15 @@ version = "1.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
[[package]]
name = "uname"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b72f89f0ca32e4db1c04e2a72f5345d59796d4866a1ee0609084569f73683dc8"
dependencies = [
"libc",
]
[[package]]
name = "uncased"
version = "0.9.10"
@ -4519,6 +4737,21 @@ version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
[[package]]
name = "ureq"
version = "2.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8cdd25c339e200129fe4de81451814e5228c9b771d57378817d6117cc2b3f97"
dependencies = [
"base64 0.21.7",
"log",
"once_cell",
"rustls 0.21.10",
"rustls-webpki",
"url",
"webpki-roots 0.25.3",
]
[[package]]
name = "url"
version = "2.5.0"

View File

@ -42,3 +42,4 @@ http-api-isahc-client = { version = "0.2.2", features = ["with-sleep-via-tokio"]
dotenv = "0.15.0"
chrono = { version = "0.4.32", default-features = false, features = ["clock", "serde"] }
validators = { version = "0.25.3", default-features = false, features = ["email", "derive", "all-validators"] }
sentry = { version = "0.32.1", default-features = false, features = ["tokio", "rustls", "tracing", "isahc", "sentry-backtrace", "sentry-log", "sentry-contexts", "backtrace", "panic"] }

View File

@ -11,12 +11,16 @@
* `GOOGLE_CLIENT_ID` -
* `GITHUB_CLIENT_ID` -
* `GITHUB_APP_NAME` -
* `MAGIC_LOGIN` -
* `MAGIC_LOGIN` - allow to log-in withuot password, using link send to email address
* `EMAIL_PASSWORD_LOGIN` -
* `SLACK_CLIENT_ID` -
* `POSTHOG_API_KEY` -
* `POSTHOG_HOST` -
* `HAS_UNSPLASH_CONFIGURED` -
* `HAS_OPENAI_CONFIGURED` -
* `FILE_SIZE_LIMIT` -
* `IS_SELF_MANAGED` -
* `HAS_OPENAI_CONFIGURED` - added for compatibility but not supported
* `FILE_SIZE_LIMIT` - maximum file size
* `IS_SELF_MANAGED` - always `true` but added for compatibility with `plane`
### Optional Environment
* `SENTRY_DSN` - sentry endpoint for events

View File

@ -15,6 +15,7 @@ use uuid::Uuid;
mod email_check;
mod sign_in;
mod sign_out;
mod sign_up;
mod social_auth;
@ -79,11 +80,6 @@ pub enum AuthError {
EncryptPass,
}
#[get("/social-auth")]
async fn oauth(_db: Data<DatabaseConnection>) -> HttpResponse {
HttpResponse::NotImplemented().finish()
}
async fn create_user(
req: &HttpRequest,
email: &str,
@ -136,11 +132,6 @@ async fn has_workspace_invites(email: &str, db: &mut DatabaseTransaction) -> Res
.map(|n| n > 0)
}
#[delete("/sign-out")]
async fn sign_out(_db: Data<DatabaseConnection>) -> HttpResponse {
HttpResponse::NotImplemented().finish()
}
async fn auth_http_response(
user: User,
session: Data<SessionStorage>,

View File

@ -0,0 +1,14 @@
use actix_jwt_session::{Authenticated, SessionStorage};
use actix_web::{post, web::Data, HttpResponse};
use sea_orm::DatabaseConnection;
use crate::session::AppClaims;
#[post("/sign-out")]
pub async fn sign_out(
_db: Data<DatabaseConnection>,
claims: Authenticated<AppClaims>,
session: Data<SessionStorage>,
) -> HttpResponse {
HttpResponse::NotImplemented().finish()
}

View File

@ -22,6 +22,10 @@ async fn main() {
dotenv::from_filename(".env.development").ok();
tracing_subscriber::fmt::init();
if let Ok(entry_dsn) = env::var("SENTRY_DSN") {
let _guard = sentry::init(sentry_dsn);
}
let addr = env::var("JET_API_ADDR").unwrap_or_else(|_| "0.0.0.0:7865".to_owned());
let redis_addr = format!(
"redis://{addr}:{port}",