Skip to content

Commit dbb8e74

Browse files
authored
chore: Revert allowing Authorization header (reacherhq#164)
* chore: Revert allowing Authorization header * Fix tests * Fix lint
1 parent 6d01a89 commit dbb8e74

File tree

4 files changed

+10
-37
lines changed

4 files changed

+10
-37
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "reacher_backend"
3-
version = "0.3.5"
3+
version = "0.3.6"
44
edition = "2018"
55
license = "AGPL-3.0 OR Commercial"
66
publish = false

src/routes/check_email/header.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ pub const DEFAULT_SAASIFY_SECRET: &str = "reacher_dev_secret";
2727
/// but there might be others in the future
2828
#[derive(Debug, PartialEq)]
2929
pub enum HeaderSecret {
30-
Authorization,
3130
Saasify,
3231
}
3332

@@ -41,8 +40,6 @@ fn get_saasify_secret() -> String {
4140
/// for auth that match:
4241
/// - `x-saasify-proxy-secret`: this means auth is handled by saasify, we don't
4342
/// care about auth anymore.
44-
/// - `Authorization`: this is a temporary fix to allow all requests with this
45-
/// header.
4643
pub fn check_header(
4744
) -> impl warp::Filter<Extract = (HeaderSecret,), Error = warp::Rejection> + Clone {
4845
let saasify_secret = get_saasify_secret();
@@ -51,6 +48,4 @@ pub fn check_header(
5148

5249
warp::header::exact_ignore_case(SAASIFY_SECRET_HEADER, saasify_secret)
5350
.map(|| HeaderSecret::Saasify)
54-
.or(warp::header::<String>("authorization").map(|_| HeaderSecret::Authorization))
55-
.unify()
5651
}

tests/check_email.rs

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ async fn test_missing_header() {
3939

4040
println!("{:?}", resp);
4141
assert_eq!(resp.status(), StatusCode::BAD_REQUEST);
42-
assert_eq!(resp.body(), r#"Missing request header "authorization""#);
42+
assert_eq!(
43+
resp.body(),
44+
r#"Missing request header "x-saasify-proxy-secret""#
45+
);
4346
}
4447

4548
#[tokio::test]
@@ -54,7 +57,10 @@ async fn test_wrong_saasify_secret() {
5457

5558
println!("{:?}", resp);
5659
assert_eq!(resp.status(), StatusCode::BAD_REQUEST);
57-
assert_eq!(resp.body(), r#"Missing request header "authorization""#);
60+
assert_eq!(
61+
resp.body(),
62+
r#"Invalid request header "x-saasify-proxy-secret""#
63+
);
5864
}
5965

6066
#[tokio::test]
@@ -84,31 +90,3 @@ async fn test_input_foo_bar_baz() {
8490
assert_eq!(resp.status(), StatusCode::OK);
8591
assert_eq!(resp.body(), FOO_BAR_BAZ_RESPONSE);
8692
}
87-
88-
#[tokio::test]
89-
async fn test_authorization_header() {
90-
let resp = request()
91-
.path("/v0/check_email")
92-
.method("POST")
93-
.header("authorization", "foo")
94-
.json(&serde_json::from_str::<EndpointRequest>(r#"{"to_email": "[email protected]"}"#).unwrap())
95-
.reply(&create_routes())
96-
.await;
97-
98-
assert_eq!(resp.status(), StatusCode::OK);
99-
assert_eq!(resp.body(), FOO_BAR_BAZ_RESPONSE);
100-
}
101-
102-
#[tokio::test]
103-
async fn test_authorization_capital_header() {
104-
let resp = request()
105-
.path("/v0/check_email")
106-
.method("POST")
107-
.header("Authorization", "foo")
108-
.json(&serde_json::from_str::<EndpointRequest>(r#"{"to_email": "[email protected]"}"#).unwrap())
109-
.reply(&create_routes())
110-
.await;
111-
112-
assert_eq!(resp.status(), StatusCode::OK);
113-
assert_eq!(resp.body(), FOO_BAR_BAZ_RESPONSE);
114-
}

0 commit comments

Comments
 (0)