- feat(accounts): persist device links with opaque hashed tokens, list and revoke endpoints - feat(frontend): app shell, routing and landing page with the chat-command hero - feat(frontend): Cyrillic-first fonts (Unbounded, Onest, JetBrains Mono); add i18next and motion - docs: free mod, bilingual site, one-click download, theme editor, public profiles, rich landing in plans - feat(accounts): internal gRPC AuthenticateDevice guarded by internal key - feat(frontend): ru/en i18n with typed per-feature dictionaries and language switch - feat(accounts): GET /me profile endpoint - feat(gateway): scaffold crate with config validation and health check - feat(gateway): reverse proxy to accounts and configs services - feat(gateway): resolve identity once from access JWT or device token via gRPC - feat(gateway): per-route and global rate limits with Retry-After - feat(gateway): CORS for the site origin; docs for gateway and internal contract - feat(configs): scaffold service with schema, config validation and health check - feat(configs): four config slots per account with list, get and save - feat(configs): permanent share codes with regenerate and public load-by-code - feat(accounts): GetPublicProfiles gRPC for showcase author info - style(accounts,common): apply rustfmt to existing sources - feat(configs): public showcase with publish, browse, detail and copy-to-slot - feat(backend): public profile endpoint and showcase author filter - fix(gateway): silence clippy collapsible-if and needless-ref warnings - docs(backend): configs-service implemented; Подсистема 1 backend complete - feat(mod): add Optimize module skeleton with OptimizeState holder - feat(mod): gate glass blur behind Optimize no_glass knob - feat(mod): cut MotionBlur and DoF sample counts behind lite_post knob - feat(mod): trim procedural sky noise behind lite_sky knob - feat(mod): drop fade gradients and digit rolls behind lean_hud knob - docs(todo): mark Optimize module phase 9.2 complete - refactor(mod): drop dead Renderer2D compatibility shims - refactor(mod): prune unreachable Renderer2D overload towers - refactor(mod): remove unused Renderer2D overloads and imports - docs(todo): mark Renderer2D giant-splitting done (2179 to 1597) - refactor(mod): extract shader id constants from LoVisualRenderPipelines - docs(todo): record registry wave 2026-09-25 (Renderer2D, pipelines) - refactor(mod): move Renderer2D instance state into base class - refactor(mod): extract Renderer2DRounded drawing family - refactor(mod): extract Renderer2DPath connector and chamfer family - refactor(mod): extract Renderer2DShapes circle line and texture primitives - refactor(mod): extract Renderer2DGlass and Renderer2DItem families - refactor(mod): prune Renderer2D imports after facade split - docs(todo): record Renderer2D facade inheritance split (1597 to 475) - docs: easter eggs — .env honeypot, konami troll mode, devtools banner, IDDQD config, breakable 404 block, 418 teapot - feat(mod): introduce surface style system core (SurfaceStyle, StyleSpec, StyleConfig, SurfaceRenderer) - refactor(mod): delegate HudRenderUtil liquid glass draws to SurfaceRenderer (dedupe glass constants) - refactor(mod): route bespoke glass call sites through SurfaceRenderer.plateSpec - feat(mod): add Auto option to HUD bg effects via shared HudBgStyles resolution - feat(mod): flat fallback for no-glass optimize mode and persist global HUD config - feat(mod): default HUD bg effects to Auto so the global surface style drives widgets - feat(mod): add global cycle-style hotkey with surface style notification - feat(mod): add surface style swatch strip under the global style picker - feat(gateway): reject ambiguous paths and answer .env probes with a honeypot - fix(gateway): charge failed credentials against the rate limit, allow stale ones on /auth - feat(frontend): ClickGui theme pipeline generated from the mod, live site theming - feat(frontend): landing v2 hero — voxel/particle backdrop, live ClickGui, theme strip - docs(todo): drop the FPS A/B measurement from phase 9.3, close phase 9 - feat(gateway): answer /coffee with a 418 teapot - feat(frontend): land the rest of landing v2 — HUD, module wall, showcase, FAQ, footer - feat(frontend): one-click download from GitHub releases, changelog page, release CI - feat(frontend): theme editor with live ClickGui preview, mod-compatible export and share links - fix(frontend): landing HUD playground now shows real mod widgets (fps, coordinates, module list, keybinds, ping) - style(frontend): apply ClickGui glass effect to landing HUD playground widgets - fix(frontend): prevent color field row overflow in theme editor grid - fix(frontend): never attach stale bearer token to /auth/* requests - fix(configs): unpublish/publish can no longer bypass moderation - refactor(accounts): shrink auth/handlers.rs under the 250-line cap - fix(accounts): tolerate concurrent refresh without killing every session - fix(gateway): minor hardening from the backend review - feat(configs): IDDQD easter egg config
137 lines
4.9 KiB
Rust
137 lines
4.9 KiB
Rust
use super::common;
|
|
use axum::http::StatusCode;
|
|
use axum_extra::extract::cookie::Cookie;
|
|
use serde_json::json;
|
|
|
|
async fn login(server: &axum_test::TestServer, email: &str) -> (String, String) {
|
|
let res = server
|
|
.post("/auth/login")
|
|
.json(&json!({ "email": email, "password": "correct-horse-battery-staple" }))
|
|
.await;
|
|
res.assert_status_ok();
|
|
let cookie = res.cookie("lv_refresh");
|
|
assert!(cookie.http_only().unwrap_or(false));
|
|
assert_eq!(cookie.path(), Some("/auth"));
|
|
let body: serde_json::Value = res.json();
|
|
assert!(
|
|
body.get("refresh_token").is_none(),
|
|
"refresh token must not be in the JSON body"
|
|
);
|
|
(
|
|
body["access_token"].as_str().unwrap().to_owned(),
|
|
cookie.value().to_owned(),
|
|
)
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn refresh_rotates_the_cookie_and_issues_a_new_access_token() {
|
|
let pool = common::test_pool().await;
|
|
let server = common::test_server(accounts_service::build_app(pool, &common::test_config()));
|
|
let (_, email) = common::register_account(&server).await;
|
|
let (_, refresh) = login(&server, &email).await;
|
|
|
|
let res = server
|
|
.post("/auth/refresh")
|
|
.add_cookie(Cookie::new("lv_refresh", refresh.clone()))
|
|
.await;
|
|
res.assert_status_ok();
|
|
assert!(res.json::<serde_json::Value>()["access_token"].is_string());
|
|
assert_ne!(res.cookie("lv_refresh").value(), refresh);
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn reusing_a_rotated_refresh_token_revokes_all_sessions() {
|
|
let pool = common::test_pool().await;
|
|
let server = common::test_server(accounts_service::build_app(pool, &common::test_config()));
|
|
let (_, email) = common::register_account(&server).await;
|
|
let (_, first) = login(&server, &email).await;
|
|
|
|
let second = server
|
|
.post("/auth/refresh")
|
|
.add_cookie(Cookie::new("lv_refresh", first.clone()))
|
|
.await
|
|
.cookie("lv_refresh")
|
|
.value()
|
|
.to_owned();
|
|
// Wait out the rotation grace window: a replay this long after rotation
|
|
// is genuine reuse, not a benign concurrent-refresh race.
|
|
tokio::time::sleep(std::time::Duration::from_secs(11)).await;
|
|
// Attacker replays the old token -> rejected, and the legit new one dies too.
|
|
server
|
|
.post("/auth/refresh")
|
|
.add_cookie(Cookie::new("lv_refresh", first))
|
|
.await
|
|
.assert_status(StatusCode::UNAUTHORIZED);
|
|
server
|
|
.post("/auth/refresh")
|
|
.add_cookie(Cookie::new("lv_refresh", second))
|
|
.await
|
|
.assert_status(StatusCode::UNAUTHORIZED);
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn concurrent_refresh_within_the_grace_window_does_not_kill_the_session() {
|
|
let pool = common::test_pool().await;
|
|
let server = common::test_server(accounts_service::build_app(pool, &common::test_config()));
|
|
let (_, email) = common::register_account(&server).await;
|
|
let (_, first) = login(&server, &email).await;
|
|
|
|
// Two tabs racing to refresh the same cookie: the first wins and rotates.
|
|
let second = server
|
|
.post("/auth/refresh")
|
|
.add_cookie(Cookie::new("lv_refresh", first.clone()))
|
|
.await
|
|
.cookie("lv_refresh")
|
|
.value()
|
|
.to_owned();
|
|
// The second tab's request lands moments later with the now-stale cookie:
|
|
// it must be rejected...
|
|
server
|
|
.post("/auth/refresh")
|
|
.add_cookie(Cookie::new("lv_refresh", first))
|
|
.await
|
|
.assert_status(StatusCode::UNAUTHORIZED);
|
|
// ...but the first tab's freshly-rotated token must keep working.
|
|
server
|
|
.post("/auth/refresh")
|
|
.add_cookie(Cookie::new("lv_refresh", second))
|
|
.await
|
|
.assert_status_ok();
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn logout_revokes_the_refresh_token() {
|
|
let pool = common::test_pool().await;
|
|
let server = common::test_server(accounts_service::build_app(pool, &common::test_config()));
|
|
let (_, email) = common::register_account(&server).await;
|
|
let (_, refresh) = login(&server, &email).await;
|
|
|
|
let res = server
|
|
.post("/auth/logout")
|
|
.add_cookie(Cookie::new("lv_refresh", refresh.clone()))
|
|
.await;
|
|
res.assert_status(StatusCode::NO_CONTENT);
|
|
let removal = res.cookie("lv_refresh");
|
|
assert_eq!(removal.value(), "");
|
|
assert_eq!(removal.max_age(), Some(time::Duration::ZERO));
|
|
server
|
|
.post("/auth/refresh")
|
|
.add_cookie(Cookie::new("lv_refresh", refresh))
|
|
.await
|
|
.assert_status(StatusCode::UNAUTHORIZED);
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn refresh_without_cookie_or_with_garbage_is_401() {
|
|
let pool = common::test_pool().await;
|
|
let server = common::test_server(accounts_service::build_app(pool, &common::test_config()));
|
|
server
|
|
.post("/auth/refresh")
|
|
.await
|
|
.assert_status(StatusCode::UNAUTHORIZED);
|
|
server
|
|
.post("/auth/refresh")
|
|
.add_cookie(Cookie::new("lv_refresh", "lvr_garbage"))
|
|
.await
|
|
.assert_status(StatusCode::UNAUTHORIZED);
|
|
}
|