-
如果您的其中一個視圖接收到
容易包含敏感信息的POST parameters對象,您可以使用HttpRequestsensitive_post_parameters裝飾器阻止這些參數的值包含在錯誤報告中:from django.views.decorators.debug import sensitive_post_parameters @sensitive_post_parameters('pass_word', 'credit_card_number') def record_user_profile(request): UserProfile.create( user=request.user, password=request.POST['pass_word'], credit_card=request.POST['credit_card_number'], name=request.POST['name'], ) ...在上麵的示例中,
pass_word和credit_card_numberPOST 參數的值將被隱藏並替換為錯誤報告中請求表示中的星號 (**********),而name參數的值將是披露。要在錯誤報告中係統地隱藏請求的所有 POST 參數,請不要向
sensitive_post_parameters裝飾器提供任何參數:@sensitive_post_parameters() def my_view(request): ...對於某些
視圖(django.contrib.auth.viewslogin、password_reset_confirm、password_change和authadmin 中的add_view和user_change_password),所有 POST 參數都係統地從錯誤報告中過濾出來,以防止敏感信息泄漏用戶密碼等信息。
本文介紹django.views.decorators.debug.sensitive_post_parameters的用法。
聲明
sensitive_post_parameters(*parameters)
相關用法
- Python Django sensitive_variables用法及代碼示例
- Python dict setdefault()用法及代碼示例
- Python seaborn.swarmplot()用法及代碼示例
- Python seaborn.residplot()用法及代碼示例
- Python calendar setfirstweekday()用法及代碼示例
- Python Django serve用法及代碼示例
- Python seaborn.regplot()用法及代碼示例
- Python seaborn.PairGrid()用法及代碼示例
- Python set clear()用法及代碼示例
- Python Tableau server_info.get用法及代碼示例
- Python Pandas series.cummax()用法及代碼示例
- Python seaborn.boxenplot()用法及代碼示例
- Python Pandas series.cumprod()用法及代碼示例
- Python Django set用法及代碼示例
- Python seaborn.pairplot()用法及代碼示例
- Python OpenCV setWindowTitle()用法及代碼示例
- Python seaborn.factorplot()用法及代碼示例
- Python seaborn.FacetGrid()用法及代碼示例
- Python seaborn.lineplot()用法及代碼示例
- Python seaborn.lmplot()用法及代碼示例
- Python set()用法及代碼示例
- Python setattr()用法及代碼示例
- Python set copy()用法及代碼示例
- Python seaborn.pointplot()用法及代碼示例
- Python set add()用法及代碼示例
注:本文由純淨天空篩選整理自djangoproject.com大神的英文原創作品 django.views.decorators.debug.sensitive_post_parameters。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
