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

Add environment variable REDIS_PASSWORD #370

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ need to change this.

``REDIS_PORT``: is the port redis is serving on, defaults to 6379

``REDIS_PASSWORD``: in certain environments authtentication may be a requirement. Defaults to ``"None"``

``SNAPPASS_REDIS_DB``: is the database that you want to use on this redis server. Defaults to db 0

``REDIS_URL``: (optional) will be used instead of ``REDIS_HOST``, ``REDIS_PORT``, and ``SNAPPASS_REDIS_DB`` to configure the Redis client object. For example: redis://username:password@localhost:6379/0
Expand Down Expand Up @@ -197,10 +199,10 @@ To check if a password exists, send a HEAD request to ``/api/v2/passwords/<token
$ curl --head http://localhost:5000/api/v2/passwords/snappassbedf19b161794fd288faec3eba15fa41~hHnILpQ50ZfJc3nurDfHCb_22rBr5gGEya68e_cZOrY%3D

If :
- the passwork_key is valid
- the passwork_key is valid
- the password :
- exists,
- has not been read
- has not been read
- is not expired

Then the API will return a 200 (OK) response like so:
Expand All @@ -224,7 +226,7 @@ Otherwise, the API will return a 404 (Not Found) response like so:
Content-Type: text/html; charset=utf-8
Content-Length: 0
Connection: close


Read a password
"""""""""""""""
Expand All @@ -236,10 +238,10 @@ To read a password, send a GET request to ``/api/v2/passwords/<password_key>``,
$ curl -X GET http://localhost:5000/api/v2/passwords/snappassbedf19b161794fd288faec3eba15fa41~hHnILpQ50ZfJc3nurDfHCb_22rBr5gGEya68e_cZOrY%3D

If :
- the token is valid
- the token is valid
- the password :
- exists
- has not been read
- has not been read
- is not expired

Then the API will return a 200 (OK) with a JSON response containing the password :
Expand Down
3 changes: 2 additions & 1 deletion snappass/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ def get_locale():
else:
redis_host = os.environ.get('REDIS_HOST', 'localhost')
redis_port = os.environ.get('REDIS_PORT', 6379)
redis_password = os.environ.get('REDIS_PASSWORD', 'None')
redis_db = os.environ.get('SNAPPASS_REDIS_DB', 0)
redis_client = redis.StrictRedis(
host=redis_host, port=redis_port, db=redis_db)
host=redis_host, port=redis_port, db=redis_db, password=redis_password)
REDIS_PREFIX = os.environ.get('REDIS_PREFIX', 'snappass')

TIME_CONVERSION = {'two weeks': 1209600, 'week': 604800, 'day': 86400,
Expand Down