You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+41Lines changed: 41 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -148,6 +148,46 @@ Inertia Django ships with a custom JsonEncoder at `inertia.utils.InertiaJsonEnco
148
148
`DjangoJSONEncoder` with additional logic to handle encoding models and Querysets. If you have other json
149
149
encoding logic you'd prefer, you can set a new JsonEncoder via the settings.
150
150
151
+
### History Encryption
152
+
153
+
Inertia.js supports [history encryption](https://inertiajs.com/history-encryption) to protect sensitive data in the browser's history state. This is useful when your pages contain sensitive information that shouldn't be stored in plain text in the browser's history. This feature requires HTTPS since it relies on `window.crypto.subtle` which is only available in secure contexts.
154
+
155
+
You can enable history encryption globally via the `INERTIA_ENCRYPT_HISTORY` setting in your `settings.py`:
156
+
157
+
```python
158
+
INERTIA_ENCRYPT_HISTORY=True
159
+
```
160
+
161
+
For more granular control, you can enable encryption on specific views:
162
+
163
+
```python
164
+
from inertia import encrypt_history, inertia
165
+
166
+
@inertia('TestComponent')
167
+
defencrypt_history_test(request):
168
+
encrypt_history(request)
169
+
return {}
170
+
171
+
# If you have INERTIA_ENCRYPT_HISTORY = True but want to disable encryption for specific views:
172
+
@inertia('PublicComponent')
173
+
defpublic_view(request):
174
+
encrypt_history(request, False) # Explicitly disable encryption for this view
175
+
return {}
176
+
```
177
+
178
+
When users log out, you might want to clear the history to ensure no sensitive data can be accessed. You can do this by extending the logout view:
179
+
180
+
```python
181
+
from inertia import clear_history
182
+
from django.contrib.auth import views as auth_views
0 commit comments