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

htpasswd: add "exclusive" parameter #5975

Open
1 task done
nusenu opened this issue Feb 11, 2023 · 5 comments
Open
1 task done

htpasswd: add "exclusive" parameter #5975

nusenu opened this issue Feb 11, 2023 · 5 comments
Labels
feature This issue/PR relates to a feature request module module plugins plugin (any type) web_infrastructure

Comments

@nusenu
Copy link

nusenu commented Feb 11, 2023

Summary

The htpasswd module does not provide the exclusive parameter like the authorized_keys module, this is a problem when usernames are generated randomly using a lookup (example)
because it would result in users getting added instead of getting replaced (old account still valid).

This can result in a security risk when people try to rotate their passwords by removing the local lookup folders, because
it will result in a new account being added to htpasswd instead of replacing it.

I'm proposing to add the exclusive parameter to the htpasswd module with the same semantics as in the authorized_keys module.

Issue Type

Feature Idea

Component Name

htpasswd

Additional Information

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibullbot
Copy link
Collaborator

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibullbot
Copy link
Collaborator

cc @None
click here for bot help

@ansibullbot ansibullbot added feature This issue/PR relates to a feature request module module plugins plugin (any type) web_infrastructure labels Feb 11, 2023
nusenu added a commit to nusenu/ansible-relayor that referenced this issue Feb 11, 2023
prometheus/nginx/MetricsPort integration:
with this change we move from a randomly generated
username to a static username to workaround this issue:
ansible-collections/community.general#5975

After upstream implemented the exclusive parameter we will revert this commit
and move to random usernames again.

If you used relayor's prometheus integration and htpasswd file generation
it is recommended to delete the htpasswd by default under
/etc/nginx/tor_metricsport_htpasswd
and run the playbook again to ensure
that only one entry is in that file
@russoz
Copy link
Collaborator

russoz commented Jul 3, 2023

Hi @nusenu , thanks for submitting your feature request.

On a first glance, it looks like your assumption is not true. The code that effectively changes the password is in:

It uses set_password() in newer versions of passlib or update() in older ones. According to the passlib documentation:
https://passlib.readthedocs.io/en/stable/lib/passlib.apache.html#passlib.apache.HtpasswdFile.set_password

image

So, from the documentation, it looks like the password is not added as you assumed but rather updated. The module has no tests, and I have not hand-crafted anything to verify at this point.

Has that problem actually happened to you? Thanks in advance

needs_info

@ansibullbot ansibullbot added the needs_info This issue requires further information. Please answer any outstanding questions label Jul 3, 2023
@nusenu
Copy link
Author

nusenu commented Jul 3, 2023 via email

@ansibullbot ansibullbot removed the needs_info This issue requires further information. Please answer any outstanding questions label Jul 3, 2023
@russoz
Copy link
Collaborator

russoz commented Jul 3, 2023

OK, I think I got it.

IMO the option name could be improved. Basically we want to clear the file of entries before running. I reckon that is somewhat easy to implement - if the flag is on, it would be similar to the "create new file" case.

@russoz russoz changed the title add "exclusive" parameter to htpasswd module htpasswd: add "exclusive" parameter Jul 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This issue/PR relates to a feature request module module plugins plugin (any type) web_infrastructure
Projects
None yet
Development

No branches or pull requests

3 participants