Commit 6c6e11dd authored by Mohamed Heikal's avatar Mohamed Heikal Committed by Commit Bot

Fix bug and remove API key from the supersize tiger viewer static files

The API key is not actually required to perform the request as long as
you are only dealing with authenticated requests (The access token is
enough of an identifier). This CL removes the API key (which has since
been revoked) as well as fixes a (use before define) bug in auth.js

Change-Id: I5abdde63b65b868d79a3bc4ca47ff59bc65cb25a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2092423Reviewed-by: default avatarSamuel Huang <huangs@chromium.org>
Commit-Queue: Mohamed Heikal <mheikal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748226}
parent ba22a6cd
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
// @ts-check // @ts-check
'use strict'; 'use strict';
const AUTH_API_KEY = 'AIzaSyAeKy_bJvcqYoLG02gCVF23an0kx8KzMng';
const AUTH_CLIENT_ID = '84462612899-hsikvugfjv36k8nt8459b7at62hi9sba.apps.googleusercontent.com'; const AUTH_CLIENT_ID = '84462612899-hsikvugfjv36k8nt8459b7at62hi9sba.apps.googleusercontent.com';
const AUTH_SCOPE = 'https://www.googleapis.com/auth/devstorage.read_only'; const AUTH_SCOPE = 'https://www.googleapis.com/auth/devstorage.read_only';
const AUTH_DISCOVERY_URL = 'https://www.googleapis.com/discovery/v1/apis/storage/v1/rest'; const AUTH_DISCOVERY_URL = 'https://www.googleapis.com/discovery/v1/apis/storage/v1/rest';
......
...@@ -5,12 +5,12 @@ ...@@ -5,12 +5,12 @@
// @ts-check // @ts-check
'use strict'; 'use strict';
let _googleAuthPromiseResolve = null;
window.googleAuth = null; window.googleAuth = null;
window.googleAuthPromise = new Promise((resolve, reject) => { window.googleAuthPromise = new Promise((resolve, reject) => {
googleAuthPromiseResolve = resolve; _googleAuthPromiseResolve = resolve;
}); });
let _googleAuthPromiseResolve = null;
function handleClientLoad() { function handleClientLoad() {
if (requiresAuthentication()) { if (requiresAuthentication()) {
gapi.load('client:auth2', initClient); gapi.load('client:auth2', initClient);
...@@ -19,7 +19,6 @@ function handleClientLoad() { ...@@ -19,7 +19,6 @@ function handleClientLoad() {
function initClient() { function initClient() {
return gapi.client.init({ return gapi.client.init({
'apiKey': AUTH_API_KEY,
'clientId': AUTH_CLIENT_ID, 'clientId': AUTH_CLIENT_ID,
'discoveryDocs': [AUTH_DISCOVERY_URL], 'discoveryDocs': [AUTH_DISCOVERY_URL],
'scope': AUTH_SCOPE, 'scope': AUTH_SCOPE,
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
'use strict'; 'use strict';
importScripts('./auth-consts.js');
importScripts('./shared.js'); importScripts('./shared.js');
importScripts('./caspian_web.js'); importScripts('./caspian_web.js');
importScripts('./auth-consts.js');
const LoadWasm = new Promise(function(resolve, reject) { const LoadWasm = new Promise(function(resolve, reject) {
Module['onRuntimeInitialized'] = function() { Module['onRuntimeInitialized'] = function() {
...@@ -73,7 +73,7 @@ class DataFetcher { ...@@ -73,7 +73,7 @@ class DataFetcher {
async _fetchFromGoogleCloudStorage(url) { async _fetchFromGoogleCloudStorage(url) {
const {bucket, file} = parseGoogleCloudStorageUrl(url); const {bucket, file} = parseGoogleCloudStorageUrl(url);
const params = `alt=media&key=${AUTH_API_KEY}`; const params = `alt=media`;
const api_url = `${STORAGE_API_ENDPOINT}/b/${bucket}/o/${file}?${params}`; const api_url = `${STORAGE_API_ENDPOINT}/b/${bucket}/o/${file}?${params}`;
const headers = new Headers(); const headers = new Headers();
headers.append('Authorization', `Bearer ${this._accessToken}`); headers.append('Authorization', `Bearer ${this._accessToken}`);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment