diff --git a/chat/src/helpers/hybrid_query.py b/chat/src/helpers/hybrid_query.py index 5a7119d3..8e202d5f 100644 --- a/chat/src/helpers/hybrid_query.py +++ b/chat/src/helpers/hybrid_query.py @@ -19,8 +19,8 @@ def hybrid_query(query: str, model_id: str, vector_field: str = "embedding", k: "queries": [ filter({ "query_string": { - "default_operator": "AND", - "fields": ["title^5", "all_controlled_labels", "all_ids^5"], + "default_operator": "OR", + "fields": ["title^1", "collection.title^5", "all_controlled_labels", "all_ids^1"], "query": query } }), diff --git a/node/src/handlers/get-auth-callback.js b/node/src/handlers/get-auth-callback.js index 87370f21..7f1a0a76 100644 --- a/node/src/handlers/get-auth-callback.js +++ b/node/src/handlers/get-auth-callback.js @@ -34,16 +34,18 @@ exports.handler = wrap(async (event) => { return { statusCode: 400 }; }); +async function invokeNuApi(path, headers) { + const url = new URL(process.env.NUSSO_BASE_URL); + url.pathname = path; + return await axios.get(url.toString(), { + headers: { apikey: process.env.NUSSO_API_KEY, ...headers }, + }); +} + async function getNetIdFromToken(nusso) { - const response = await axios.get( - `${process.env.NUSSO_BASE_URL}validateWebSSOToken`, - { - headers: { - apikey: process.env.NUSSO_API_KEY, - webssotoken: nusso, - }, - } - ); + const response = await invokeNuApi("/agentless-websso/validateWebSSOToken", { + webssotoken: nusso, + }); return response?.data?.netid; } @@ -52,14 +54,8 @@ async function redeemSsoToken(event) { const netid = await getNetIdFromToken(nusso); if (netid) { try { - const response = await axios.get( - `${process.env.NUSSO_BASE_URL}validate-with-directory-search-response`, - { - headers: { - apikey: process.env.NUSSO_API_KEY, - webssotoken: nusso, - }, - } + const response = await invokeNuApi( + `/directory-search/res/netid/bas/${netid}` ); return fillInBlanks({ ...response.data.results[0], uid: netid }); } catch (err) { @@ -79,10 +75,13 @@ async function redeemSsoToken(event) { } function fillInBlanks(response) { - const { uid } = response; - response.displayName = ifEmpty(response.displayName, [uid]); - response.mail = ifEmpty(response.mail, `${uid}@e.northwestern.edu`); - return response; + const { uid, displayName, givenName, mail } = response; + return { + uid, + givenName, + displayName: ifEmpty(displayName, [uid]), + mail: ifEmpty(mail, `${uid}@e.northwestern.edu`), + }; } function ifEmpty(val, replacement) { diff --git a/node/test/integration/get-auth-callback.test.js b/node/test/integration/get-auth-callback.test.js index 92639114..a1b94751 100644 --- a/node/test/integration/get-auth-callback.test.js +++ b/node/test/integration/get-auth-callback.test.js @@ -20,13 +20,13 @@ describe("auth callback", function () { .render(); nock(process.env.NUSSO_BASE_URL) - .get("/validateWebSSOToken") + .get("/agentless-websso/validateWebSSOToken") .reply(200, { netid: "uid123" }); }); it("redeems the NUSSO token", async () => { nock(process.env.NUSSO_BASE_URL) - .get("/validate-with-directory-search-response") + .get("/directory-search/res/netid/bas/uid123") .reply(200, { results: [ { displayName: ["Some User"], mail: "some.user@example.com" }, @@ -53,7 +53,7 @@ describe("auth callback", function () { it("fills in the blanks if the directory search result is incomplete", async () => { nock(process.env.NUSSO_BASE_URL) - .get("/validate-with-directory-search-response") + .get("/directory-search/res/netid/bas/uid123") .reply(200, { results: [{ displayName: [], mail: "" }], }); @@ -82,7 +82,7 @@ describe("auth callback", function () { it("assembles a user object from the netID if directory search fails", async () => { nock(process.env.NUSSO_BASE_URL) - .get("/validate-with-directory-search-response") + .get("/directory-search/res/netid/bas/uid123") .reply(500, { fault: { faultstring: