Commit edc67b68 by Sven Marnach

Merge pull request #2481 from open-craft/smarnach/selective-http-auth

Allow enabling HTTP basic auth for individual services.
parents fcb4d2ff c44bf596
...@@ -128,3 +128,28 @@ nginx_cfg: ...@@ -128,3 +128,28 @@ nginx_cfg:
NGINX_ROBOT_RULES: [ ] NGINX_ROBOT_RULES: [ ]
NGINX_EDXAPP_EMBARGO_CIDRS: [] NGINX_EDXAPP_EMBARGO_CIDRS: []
NGINX_P3P_MESSAGE: 'CP="Open edX does not have a P3P policy."' NGINX_P3P_MESSAGE: 'CP="Open edX does not have a P3P policy."'
COMMON_ENABLE_BASIC_AUTH: False
CERTS_ENABLE_BASIC_AUTH: "{{ COMMON_ENABLE_BASIC_AUTH }}"
ECOMMERCE_ENABLE_BASIC_AUTH: "{{ COMMON_ENABLE_BASIC_AUTH }}"
EDXAPP_CMS_ENABLE_BASIC_AUTH: "{{ COMMON_ENABLE_BASIC_AUTH }}"
EDXAPP_LMS_ENABLE_BASIC_AUTH: "{{ COMMON_ENABLE_BASIC_AUTH }}"
EDXAPP_LMS_PREVIEW_ENABLE_BASIC_AUTH: "{{ COMMON_ENABLE_BASIC_AUTH }}"
KIBANA_ENABLE_BASIC_AUTH: "{{ COMMON_ENABLE_BASIC_AUTH }}"
PROGRAMS_ENABLE_BASIC_AUTH: "{{ COMMON_ENABLE_BASIC_AUTH }}"
XQUEUE_ENABLE_BASIC_AUTH: "{{ COMMON_ENABLE_BASIC_AUTH }}"
XSERVER_ENABLE_BASIC_AUTH: "{{ COMMON_ENABLE_BASIC_AUTH }}"
NGINX_CREATE_HTPASSWD_FILE: >
{{
CERTS_ENABLE_BASIC_AUTH|bool or
ECOMMERCE_ENABLE_BASIC_AUTH|bool or
EDXAPP_CMS_ENABLE_BASIC_AUTH|bool or
EDXAPP_LMS_ENABLE_BASIC_AUTH|bool or
EDXAPP_LMS_PREVIEW_ENABLE_BASIC_AUTH|bool or
KIBANA_ENABLE_BASIC_AUTH|bool or
PROGRAMS_ENABLE_BASIC_AUTH|bool or
XQUEUE_ENABLE_BASIC_AUTH|bool or
XSERVER_ENABLE_BASIC_AUTH|bool
}}
...@@ -227,7 +227,7 @@ ...@@ -227,7 +227,7 @@
password={{ item.password }} password={{ item.password }}
state={{ item.state }} state={{ item.state }}
path={{ nginx_htpasswd_file }} path={{ nginx_htpasswd_file }}
when: COMMON_ENABLE_BASIC_AUTH when: NGINX_CREATE_HTPASSWD_FILE
tags: tags:
- install - install
- install:configuration - install:configuration
......
{% if COMMON_ENABLE_BASIC_AUTH %}
satisfy any; satisfy any;
allow 127.0.0.1; allow 127.0.0.1;
...@@ -14,4 +13,3 @@ ...@@ -14,4 +13,3 @@
index index.html index index.html
proxy_set_header X-Forwarded-Proto https; proxy_set_header X-Forwarded-Proto https;
{% endif %}
...@@ -3,8 +3,9 @@ server { ...@@ -3,8 +3,9 @@ server {
location / { location / {
root {{ CERTS_WEB_ROOT }}; root {{ CERTS_WEB_ROOT }};
{% if CERTS_ENABLE_BASIC_AUTH|bool %}
{% include "basic-auth.j2" %} {% include "basic-auth.j2" %}
{% endif %}
try_files $uri $uri/valid.html =404; try_files $uri $uri/valid.html =404;
} }
} }
...@@ -101,7 +101,9 @@ error_page {{ k }} {{ v }}; ...@@ -101,7 +101,9 @@ error_page {{ k }} {{ v }};
} }
location / { location / {
{% if EDXAPP_CMS_ENABLE_BASIC_AUTH|bool %}
{% include "basic-auth.j2" %} {% include "basic-auth.j2" %}
{% endif %}
try_files $uri @proxy_to_cms_app; try_files $uri @proxy_to_cms_app;
} }
......
...@@ -63,6 +63,9 @@ server { ...@@ -63,6 +63,9 @@ server {
} }
location / { location / {
{% if ECOMMERCE_ENABLE_BASIC_AUTH|bool %}
{% include "basic-auth.j2" %}
{% endif %}
try_files $uri @proxy_to_app; try_files $uri @proxy_to_app;
} }
......
...@@ -57,7 +57,9 @@ server { ...@@ -57,7 +57,9 @@ server {
error_log {{ nginx_log_dir }}/kibana.error.log error; error_log {{ nginx_log_dir }}/kibana.error.log error;
# Access restriction # Access restriction
{% if KIBANA_ENABLE_BASIC_AUTH|bool %}
{% include "basic-auth.j2" %} {% include "basic-auth.j2" %}
{% endif %}
# Set image format types to expire in a very long time # Set image format types to expire in a very long time
location ~* ^.+\.(jpg|jpeg|gif|png|ico)$ { location ~* ^.+\.(jpg|jpeg|gif|png|ico)$ {
......
...@@ -37,8 +37,9 @@ server { ...@@ -37,8 +37,9 @@ server {
} }
location / { location / {
{% if EDXAPP_LMS_PREVIEW_ENABLE_BASIC_AUTH|bool %}
{% include "basic-auth.j2" %} {% include "basic-auth.j2" %}
{% endif %}
try_files $uri @proxy_to_lms-preview_app; try_files $uri @proxy_to_lms-preview_app;
} }
......
...@@ -119,7 +119,9 @@ error_page {{ k }} {{ v }}; ...@@ -119,7 +119,9 @@ error_page {{ k }} {{ v }};
} }
location / { location / {
{% if EDXAPP_LMS_ENABLE_BASIC_AUTH|bool %}
{% include "basic-auth.j2" %} {% include "basic-auth.j2" %}
{% endif %}
{% if NGINX_EDXAPP_EMBARGO_CIDRS -%} {% if NGINX_EDXAPP_EMBARGO_CIDRS -%}
if ( $embargo ) { if ( $embargo ) {
return 302 /embargo; return 302 /embargo;
...@@ -206,7 +208,9 @@ error_page {{ k }} {{ v }}; ...@@ -206,7 +208,9 @@ error_page {{ k }} {{ v }};
error_page 503 = /server/rate-limit.html; error_page 503 = /server/rate-limit.html;
{%- endif -%} {%- endif -%}
{% if EDXAPP_LMS_ENABLE_BASIC_AUTH|bool %}
{%- include "basic-auth.j2" %} {%- include "basic-auth.j2" %}
{% endif %}
try_files $uri @proxy_to_lms_app; try_files $uri @proxy_to_lms_app;
} }
......
...@@ -79,6 +79,9 @@ server { ...@@ -79,6 +79,9 @@ server {
} }
location / { location / {
{% if PROGRAMS_ENABLE_BASIC_AUTH|bool %}
{% include "basic-auth.j2" %}
{% endif %}
try_files $uri @proxy_to_app; try_files $uri @proxy_to_app;
} }
......
...@@ -8,7 +8,9 @@ server { ...@@ -8,7 +8,9 @@ server {
listen {{ XQUEUE_NGINX_PORT }} default_server; listen {{ XQUEUE_NGINX_PORT }} default_server;
location / { location / {
{% if XQUEUE_ENABLE_BASIC_AUTH|bool %}
{% include "basic-auth.j2" %} {% include "basic-auth.j2" %}
{% endif %}
try_files $uri @proxy_to_app; try_files $uri @proxy_to_app;
} }
......
...@@ -18,7 +18,9 @@ server { ...@@ -18,7 +18,9 @@ server {
listen {{ XSERVER_NGINX_PORT }} default_server; listen {{ XSERVER_NGINX_PORT }} default_server;
location / { location / {
{% if XSERVER_ENABLE_BASIC_AUTH|bool %}
{% include "basic-auth.j2" %} {% include "basic-auth.j2" %}
{% endif %}
try_files $uri @proxy_to_app; try_files $uri @proxy_to_app;
} }
......
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