Read password from environment variable #229

Open
wants to merge 1 commit into
from

Conversation

Projects
None yet
3 participants
@gmanika

gmanika commented Jun 20, 2014

If the password is not provided via the command line, try to read it from the HTTPIE_PASSWORD environment variable.

This is meant as a simple way to avoid leaking the password via the process title in scripted runs.

@sigmavirus24

This comment has been minimized.

Show comment Hide comment
@sigmavirus24

sigmavirus24 Jun 20, 2014

You broke some tests. Before any serious discussion about this feature can start, you should fix them.

You broke some tests. Before any serious discussion about this feature can start, you should fix them.

@gmanika

This comment has been minimized.

Show comment Hide comment
@gmanika

gmanika Jun 20, 2014

Thanks for the feedback, and I'll investigate and fix if necessary, but unless I am misreading the Travis CI output the broken tests come from the master branch, which is currently broken, and not from this pull request.

gmanika commented Jun 20, 2014

Thanks for the feedback, and I'll investigate and fix if necessary, but unless I am misreading the Travis CI output the broken tests come from the master branch, which is currently broken, and not from this pull request.

+ 'GET', httpbin('/basic-auth/user/password'))
+ assert HTTP_OK in r
+ assert r.json == {'authenticated': True, 'user': 'user'}
+ del os.environ["HTTPIE_PASSWORD"]

This comment has been minimized.

Show comment Hide comment
@jakubroztocil

jakubroztocil Jun 29, 2014

Owner

Use try … finally to make sure del os.environ["HTTPIE_PASSWORD"] gets executed even in case of error:

os.environ["HTTPIE_PASSWORD"] = "password"
try:
    …
finally:
     del os.environ["HTTPIE_PASSWORD"]
@jakubroztocil

jakubroztocil Jun 29, 2014

Owner

Use try … finally to make sure del os.environ["HTTPIE_PASSWORD"] gets executed even in case of error:

os.environ["HTTPIE_PASSWORD"] = "password"
try:
    …
finally:
     del os.environ["HTTPIE_PASSWORD"]
@jakubroztocil

This comment has been minimized.

Show comment Hide comment
@jakubroztocil

jakubroztocil Jun 29, 2014

Owner

I believe those errors are not related to the pull request. If you rebase against current master it should be without errors.

Owner

jakubroztocil commented Jun 29, 2014

I believe those errors are not related to the pull request. If you rebase against current master it should be without errors.

@@ -201,13 +201,18 @@ def _process_auth(self):
"""
url = urlsplit(self.args.url)
+ password_from_env = os.getenv("HTTPIE_PASSWORD")

This comment has been minimized.

Show comment Hide comment
@jakubroztocil

jakubroztocil Jun 29, 2014

Owner

This should go after if not self.args.auth.has_password():

@jakubroztocil

jakubroztocil Jun 29, 2014

Owner

This should go after if not self.args.auth.has_password():

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment