Skip to content

Commit a799fa8

Browse files
committed
Prompt for credentials when creating Admin acct
When Meza creates an Admin account, whether for the initial 'demo' or for any new wiki, prompt for the secure password and do not log it. This way it is only known to the user, and not a vulnerability. Note: the way that this is executed in the role hierarchy is that verify-wiki runs import-wiki-sql tasks for new wikis, which in turn runs init-wiki tasks. Since 'init-wiki.yml' ONLY creates an Admin account it was renamed 'create-admin-account.yml' Fixes Issue #217
1 parent de0798e commit a799fa8

File tree

3 files changed

+55
-10
lines changed

3 files changed

+55
-10
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
3+
# Renamed the file to create-admin-account.yml since that is its only purpose.
4+
# This task file is only included when initializing new wikis.
5+
# Prompt for secure admin password for Demo Wiki
6+
- name: Prompt for Admin password on Demo Wiki
7+
ansible.builtin.pause:
8+
prompt: |
9+
10+
Creating Admin user for Demo Wiki ({{ wiki_id }})
11+
12+
MediaWiki Password Requirements:
13+
- Minimum 8 characters
14+
- Must contain at least one uppercase letter
15+
- Must contain at least one lowercase letter
16+
- Must contain at least one number
17+
- Must contain at least one special character (!@#$%^&*()_+-=[]{}|;:,.<>?)
18+
- Cannot contain spaces
19+
20+
Enter a secure password for the Admin user
21+
echo: false
22+
register: admin_password_prompt
23+
run_once: true
24+
when: wiki_id == "demo"
25+
26+
# Validate password meets MediaWiki requirements
27+
- name: Validate Admin password meets requirements
28+
ansible.builtin.fail:
29+
msg: |
30+
Password does not meet MediaWiki requirements:
31+
- Must be at least 8 characters long
32+
- Must contain uppercase, lowercase, number, and special character
33+
- Cannot contain spaces
34+
when:
35+
- wiki_id == "demo"
36+
- >
37+
admin_password_prompt.user_input | length < 8 or
38+
admin_password_prompt.user_input is not regex('[A-Z]') or
39+
admin_password_prompt.user_input is not regex('[a-z]') or
40+
admin_password_prompt.user_input is not regex('[0-9]') or
41+
admin_password_prompt.user_input is not regex('[!@#$%^&*()_+\-=\[\]{}|;:,.<>?]') or
42+
' ' in admin_password_prompt.user_input
43+
run_once: true
44+
45+
# Create an admin user for Demo Wiki with the provided secure password
46+
# https://www.mediawiki.org/wiki/Manual:CreateAndPromote.php
47+
# https://meta.wikimedia.org/wiki/Password_policy
48+
- name: Create Admin user on Demo Wiki
49+
ansible.builtin.shell: >
50+
WIKI={{ wiki_id | quote }} {{ m_mediawiki | quote }}/maintenance/run createAndPromote --force --sysop --bureaucrat Admin {{ admin_password_prompt.user_input | quote }}
51+
run_once: true
52+
when: wiki_id == "demo"
53+
no_log: true

src/roles/verify-wiki/tasks/import-wiki-sql.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@
119119
#
120120
# SECTION: init new wiki
121121
#
122-
- name: "{{ wiki_id }} - Include init-wiki.yml only when a new wiki created (but not imported)"
123-
include_tasks: init-wiki.yml
122+
- name: "Include create-admin-account.yml for a new (not imported) wiki - {{ wiki_id }}"
123+
include_tasks: create-admin-account.yml
124124
when: created_new_wiki
125125

126126

src/roles/verify-wiki/tasks/init-wiki.yml

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)