瀏覽代碼

HUE-4652 [core] Add settings for django-axes AXES_BEHIND_REVERSE_PROXY and AXES_REVERSE_PROXY_HEADER

Jenny Kim 9 年之前
父節點
當前提交
f60472e

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

@@ -323,6 +323,12 @@
     # If True, lock out based on IP and user
     ## login_lock_out_by_combination_user_and_ip=false
 
+    # If True, it will look for the IP address from the header defined at reverse_proxy_header.
+    ## behind_reverse_proxy=false
+
+    # If behind_reverse_proxy is True, it will look for the IP address from this header. Default: HTTP_X_FORWARDED_FOR
+    ## reverse_proxy_header=HTTP_X_FORWARDED_FOR
+
   # Configuration options for connecting to LDAP and Active Directory
   # -------------------------------------------------------------------
   [[ldap]]

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

@@ -331,6 +331,12 @@
     # If True, lock out based on IP and user
     ## login_lock_out_by_combination_user_and_ip=false
 
+    # If True, it will look for the IP address from the header defined at reverse_proxy_header.
+    ## behind_reverse_proxy=false
+
+    # If behind_reverse_proxy is True, it will look for the IP address from this header. Default: HTTP_X_FORWARDED_FOR
+    ## reverse_proxy_header=HTTP_X_FORWARDED_FOR
+
   # Configuration options for connecting to LDAP and Active Directory
   # -------------------------------------------------------------------
   [[ldap]]

+ 12 - 0
desktop/core/src/desktop/conf.py

@@ -796,6 +796,18 @@ AUTH = ConfigSection(
       type=coerce_bool,
       default=False,
     ),
+    BEHIND_REVERSE_PROXY = Config(
+      key="behind_reverse_proxy",
+      help=_("If True, it will look for the IP address from the header defined at reverse_proxy_header."),
+      type=coerce_bool,
+      default=False,
+    ),
+    REVERSE_PROXY_HEADER = Config(
+      key="reverse_proxy_header",
+      help=_("If behind_reverse_proxy is True, it will look for the IP address from this header. Default: HTTP_X_FORWARDED_FOR"),
+      type=str,
+      default="HTTP_X_FORWARDED_FOR",
+    ),
 ))
 
 

+ 2 - 0
desktop/core/src/desktop/settings.py

@@ -401,6 +401,8 @@ AXES_LOCK_OUT_AT_FAILURE = desktop.conf.AUTH.LOGIN_LOCK_OUT_AT_FAILURE.get()
 AXES_COOLOFF_TIME = desktop.conf.AUTH.LOGIN_COOLOFF_TIME.get()
 AXES_USE_USER_AGENT = desktop.conf.AUTH.LOGIN_LOCK_OUT_USE_USER_AGENT.get()
 AXES_LOCK_OUT_BY_COMBINATION_USER_AND_IP = desktop.conf.AUTH.LOGIN_LOCK_OUT_BY_COMBINATION_USER_AND_IP.get()
+AXES_BEHIND_REVERSE_PROXY = desktop.conf.AUTH.BEHIND_REVERSE_PROXY.get()
+AXES_REVERSE_PROXY_HEADER = desktop.conf.AUTH.REVERSE_PROXY_HEADER.get()
 
 # SAML
 SAML_AUTHENTICATION = 'libsaml.backend.SAML2Backend' in AUTHENTICATION_BACKENDS