Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

htdigest module feature request #23545

Closed
smacz42 opened this issue Apr 12, 2017 · 2 comments
Closed

htdigest module feature request #23545

smacz42 opened this issue Apr 12, 2017 · 2 comments
Labels
affects_2.2 This issue/PR affects Ansible v2.2 feature This issue/PR relates to a feature request. support:core This issue/PR relates to code supported by the Ansible Engineering Team.

Comments

@smacz42
Copy link

smacz42 commented Apr 12, 2017

ISSUE TYPE
  • Feature Request
COMPONENT NAME

htdigest

ANSIBLE VERSION
ansible 2.2.1.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
OS / ENVIRONMENT

Control: Arch Linux
Remote: CentOS 7

SUMMARY

When setting up an Apache (httpd) Digest authentication service, the client is unable to connect and is returned a 500 error. The logs state:

[<date>] [auth_digest:error] [pid <httpd-pid>] [client <ip-addr>:<port>] AH01780: need AuthName: /gitlist/ansible-role-common/info/refs
[<date>] [auth_digest:error] [pid <httpd-pid>] [client <ip-addr>:<port>] AH01780: need AuthName: /gitlist/ansible-role-common/info/refs
HOW THE FEATURE WOULD BE USED
gitlist_htdigest:
    - { name: test, password: hqq3Dw2UXEd9, realm: 'git repo' }
    - { name: test, password: 2n66nboz72Ha, realm: 'git repo'}

- name: (gitlist_config) [3/5] Template htpasswd is deployed
  htdigest:
    create: yes
    crypt_scheme: sha256_crypt
    name: "{{ item.name }}"
    password: "{{ item.password }}"
    realm: "{{ item.realm }}"
    path: /srv/.htpasswd
    state: present
    owner: apache
    group: apache
    mode: 640
  with_items: "{{ gitlist_htdigest }}"

Apache 2.4 config

SetEnv GIT_PROJECT_ROOT /srv/repos
SetEnv GIT_HTTP_EXPORT_ALL
SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER
<If "%{QUERY_STRING} == 'service=git-receive-pack' || %{REQUEST_URI} == '/git-receive-pack$'" >
    AuthType Digest
    AuthUserFile /srv/.htdigest
    Require valid-user
</If>
EXPECTED RESULTS

There should be a field for AuthName, as it is apparently required by Apache's AuthType system:

To implement authentication, you must also use the AuthName and Require directives.
--Apache Core Features - AuthType Directive

At least it is required for AuthType Digest.

UPSTREAM

The same library that is used for htpasswd can be used for this proposed htdigest, just using HtdigestFile instead of HtpasswdFile.

@smacz42
Copy link
Author

smacz42 commented Apr 12, 2017

Temporary work-around is to create a template and apply filters - but it only works for md5 for the time being.

tasks/main.yml

- name: (gitlist_config) [3/5] Template htdigest is deployed
  template:
    src: ../templates/htdigest.j2
    dest: /srv/.htdigest
    owner: apache
    group: apache
    mode: 0400

files/httpd.conf

[...]
<If "%{QUERY_STRING} == 'service=git-receive-pack' || %{REQUEST_URI} == '/git-receive-pack$'" >
    AuthType Digest
    AuthName: git
    AuthUserFile /srv/.htdigest
    Require valid-user
</If>
[...]

htdigest.j2

{% for user in gitlist_htdigest %}
{{ user.name }}:{{ user.realm }}:{{ user.password }}
{% endfor %}

defaults/main.yml

vault_gitlist_htdigest:
    - name: smacz
      realm: git
      password: "{{ 'smacz:git:hqq3Dw2UXEd9'|hash('md5') }}"
    - name: test
      realm: git
      password: "{{ 'test:git:2n66nboz72Ha'|hash('md5') }}"

@ansibot ansibot added affects_2.2 This issue/PR affects Ansible v2.2 feature_idea needs_triage Needs a first human triage before being processed. labels Apr 13, 2017
@nitzmahone nitzmahone removed the needs_triage Needs a first human triage before being processed. label Apr 13, 2017
@ansibot ansibot added the support:core This issue/PR relates to code supported by the Ansible Engineering Team. label Jun 29, 2017
@ansibot ansibot added feature This issue/PR relates to a feature request. and removed feature_idea labels Mar 2, 2018
@samdoran
Copy link
Contributor

samdoran commented Aug 2, 2019

Closing per above solution to use template.

@samdoran samdoran closed this as completed Aug 2, 2019
@ansible ansible locked and limited conversation to collaborators Aug 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.2 This issue/PR affects Ansible v2.2 feature This issue/PR relates to a feature request. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

No branches or pull requests

4 participants