Skip to content

Commit df98f1a

Browse files
kutysamgdzien
authored andcommitted
Allow auth basic to be added to global (server) (#125)
* Add auth basic for global level * Change auth_basic_file to auth_basic_user_file
1 parent 898c5a5 commit df98f1a

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,8 @@ nginx_http_template:
330330
root: /usr/share/nginx/html
331331
https_redirect: false
332332
autoindex: false
333+
auth_basic: null
334+
auth_basic_user_file: null
333335
#auth_request: /auth
334336
ssl:
335337
cert: /etc/ssl/certs/default.crt
@@ -346,7 +348,7 @@ nginx_http_template:
346348
html_file_name: index.html
347349
autoindex: false
348350
auth_basic: null
349-
auth_basic_file: null
351+
auth_basic_user_file: null
350352
#auth_req: /auth
351353
#returns:
352354
#return302:
@@ -432,7 +434,7 @@ nginx_http_template:
432434
proxy_redirect: false
433435
websocket: false
434436
auth_basic: null
435-
auth_basic_file: null
437+
auth_basic_user_file: null
436438
#auth_req: /auth
437439
#returns:
438440
#return302:

defaults/main.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ nginx_http_template:
172172
root: /usr/share/nginx/html
173173
https_redirect: false
174174
autoindex: false
175+
auth_basic: null
176+
auth_basic_user_file: null
175177
try_files: $uri $uri/index.html $uri.html =404
176178
#auth_request: /auth
177179
ssl:
@@ -190,7 +192,7 @@ nginx_http_template:
190192
html_file_name: index.html
191193
autoindex: false
192194
auth_basic: null
193-
auth_basic_file: null
195+
auth_basic_user_file: null
194196
try_files: $uri $uri/index.html $uri.html =404
195197
#auth_request: /auth
196198
#returns:
@@ -273,7 +275,7 @@ nginx_http_template:
273275
- Cache-Control
274276
websocket: false
275277
auth_basic: null
276-
auth_basic_file: null
278+
auth_basic_user_file: null
277279
try_files: $uri $uri/index.html $uri.html =404
278280
#auth_req: /auth
279281
#returns:

templates/http/default.conf.j2

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ server {
7474
listen {{ item.value.port }};
7575
{% endif %}
7676
server_name {{ item.value.server_name }};
77+
{% if item.value.auth_basic is defined and item.value.auth_basic %}
78+
auth_basic "{{ item.value.auth_basic }}";
79+
{% endif %}
80+
{% if item.value.auth_basic_user_file is defined and item.value.auth_basic_user_file %}
81+
auth_basic_user_file {{ item.value.auth_basic_user_file }};
82+
{% endif %}
7783
{% if item.value.root is defined and item.value.root %}
7884
root {{ item.value.root }};
7985
{% endif %}
@@ -102,8 +108,8 @@ server {
102108
{% if item.value.reverse_proxy.locations[location].auth_basic is defined and item.value.reverse_proxy.locations[location].auth_basic %}
103109
auth_basic "{{ item.value.reverse_proxy.locations[location].auth_basic }}";
104110
{% endif %}
105-
{% if item.value.reverse_proxy.locations[location].auth_basic_file is defined and item.value.reverse_proxy.locations[location].auth_basic_file %}
106-
auth_basic_user_file {{ item.value.reverse_proxy.locations[location].auth_basic_file }};
111+
{% if item.value.reverse_proxy.locations[location].auth_basic_user_file is defined and item.value.reverse_proxy.locations[location].auth_basic_user_file %}
112+
auth_basic_user_file {{ item.value.reverse_proxy.locations[location].auth_basic_user_file }};
107113
{% endif %}
108114
{% if item.value.reverse_proxy.locations[location].returns is defined %}
109115
{% for code in item.value.reverse_proxy.locations[location].returns %}
@@ -229,8 +235,8 @@ server {
229235
{% if item.value.web_server.locations[location].auth_basic is defined and item.value.web_server.locations[location].auth_basic %}
230236
auth_basic "{{ item.value.web_server.locations[location].auth_basic }}";
231237
{% endif %}
232-
{% if item.value.web_server.locations[location].auth_basic_file is defined and item.value.web_server.locations[location].auth_basic_file %}
233-
auth_basic_user_file {{ item.value.web_server.locations[location].auth_basic_file }};
238+
{% if item.value.web_server.locations[location].auth_basic_user_file is defined and item.value.web_server.locations[location].auth_basic_user_file %}
239+
auth_basic_user_file {{ item.value.web_server.locations[location].auth_basic_user_file }};
234240
{% endif %}
235241
{% if item.value.web_server.locations[location].auth_request is defined %}
236242
auth_request {{ item.value.web_server.locations[location].auth_request }};

0 commit comments

Comments
 (0)