From 2037167533b9d2f4e0d86054594339a752e81cca Mon Sep 17 00:00:00 2001 From: Fred <10602047+freddieptf@users.noreply.github.com> Date: Wed, 17 Jan 2024 20:58:33 +0300 Subject: [PATCH] Use axios to correctly encode credentials (#9) * do basic auth correct * keys match vars * 1.0.1 --- package-lock.json | 4 ++-- package.json | 2 +- src/lib/cht-api.ts | 7 ++++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index dfde405e..b00b7d4b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "cht-user-management", - "version": "1.0.0", + "version": "1.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "cht-user-management", - "version": "1.0.0", + "version": "1.0.1", "license": "ISC", "dependencies": { "@fastify/autoload": "^5.8.0", diff --git a/package.json b/package.json index eaceaaf6..438aece7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cht-user-management", - "version": "1.0.0", + "version": "1.0.1", "main": "dist/index.js", "dependencies": { "@fastify/autoload": "^5.8.0", diff --git a/src/lib/cht-api.ts b/src/lib/cht-api.ts index 2f7bc45f..d42a048e 100644 --- a/src/lib/cht-api.ts +++ b/src/lib/cht-api.ts @@ -50,10 +50,15 @@ export class ChtApi { public static async createSession(authInfo: AuthenticationInfo, username : string, password: string): Promise { const COUCH_AUTH_COOKIE_NAME = 'AuthSession='; const protocol = authInfo.useHttp ? 'http' : 'https'; - const sessionUrl = `${protocol}://${username}:${password}@${authInfo.domain}/_session`; + const sessionUrl = `${protocol}://${authInfo.domain}/_session`; const resp = await axios.post(sessionUrl, { name: username, password, + }, { + auth: { + username, + password + } }); const setCookieHeader = (resp.headers as AxiosHeaders).get('set-cookie') as AxiosHeaders; const sessionToken = setCookieHeader?.[0].split(';')