GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: HTTP BasicAuth setting · getstackhead/stackhead@8d6c73f

This repository was archived by the owner on Feb 26, 2024. It is now read-only.

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • ansible
    • roles
      • config_nginx
        • defaults
          • main.yml
        • tasks
          • main.yml
        • vars
          • main.yml
      • stackhead_project/tasks
        • setup-containerapp.yml
        • setup-nativeapp.yml
      • stackhead_setup/tasks
        • main.yml
        • setup-auth.yml
    • templates
      • nginx-vhost.j2
  • validation
    • examples/valid
      • docker_project-secured.yml
      • native_project-secured.yml
    • schema
      • project-definition.schema.json
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎ansible/roles/config_nginx/defaults/main.yml‎

Copy file name to clipboard
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
---
22
nginx_vhost_template: "{{ playbook_dir }}/templates/nginx-vhost.j2"
3+
nginx_basicauth_title: "Restricted area"
Collapse file

‎ansible/roles/config_nginx/tasks/main.yml‎

Copy file name to clipboardExpand all lines: ansible/roles/config_nginx/tasks/main.yml
+19Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,25 @@
33
include_vars: "{{ ansible_os_family }}.yml"
44
ignore_errors: yes
55

6+
- set_fact:
7+
has_basic_auth: "{{ nginx_auth_basic is defined and nginx_auth_basic | length > 0 }}"
8+
htpasswd_path: "{{ nginx_htpasswd_path }}/.{{ nginx_project_name }}"
9+
10+
- name: Write BasicAuth data
11+
htpasswd:
12+
path: "{{ htpasswd_path }}"
13+
name: "{{ item.username }}"
14+
password: "{{ item.password }}"
15+
state: present
16+
when: item.type == 'basic'
17+
with_items: "{{ nginx_auth_basic }}"
18+
19+
- name: Remove BasicAuth file
20+
file:
21+
path: "{{ htpasswd_path }}"
22+
state: absent
23+
when: not has_basic_auth
24+
625
- name: Add managed vhost config files.
726
template:
827
src: "{{ nginx_vhost_template }}"
Collapse file

‎ansible/roles/config_nginx/vars/main.yml‎

Copy file name to clipboardExpand all lines: ansible/roles/config_nginx/vars/main.yml
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
# OS-specific variables see other yml files in this directory
33
root_group: root
44
nginx_vhost_path: /etc/nginx/sites-enabled
5+
nginx_htpasswd_path: /etc/nginx/passwd
Collapse file

‎ansible/roles/stackhead_project/tasks/setup-containerapp.yml‎

Copy file name to clipboardExpand all lines: ansible/roles/stackhead_project/tasks/setup-containerapp.yml
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
include_role:
1515
name: config_nginx
1616
vars:
17+
nginx_project_name: "{{ project_name }}"
1718
nginx_vhost_template: "{{ playbook_dir }}/templates/nginx-vhost.reverse-proxy.j2"
19+
nginx_auth_basic: "{{ app_config.security.authentication|default([]) }}"
1820
nginx_vhosts:
1921
- server_name: "{{ app_config.domain }}"
2022
use_https: 1
Collapse file

‎ansible/roles/stackhead_project/tasks/setup-nativeapp.yml‎

Copy file name to clipboardExpand all lines: ansible/roles/stackhead_project/tasks/setup-nativeapp.yml
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
include_role:
1111
name: config_nginx
1212
vars:
13+
nginx_project_name: "{{ project_name }}"
1314
nginx_vhost_template: "{{ playbook_dir }}/templates/nginx-vhost.native.j2"
15+
nginx_auth_basic: "{{ app_config.security.authentication|default([]) }}"
1416
nginx_use_php: "{{ native_php_enabled }}"
1517
nginx_vhosts:
1618
- server_name: "{{ app_config.domain }}"
Collapse file

‎ansible/roles/stackhead_setup/tasks/main.yml‎

Copy file name to clipboardExpand all lines: ansible/roles/stackhead_setup/tasks/main.yml
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
- import_tasks: "roles/stackhead_setup/tasks/setup-user.yml"
1313

14+
- import_tasks: "roles/stackhead_setup/tasks/setup-auth.yml"
15+
1416
- import_tasks: "roles/stackhead_setup/tasks/setup-nginx.yml"
1517

1618
- import_tasks: "roles/stackhead_setup/tasks/setup-docker.yml"
Collapse file

‎ansible/roles/stackhead_setup/tasks/setup-auth.yml‎

Copy file name to clipboard
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
- name: Install passlib dependency for htpasswd generation
3+
pip:
4+
name: passlib
5+
state: present
Collapse file

‎ansible/templates/nginx-vhost.j2‎

Copy file name to clipboardExpand all lines: ansible/templates/nginx-vhost.j2
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,12 @@ server {
3535
client_max_body_size 10G;
3636
{% endif %}
3737

38+
{% if nginx_auth_basic is defined and nginx_auth_basic | length > 0 %}
39+
location / {
40+
auth_basic "{{ nginx_basicauth_title }}";
41+
auth_basic_user_file "{{ nginx_htpasswd_path }}/.{{ nginx_project_name }}";
42+
}
43+
{% endif %}
44+
3845
{% block location %}{% endblock %}
3946
}
Collapse file

‎validation/examples/valid/docker_project-secured.yml‎

Copy file name to clipboard
+40Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
domain: mydomain.com
3+
security:
4+
authentication:
5+
- type: basic
6+
username: user
7+
password: pass
8+
deployment:
9+
type: container
10+
settings:
11+
expose:
12+
service: app
13+
port: 8080
14+
registries:
15+
- username: dockerhubuser
16+
password: dockerhubpassword
17+
- username: privateuser
18+
password: privatepassword
19+
url: https://myprivateregistry.tld
20+
services:
21+
- name: app
22+
image: getstackhead/project-demo-php
23+
user: "1000:1000"
24+
volumes:
25+
- type: global
26+
src: assets
27+
dest: /var/www/public/assets
28+
- type: local
29+
src: log
30+
dest: /var/www/public/log
31+
- type: custom
32+
src: /etc/secrets.txt
33+
dest: /var/www/secrets.txt
34+
mode: ro
35+
links:
36+
- db
37+
- name: db
38+
image: mariadb:10.5
39+
environment:
40+
MYSQL_ROOT_PASSWORD: example
Collapse file

‎validation/examples/valid/native_project-secured.yml‎

Copy file name to clipboard
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
domain: mydomain.com
3+
security:
4+
authentication:
5+
- type: basic
6+
username: user
7+
password: pass
8+
deployment:
9+
type: native
10+
settings:
11+
public_path: public
12+
capabilities:
13+
php:
14+
version: 7.3

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.