Skip to content
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

Attach authorization header to ghosterysearch.com/login #5

Merged
merged 2 commits into from Oct 20, 2020
Merged
Changes from all commits
Commits
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

@@ -44,6 +44,7 @@ const cookieListener = (changeInfo) => {

if (removed) {
AccessToken.destroy();
return;
}

AccessToken.set(cookie.value);
@@ -81,6 +82,21 @@ async function start() {
requestHeaders,
};
}, { urls: [`${SERP_BASE_URL}/search*`]}, ["blocking", "requestHeaders"]);

browser.webRequest.onBeforeSendHeaders.addListener(async (details) => {
const { requestHeaders } = details;
const accessToken = AccessToken.get();
if (!accessToken) {
return;
}
requestHeaders.push({
name: "Authorization",
value: `Bearer ${accessToken}`,
});
return {
requestHeaders,
};
}, { urls: [`${SERP_BASE_URL}/login*`]}, ["blocking", "requestHeaders"]);
}

start();
@@ -1,3 +1,3 @@
let DEBUG = false;
let DEBUG = true;

This comment has been minimized.

@sammacbeth

sammacbeth Oct 20, 2020
Contributor

In future we could expose this on the window object to allow this to be toggled at runtime.

This comment has been minimized.

@chrmod

chrmod Oct 20, 2020
Author Member

ops, this should not get merged with debug set to true

This comment has been minimized.

@chrmod

chrmod Oct 20, 2020
Author Member

toggling it from window global would be lovely but it will require replacing webrequest listeners.

let API_BASE_URL = DEBUG ? 'http://localhost:5000' : 'https://ghosterysearch.com';
let SERP_BASE_URL = DEBUG ? 'http://localhost' : 'https://ghosterysearch.com';
@@ -1,5 +1,5 @@
{
"version": "0.1.3",
"version": "0.1.4",
"browser_specific_settings": {
"gecko": {
"id": "search@ghostery.com"
ProTip! Use n and p to navigate between commits in a pull request.