瀏覽代碼

HUE-9608 [core] Sensitive Information Stored in Local Storage (asnaik)

HUE-9608 [core] Sensitive Information Stored in Local Storage (asnaik)
Asnaik HWX 5 年之前
父節點
當前提交
c8cf483016

+ 5 - 0
desktop/conf.dist/hue.ini

@@ -310,6 +310,11 @@
   # Turn on the direct link sharing of saved document.
   ## enable_link_sharing=true
 
+  # Hue uses Localstorage to keep the users settings and database preferences.
+  # Please make this value true in case local storage should not be used
+  # default value is false
+  ## disable_local_storage = false
+
   # Administrators
   # ----------------
   [[django_admins]]

+ 5 - 0
desktop/conf/pseudo-distributed.ini.tmpl

@@ -314,6 +314,11 @@
   # Turn on the direct link sharing of saved document.
   ## enable_link_sharing=true
 
+  # Hue uses Localstorage to keep the users settings and database preferences.
+  # Please make this value true in case local storage should not be used
+  # default value is false
+  ## disable_local_storage = false
+
   # Administrators
   # ----------------
   [[django_admins]]

+ 8 - 1
desktop/core/src/desktop/conf.py

@@ -993,7 +993,7 @@ CUSTOM = ConfigSection(
                    help=_("The cache TTL in milliseconds for the assist/autocomplete/etc calls. Set to 0 it disables the cache.")),
     LOGO_SVG=Config("logo_svg",
                    default="",
-                   help=_("SVG code to replace the default Hue logo in the top bar and sign in screen")),
+                   help=_("SVG code to replace the default Hue logo in the top bar and sign in screen"))
 ))
 
 AUTH = ConfigSection(
@@ -1938,6 +1938,13 @@ ENABLE_LINK_SHARING = Config(
   type=coerce_bool,
   help=_('Turn on the direct link sharing of saved document.')
 )
+DISABLE_LOCAL_STORAGE = Config(
+  key='disable_local_storage',
+  default="false",
+  type=coerce_bool,
+  help=_("Hue uses Localstorage to keep the users settings and database preferences."
+         "Please make this value true in case local storage should not be used")
+)
 
 ENABLE_CONNECTORS = Config(
   key='enable_connectors',

+ 5 - 1
desktop/core/src/desktop/js/utils/storageUtils.ts

@@ -22,7 +22,7 @@ type LocalStorageGet = {
 };
 export const getFromLocalStorage: LocalStorageGet = <T>(key: string, defaultValue?: T) => {
   const defaultOrNull = typeof defaultValue !== 'undefined' ? defaultValue : null;
-  if (!window.localStorage) {
+  if (!window.localStorage || window.DISABLE_LOCAL_STORAGE) {
     return defaultOrNull;
   }
 
@@ -47,6 +47,10 @@ export const setInLocalStorage = (key: string, value: unknown): void => {
   if (!window.localStorage) {
     return;
   }
+  if (window.DISABLE_LOCAL_STORAGE) {
+    window.localStorage.clear();
+    return;
+  }
   const userKey = (<hueWindow>window).LOGGED_USERNAME
     ? `${(<hueWindow>window).LOGGED_USERNAME}.${key}`
     : key;

+ 2 - 0
desktop/core/src/desktop/templates/global_js_constants.mako

@@ -47,6 +47,8 @@
 
   window.BANNER_TOP_HTML = '${ conf.CUSTOM.BANNER_TOP_HTML.get() }';
 
+  window.DISABLE_LOCAL_STORAGE = '${ conf.DISABLE_LOCAL_STORAGE.get() }' === 'True';
+
   window.CACHEABLE_TTL = {
     default: ${ conf.CUSTOM.CACHEABLE_TTL.get() },
     optimizer: ${ OPTIMIZER.CACHEABLE_TTL.get() or 0 }