mirror of
https://github.com/Nutomic/ibis.git
synced 2024-11-22 08:41:08 +00:00
use trunk build not watch for federation.sh, ignore invalid auth
This commit is contained in:
parent
dd513a106d
commit
3adcd98b3f
3 changed files with 8 additions and 13 deletions
|
@ -24,12 +24,11 @@ echo $ALPHA_DB_URL
|
||||||
# get rid of processes leftover from previous runs
|
# get rid of processes leftover from previous runs
|
||||||
killall ibis || true
|
killall ibis || true
|
||||||
|
|
||||||
|
CARGO_TARGET_DIR=target/frontend trunk build
|
||||||
|
|
||||||
# launch a couple of local instances to test federation
|
# launch a couple of local instances to test federation
|
||||||
# sometimes ctrl+c doesnt work properly, so you have to kill trunk, cargo-watch and ibis manually
|
# sometimes ctrl+c doesnt work properly, so you have to kill trunk, cargo-watch and ibis manually
|
||||||
# TODO: somehow instances use wrong port resulting in cors errors
|
|
||||||
(trap 'kill 0' SIGINT;
|
(trap 'kill 0' SIGINT;
|
||||||
sh -c "CARGO_TARGET_DIR=target/frontend trunk serve -w src/frontend/ --proxy-backend http://127.0.0.1:8071 --port 8070" &
|
sh -c "IBIS__BIND=127.0.0.1:8070 IBIS__FEDERATION__DOMAIN=ibis-alpha:8070 IBIS__DATABASE_URL=$ALPHA_DB_URL cargo run" &
|
||||||
sh -c "IBIS__BIND=127.0.0.1:8071 IBIS__FEDERATION__DOMAIN=ibis-alpha:8070 IBIS__DATABASE_URL=$ALPHA_DB_URL cargo run" &
|
sh -c "IBIS__BIND=127.0.0.1:8080 IBIS__FEDERATION__DOMAIN=ibis-beta:8080 IBIS__DATABASE_URL=$BETA_DB_URL cargo run" &
|
||||||
sh -c "CARGO_TARGET_DIR=target/frontend trunk serve -w src/frontend/ --proxy-backend http://127.0.0.1:8081 --port 8080" &
|
|
||||||
sh -c "IBIS__BIND=127.0.0.1:8081 IBIS__FEDERATION__DOMAIN=ibis-beta:8080 IBIS__DATABASE_URL=$BETA_DB_URL cargo run" &
|
|
||||||
)
|
)
|
|
@ -26,7 +26,6 @@ use axum::{Json, Router};
|
||||||
use axum_extra::extract::CookieJar;
|
use axum_extra::extract::CookieJar;
|
||||||
use axum_macros::debug_handler;
|
use axum_macros::debug_handler;
|
||||||
use futures::future::try_join_all;
|
use futures::future::try_join_all;
|
||||||
use log::warn;
|
|
||||||
|
|
||||||
pub mod article;
|
pub mod article;
|
||||||
pub mod instance;
|
pub mod instance;
|
||||||
|
@ -60,11 +59,9 @@ async fn auth<B>(
|
||||||
next: Next<B>,
|
next: Next<B>,
|
||||||
) -> Result<Response, StatusCode> {
|
) -> Result<Response, StatusCode> {
|
||||||
if let Some(auth) = jar.get(AUTH_COOKIE) {
|
if let Some(auth) = jar.get(AUTH_COOKIE) {
|
||||||
let user = validate(auth.value(), &data).await.map_err(|e| {
|
if let Ok(user) = validate(auth.value(), &data).await {
|
||||||
warn!("Failed to validate auth token: {e}");
|
request.extensions_mut().insert(user);
|
||||||
StatusCode::UNAUTHORIZED
|
}
|
||||||
})?;
|
|
||||||
request.extensions_mut().insert(user);
|
|
||||||
}
|
}
|
||||||
let response = next.run(request).await;
|
let response = next.run(request).await;
|
||||||
Ok(response)
|
Ok(response)
|
||||||
|
|
|
@ -94,8 +94,7 @@ fn create_cookie(jwt: String, data: &Data<IbisData>) -> Cookie<'static> {
|
||||||
.same_site(SameSite::Strict)
|
.same_site(SameSite::Strict)
|
||||||
.path("/")
|
.path("/")
|
||||||
.http_only(true)
|
.http_only(true)
|
||||||
// TODO: not in debug mode
|
.secure(!cfg!(debug_assertions))
|
||||||
//.secure(true)
|
|
||||||
.expires(Expiration::DateTime(
|
.expires(Expiration::DateTime(
|
||||||
OffsetDateTime::now_utc() + Duration::weeks(52),
|
OffsetDateTime::now_utc() + Duration::weeks(52),
|
||||||
))
|
))
|
||||||
|
|
Loading…
Reference in a new issue