mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-11-28 16:06:22 +00:00
* fix: derive the client ip from trusted proxies only Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: read forwarded-for as raw bytes and add an explicit client ip header Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: strip the source port from cloudfront-viewer-address before parsing Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * style: rustfmt client_ip Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: restrict api tokens to allowed ip ranges Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: inherit token ip restrictions on every mint and refuse login links Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: keep a webhook token's ip restriction when rotating it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test: pin that webhook token rotation keeps allowed_ips Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * perf: resolve the client ip only for restricted tokens and throttle refusal logs Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore: update ee-repo-ref to 49b7074a9ce31a2b7cd5a730c9b9d4b8295d0c7e This commit updates the EE repository reference after PR #1011 was merged in windmill-ee-private. Previous ee-repo-ref: 6c8458630cea7c3082771db9f772c964ef11dcdf New ee-repo-ref: 49b7074a9ce31a2b7cd5a730c9b9d4b8295d0c7e Automated by sync-ee-ref workflow. * feat: show the caller's ip so a device can check what to allowlist Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: make token ip allowlists an ee feature Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor: move token ip allowlist logic into ee Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore: update ee-repo-ref to cf0cee4ef89bd0b8b2399ced7b12ccc9a3d43dd8 This commit updates the EE repository reference after PR #1017 was merged in windmill-ee-private. Previous ee-repo-ref: 98f8ade3347f3dcfc73962f4aa39618282f73fa3 New ee-repo-ref: cf0cee4ef89bd0b8b2399ced7b12ccc9a3d43dd8 Automated by sync-ee-ref workflow. --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: windmill-internal-app[bot] <windmill-internal-app[bot]@users.noreply.github.com>
77 lines
2.5 KiB
Rust
77 lines
2.5 KiB
Rust
//! Postgres-trigger ancillary handlers (slot / publication / version management)
|
|
//! must reject a path-mismatched scoped token before opening any connection —
|
|
//! the route-level middleware only checks the scope domain, so per-path
|
|
//! enforcement lives in the handlers. Rejecting pre-connection is why these tests
|
|
//! need no real Postgres resource.
|
|
|
|
use axum::{extract::Path, Extension, Json};
|
|
use sqlx::{Pool, Postgres};
|
|
use windmill_api_auth::ApiAuthed;
|
|
use windmill_common::{db::UserDB, error::Error};
|
|
use windmill_trigger_postgres::{handler, Slot};
|
|
|
|
fn scoped_authed(scopes: Vec<&str>) -> ApiAuthed {
|
|
ApiAuthed {
|
|
email: "alice@windmill.dev".to_string(),
|
|
username: "alice".to_string(),
|
|
is_admin: false,
|
|
is_operator: false,
|
|
groups: vec![],
|
|
folders: vec![],
|
|
scopes: Some(scopes.into_iter().map(str::to_string).collect()),
|
|
username_override: None,
|
|
username_override_is_token_label: false,
|
|
is_session_token: false,
|
|
token_prefix: None,
|
|
read_only: false,
|
|
job_id: None,
|
|
credential_expiry: None,
|
|
mcp_client: None,
|
|
capabilities: Some(windmill_common::roles::RoleCapabilities::FULL),
|
|
allowed_ips: None,
|
|
}
|
|
}
|
|
|
|
// A token scoped to `u/alice/db` must not reach a read handler for `u/bob/db`.
|
|
#[sqlx::test]
|
|
async fn read_handler_rejects_path_mismatched_scope(db: Pool<Postgres>) -> anyhow::Result<()> {
|
|
let authed = scoped_authed(vec!["postgres_triggers:read:u/alice/db"]);
|
|
let user_db = UserDB::new(db.clone());
|
|
|
|
let res = handler::get_postgres_version(
|
|
authed,
|
|
Extension(db),
|
|
Extension(user_db),
|
|
Path(("test-workspace".to_string(), "u/bob/db".to_string())),
|
|
)
|
|
.await;
|
|
|
|
assert!(
|
|
matches!(res, Err(Error::PermissionDenied(_))),
|
|
"expected PermissionDenied, got {res:?}"
|
|
);
|
|
Ok(())
|
|
}
|
|
|
|
// The destructive slot-drop handler must reject a write token scoped to another path.
|
|
#[sqlx::test]
|
|
async fn drop_slot_rejects_path_mismatched_scope(db: Pool<Postgres>) -> anyhow::Result<()> {
|
|
let authed = scoped_authed(vec!["postgres_triggers:write:u/alice/db"]);
|
|
let user_db = UserDB::new(db.clone());
|
|
|
|
let res = handler::drop_slot_name(
|
|
authed,
|
|
Extension(user_db),
|
|
Extension(db),
|
|
Path(("test-workspace".to_string(), "u/bob/db".to_string())),
|
|
Json(Slot { name: "some_slot".to_string() }),
|
|
)
|
|
.await;
|
|
|
|
assert!(
|
|
matches!(res, Err(Error::PermissionDenied(_))),
|
|
"expected PermissionDenied, got {res:?}"
|
|
);
|
|
Ok(())
|
|
}
|