Skip to content

Allow using CST created with PAT to authenticate requests #233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jan 30, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Allow using CST created with PAT to authenticate requests
  • Loading branch information
andrii-balitskyi committed Jan 14, 2025
commit 8db741667e2d21a8435bd2bd4082007d83acb59b
7 changes: 0 additions & 7 deletions src/lib/middleware/with-client-session.ts
Original file line number Diff line number Diff line change
@@ -99,13 +99,6 @@ export const withClientSession: Middleware<
})
}

if (publishable_key == null && api_key_id == null) {
throw new UnauthorizedException({
type: "unauthorized",
message: "publishable key or api key must be set",
})
}

req.auth = {
type: "client_session",
client_session_id,
22 changes: 0 additions & 22 deletions test/middleware/with-client-session.test.ts
Original file line number Diff line number Diff line change
@@ -85,26 +85,4 @@ test("withClientSession middleware - successful auth", async (t) => {
)
t.is(revokedErr?.status, 401)
t.is(revokedErr?.response.error.type, "client_session_revoked")

// Test client session without api key or publishable key
const invalid_session = db.addClientSession({
workspace_id: seed_result.seed_workspace_1,
})

const invalidSessionErr = await t.throwsAsync<SimpleAxiosError>(
axios.get("/connected_accounts/get", {
params: {
connected_account_id: seed_result.john_connected_account_id,
},
headers: {
Authorization: `Bearer ${invalid_session.token}`,
},
}),
)
t.is(invalidSessionErr?.status, 401)
t.is(invalidSessionErr?.response.error.type, "unauthorized")
t.is(
invalidSessionErr?.response.error.message,
"publishable key or api key must be set",
)
})