Skip to content

Commit

Permalink
Add an option for protecting sensitive parameters.
Browse files Browse the repository at this point in the history
fixes issue 18
  • Loading branch information
sjl committed Jan 30, 2010
1 parent a2de973 commit 3cce0c7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
13 changes: 13 additions & 0 deletions docs/wiki/config/index.mdown
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,19 @@ This will force all HTTP requests to use SSL. There's always a possibility, due

This will force a fallback to a non-SSL HTTP post to Hoptoad if the SSL post fails.

Hide Sensitive Request Parameters
---------------------------------

If a user submits important data (credit card numbers, for example) with a GET
or POST request and an error occurs, that data will be passed along to
Hoptoad. If you want to blank out the contents of certain parameters you can
use this option:

HOPTOAD_PROTECTED_PARAMS = ['credit_card_number', 'ssn']

Any parameter in this list will have its contents replaced with
`********************` before it is sent to Hoptoad.

Asynchronous POSTs and Request Handlers
---------------------------------------

Expand Down
11 changes: 10 additions & 1 deletion hoptoad/api/htv1.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
from django.views.debug import get_safe_settings
from django.conf import settings

from hoptoad import get_hoptoad_settings


PROTECTED_PARAMS = frozenset(get_hoptoad_settings().get('HOPTOAD_PROTECTED_PARAMS', []))

def _parse_environment(request):
"""Return an environment mapping for a notification from the given request."""
Expand Down Expand Up @@ -32,7 +36,12 @@ def _parse_request(request):
"""Return a request mapping for a notification from the given request."""
request_get = dict( (str(k), str(v)) for (k, v) in request.GET.items() )
request_post = dict( (str(k), str(v)) for (k, v) in request.POST.items() )
return request_post if request_post else request_get

data = request_post or request_get
for k in PROTECTED_PARAMS.intersection(data.keys()):
data[k] = '********************'

return data

def _parse_session(session):
"""Return a request mapping for a notification from the given session."""
Expand Down

0 comments on commit 3cce0c7

Please sign in to comment.