From 13b20b0502663ef5fe96068774a1e4c6ddf0bd6a Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 Date: Mon, 25 Sep 2023 06:37:45 -0400 Subject: [PATCH] Address PR feedback --- Cargo.lock | 1 - Cargo.toml | 3 +-- api_tests/src/comment.spec.ts | 2 +- api_tests/src/community.spec.ts | 2 +- api_tests/src/post.spec.ts | 2 +- api_tests/src/shared.ts | 10 +++++----- api_tests/src/user.spec.ts | 6 +++--- crates/api_crud/Cargo.toml | 1 - docker/federation/docker-compose.yml | 8 ++++---- 9 files changed, 16 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 80d1e7e77..0828aaa6b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2687,7 +2687,6 @@ version = "0.18.4" dependencies = [ "activitypub_federation", "actix-web", - "actix-web-httpauth", "async-trait", "bcrypt", "chrono", diff --git a/Cargo.toml b/Cargo.toml index ed628927a..af7ceb407 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -83,7 +83,6 @@ actix-web = { version = "4.3.1", default-features = false, features = [ "compress-gzip", "compress-zstd", ] } -actix-web-httpauth = "0.8.1" tracing = "0.1.37" tracing-actix-web = { version = "0.7.5", default-features = false } tracing-error = "0.2.0" @@ -169,5 +168,5 @@ prometheus = { version = "0.13.3", features = ["process"], optional = true } actix-web-prom = { version = "0.6.0", optional = true } serial_test = { workspace = true } clap = { version = "4.3.19", features = ["derive"] } -actix-web-httpauth = { workspace = true } +actix-web-httpauth = "0.8.1" lemmy_federate = { version = "0.18.4", path = "crates/federate" } diff --git a/api_tests/src/comment.spec.ts b/api_tests/src/comment.spec.ts index 6ced2bf33..871545971 100644 --- a/api_tests/src/comment.spec.ts +++ b/api_tests/src/comment.spec.ts @@ -229,7 +229,7 @@ test.skip("Remove a comment from admin and community on the same instance", asyn test("Remove a comment from admin and community on different instance", async () => { let alpha_user = await registerUser(alpha); let newAlphaApi = new LemmyHttp(alphaUrl, { - headers: { auth: alpha_user.jwt ?? "" }, + headers: { Authorization: `Bearer ${alpha_user.jwt ?? ""}` }, }); // New alpha user creates a community, post, and comment. diff --git a/api_tests/src/community.spec.ts b/api_tests/src/community.spec.ts index b81dd900c..18b56c152 100644 --- a/api_tests/src/community.spec.ts +++ b/api_tests/src/community.spec.ts @@ -252,7 +252,7 @@ test("moderator view", async () => { // register a new user with their own community on alpha and post to it let registerUserRes = await registerUser(alpha); let otherUser = new LemmyHttp(alphaUrl, { - headers: { auth: registerUserRes.jwt ?? "" }, + headers: { Authorization: `Bearer ${registerUserRes.jwt ?? ""}` }, }); let otherCommunity = (await createCommunity(otherUser)).community_view; diff --git a/api_tests/src/post.spec.ts b/api_tests/src/post.spec.ts index 51a10293b..ff792bb26 100644 --- a/api_tests/src/post.spec.ts +++ b/api_tests/src/post.spec.ts @@ -382,7 +382,7 @@ test("Enforce site ban for federated user", async () => { let alphaUserJwt = await registerUser(alpha); expect(alphaUserJwt).toBeDefined(); let alpha_user = new LemmyHttp(alphaUrl, { - headers: { auth: alphaUserJwt.jwt ?? "" }, + headers: { Authorization: `Bearer ${alphaUserJwt.jwt ?? ""}` }, }); let alphaUserActorId = (await getSite(alpha_user)).my_user?.local_user_view .person.actor_id; diff --git a/api_tests/src/shared.ts b/api_tests/src/shared.ts index a1868f8f2..961d46be0 100644 --- a/api_tests/src/shared.ts +++ b/api_tests/src/shared.ts @@ -124,11 +124,11 @@ export async function setupLogins() { resDelta, resEpsilon, ]); - alpha.setHeaders({ auth: res[0].jwt ?? "" }); - beta.setHeaders({ auth: res[1].jwt ?? "" }); - gamma.setHeaders({ auth: res[2].jwt ?? "" }); - delta.setHeaders({ auth: res[3].jwt ?? "" }); - epsilon.setHeaders({ auth: res[4].jwt ?? "" }); + alpha.setHeaders({ Authorization: `Bearer ${res[0].jwt ?? ""}` }); + beta.setHeaders({ Authorization: `Bearer ${res[1].jwt ?? ""}` }); + gamma.setHeaders({ Authoirzation: `Bearer ${res[2].jwt ?? ""}` }); + delta.setHeaders({ Authorization: `Bearer ${res[3].jwt ?? ""}` }); + epsilon.setHeaders({ Authorization: `Bearer ${res[4].jwt ?? ""}` }); // Registration applications are now enabled by default, need to disable them let editSiteForm: EditSite = { diff --git a/api_tests/src/user.spec.ts b/api_tests/src/user.spec.ts index e679e8053..db36494d7 100644 --- a/api_tests/src/user.spec.ts +++ b/api_tests/src/user.spec.ts @@ -41,7 +41,7 @@ test("Create user", async () => { let userRes = await registerUser(alpha); expect(userRes.jwt).toBeDefined(); let user = new LemmyHttp(alphaUrl, { - headers: { auth: userRes.jwt ?? "" }, + headers: { Authorization: `Bearer ${userRes.jwt ?? ""}` }, }); let site = await getSite(user); @@ -63,7 +63,7 @@ test("Delete user", async () => { let userRes = await registerUser(alpha); expect(userRes.jwt).toBeDefined(); let user = new LemmyHttp(alphaUrl, { - headers: { auth: userRes.jwt ?? "" }, + headers: { Authorization: `Bearer ${userRes.jwt ?? ""}` }, }); // make a local post and comment @@ -109,7 +109,7 @@ test("Delete user", async () => { test("Requests with invalid auth should be treated as unauthenticated", async () => { let invalid_auth = new LemmyHttp(alphaUrl, { - headers: { auth: "" }, + headers: { Authorization: "Bearer foobar" }, }); let site = await getSite(invalid_auth); expect(site.my_user).toBeUndefined(); diff --git a/crates/api_crud/Cargo.toml b/crates/api_crud/Cargo.toml index f39c76ca5..06e29044b 100644 --- a/crates/api_crud/Cargo.toml +++ b/crates/api_crud/Cargo.toml @@ -18,7 +18,6 @@ activitypub_federation = { workspace = true } bcrypt = { workspace = true } serde = { workspace = true } actix-web = { workspace = true } -actix-web-httpauth = { workspace = true } tracing = { workspace = true } url = { workspace = true } async-trait = { workspace = true } diff --git a/docker/federation/docker-compose.yml b/docker/federation/docker-compose.yml index 272723fc2..634a97449 100644 --- a/docker/federation/docker-compose.yml +++ b/docker/federation/docker-compose.yml @@ -2,11 +2,11 @@ version: "3.7" x-ui-default: &ui-default init: true - # image: dessalines/lemmy-ui:0.18.4 + image: dessalines/lemmy-ui:0.18.4 # assuming lemmy-ui is cloned besides lemmy directory - build: - context: ../../../lemmy-ui - dockerfile: dev.dockerfile + # build: + # context: ../../../lemmy-ui + # dockerfile: dev.dockerfile environment: - LEMMY_UI_HTTPS=false