ansible/awx

awx cli prompt for password

Open

#7.209 geöffnet am 1. Juni 2020

Auf GitHub ansehen
 (0 Kommentare) (3 Reaktionen) (0 zugewiesene Personen)Python (3.333 Forks)batch import
component:clihelp wantedtype:enhancement

Repository-Metriken

Stars
 (13.071 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 24T 6h) (30 gemergte PRs in 30 T)

Beschreibung

ISSUE TYPE
  • Awx cli tool should have the option to prompt a user for their password to avoid entering a password in plain visible text on the command line.
SUMMARY

The awx cli tool can take a password as a command line argument or an environment variable. Both options require a user to enter and possibly store their password in plain text. This not only poses a security concern, it makes it difficult to properly escape special characters if present. An option to prompt a user to enter their password in a manner that won't be echoed to the terminal should alleviate this.

I personally got around this by modifying the awxkit/cli/client.py with the following:

from getpass import getpass
...
    def get_config(self, key):
        """Helper method for looking up the value of a --conf.xyz flag"""
        if key == 'password':
            if getattr(self.args, 'conf.{}'.format(key)) == 'ask':
                password = getpass("Enter your password: ")
                return password
            else: 
               return getattr(self.args, 'conf.{}'.format(key))
        else:
            return getattr(self.args, 'conf.{}'.format(key))

I don't think the method above is ideal, but it works for my immediate needs. And has the desired effect on the command line.

edit to include conditional return when key == 'password' and is not set to 'ask'

Contributor Guide