Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
add ingore_auth feature on backend
appflowyef4ee320f7d5
diff --git a/backend/Cargo.toml b/backend/Cargo.tomlindex ed178e5ef3..3ac7fced1e 100644--- a/backend/Cargo.toml+++ b/backend/Cargo.toml@@ -92,6 +92,7 @@ path = "src/main.rs"[features]flowy_test = []+ignore_auth = [][dev-dependencies]parking_lot = "0.11"diff --git a/backend/src/middleware/auth_middleware.rs b/backend/src/middleware/auth_middleware.rsindex fa826c416d..c51731d354 100644--- a/backend/src/middleware/auth_middleware.rs+++ b/backend/src/middleware/auth_middleware.rs@@ -49,9 +49,7 @@ wheretype Error = Error;type Future = LocalBoxFuture<'static, Result<Self::Response, Self::Error>>;- fn poll_ready(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {- self.service.poll_ready(cx)- }+ fn poll_ready(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> { self.service.poll_ready(cx) }fn call(&self, req: ServiceRequest) -> Self::Future {let mut authenticate_pass: bool = false;@@ -68,9 +66,15 @@ wherelet result: Result<LoggedUser, ServerError> = header.try_into();match result {Ok(logged_user) => {- authenticate_pass = AUTHORIZED_USERS.is_authorized(&logged_user);- // Update user timestamp- AUTHORIZED_USERS.store_auth(logged_user, true);+ if cfg!(feature = "ignore_auth") {+ authenticate_pass = true;+ AUTHORIZED_USERS.store_auth(logged_user, true);+ } else {+ authenticate_pass = AUTHORIZED_USERS.is_authorized(&logged_user);+ if authenticate_pass {+ AUTHORIZED_USERS.store_auth(logged_user, true);+ }+ }},Err(e) => log::error!("{:?}", e),}diff --git a/backend/src/service/user/logged_user.rs b/backend/src/service/user/logged_user.rsindex 443574ad70..7414e0243a 100644--- a/backend/src/service/user/logged_user.rs+++ b/backend/src/service/user/logged_user.rs@@ -15,11 +15,7 @@ pub struct LoggedUser {}impl std::convert::From<Claim> for LoggedUser {- fn from(c: Claim) -> Self {- Self {- user_id: c.user_id(),- }- }+ fn from(c: Claim) -> Self { Self { user_id: c.user_id() } }}impl LoggedUser {@@ -93,7 +89,6 @@ impl AuthorizedUsers {AuthStatus::Authorized(last_time) => {let current_time = Utc::now();let days = (current_time - last_time).num_days();- log::debug!("user active {} from now", days);days < EXPIRED_DURATION_DAYS},AuthStatus::NotAuthorized => {diff --git a/rust-lib/flowy-document/src/services/doc/revision/manager.rs b/rust-lib/flowy-document/src/services/doc/revision/manager.rsindex ed5a1b3bf8..3c241339a1 100644--- a/rust-lib/flowy-document/src/services/doc/revision/manager.rs+++ b/rust-lib/flowy-document/src/services/doc/revision/manager.rs@@ -32,7 +32,6 @@ impl RevisionManager {}}- #[tracing::instrument(level = "debug", skip(self))]pub async fn add_revision(&self, revision: &Revision) -> Result<(), DocError> {let (ret, rx) = oneshot::channel();let cmd = RevisionCmd::Revision {diff --git a/rust-lib/flowy-document/src/services/doc/revision/store_actor.rs b/rust-lib/flowy-document/src/services/doc/revision/store_actor.rsindex 567d0b6d41..63515b798b 100644--- a/rust-lib/flowy-document/src/services/doc/revision/store_actor.rs+++ b/rust-lib/flowy-document/src/services/doc/revision/store_actor.rs@@ -95,6 +95,7 @@ impl RevisionStoreActor {}}+ #[tracing::instrument(level = "debug", skip(self, revision))]async fn handle_new_revision(&self, revision: Revision) -> DocResult<()> {if self.revs.contains_key(&revision.rev_id) {return Err(DocError::duplicate_rev().context(format!("Duplicate revision id: {}", revision.rev_id)));@@ -107,6 +108,7 @@ impl RevisionStoreActor {Ok(())}+ #[tracing::instrument(level = "debug", skip(self, rev_id))]async fn handle_revision_acked(&self, rev_id: RevId) {match self.revs.get_mut(rev_id.as_ref()) {None => {},@@ -138,7 +140,6 @@ impl RevisionStoreActor {// TODO: Ok to unwrap?let conn = &*persistence.pool.get().map_err(internal_error).unwrap();-let result = conn.immediate_transaction::<_, DocError, _>(|| {let _ = persistence.rev_sql.create_rev_table(revisions, conn).unwrap();Ok(())diff --git a/rust-lib/flowy-user/src/services/user/user_session.rs b/rust-lib/flowy-user/src/services/user/user_session.rsindex 9623442d84..c20e3bde53 100644--- a/rust-lib/flowy-user/src/services/user/user_session.rs+++ b/rust-lib/flowy-user/src/services/user/user_session.rs@@ -292,7 +292,6 @@ impl UserSession {let mut notify = self.ws_controller.state_subscribe();let ws_controller = self.ws_controller.clone();let _ = tokio::spawn(async move {- log::debug!("listen ws state");loop {match notify.recv().await {Ok(state) => {diff --git a/rust-lib/flowy-ws/src/ws.rs b/rust-lib/flowy-ws/src/ws.rsindex b12073f768..b16e8e40c1 100644--- a/rust-lib/flowy-ws/src/ws.rs+++ b/rust-lib/flowy-ws/src/ws.rs@@ -88,7 +88,7 @@ impl WsController {pub async fn start_connect(&self, addr: String) -> Result<(), ServerError> {*self.addr.write() = Some(addr.clone());- let strategy = ExponentialBackoff::from_millis(100).take(5);+ let strategy = FixedInterval::from_millis(5000).take(3);self.connect(addr, strategy).await}@@ -326,7 +326,7 @@ impl Future for WsConnectActionFut {sender,}))},- Err(e) => Poll::Ready(Err(WsError::internal().context(e))),+ Err(e) => Poll::Ready(Err(e)),}}}