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

Fixes for auth on staging. #15

Merged
merged 1 commit into from Oct 30, 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

Fixes for auth on staging.

  • Loading branch information
sammacbeth committed Oct 30, 2020
commit 52a35970d9ce83ce4b51e7126c08ae13e0a18864
@@ -40,8 +40,7 @@ function parseJwt(token) {

const cookieListener = (changeInfo) => {
const { cookie, removed } = changeInfo;

if (cookie.domain !== ".ghostery.com") {
if (cookie.domain !== AUTH_DOMAIN) {
return;
}

@@ -60,7 +59,7 @@ const cookieListener = (changeInfo) => {
const lookForAccessToken = async () => {
browser.cookies.onChanged.addListener(cookieListener);
const cookie = await browser.cookies.get({
url: "https://www.ghostery.com/",
url: `https://www${AUTH_DOMAIN}/`,
name: "access_token",
});
if (cookie) {
@@ -1,14 +1,18 @@
let DEBUG = false;
const STAGING_BASE_URL = 'https://staging.ghosterysearch.com';
const PROD_BASE_URL = 'https://ghosterysearch.com';
const STAGING_AUTH_DOMAIN = '.ghosterystage.com';
const PROD_AUTH_DOMAIN = '.ghostery.com';
let API_BASE_URL = DEBUG ? 'http://localhost:5000' : PROD_BASE_URL;
let SERP_BASE_URL = DEBUG ? 'http://localhost' : PROD_BASE_URL;
let AUTH_BASE_URL = 'https://consumerapi.ghostery.com/api/v2';
let AUTH_DOMAIN = PROD_AUTH_DOMAIN;
let AUTH_BASE_URL = `https://consumerapi${PROD_AUTH_DOMAIN}/api/v2`;

const setupEndpoints = (async function() {
const USE_STAGING = (await browser.storage.local.get('USE_STAGING'))['USE_STAGING'];
if (USE_STAGING) {
AUTH_BASE_URL = AUTH_BASE_URL.replace('.ghostery.com', '.ghosterystage.com');
AUTH_DOMAIN = STAGING_AUTH_DOMAIN;
AUTH_BASE_URL = AUTH_BASE_URL.replace(PROD_AUTH_DOMAIN, STAGING_AUTH_DOMAIN);
console.log(`USING_STAGING: AUTH_BASE_URL=${AUTH_BASE_URL}`)
// only switch to staging search if DEBUG is disabled
if (!DEBUG) {
@@ -30,7 +30,10 @@
"webRequestBlocking",
"https://www.ghostery.com/*",
"https://consumerapi.ghostery.com/*",
"https://www.ghosterystage.com/*",
"https://consumerapi.ghosterystage.com/*",
"https://ghosterysearch.com/*",
"https://staging.ghosterysearch.com/*",
"http://localhost/*"
],
"icons": {
ProTip! Use n and p to navigate between commits in a pull request.