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
+35-1Lines changed: 35 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,13 +6,27 @@ It can be used even for situations where Single sign-on (SSO) is not suitable, e
6
6
This project is inspired by [django-xsession](https://github.com/badzong/django-xsession), but uses a different approach to session sharing
7
7
which sets the cookie on server-side and thus does not require reloading the page.
8
8
9
+
## How it works
10
+
11
+
1. User visits one of the configured sites
12
+
2. Session key is encrypted and included in the HTML file. This file contains `<script>` tags linking to all configured sites with encrypted session key (as part of the file name).
13
+
3. Browser requests the script files
14
+
4. On destination domain the session key is decrypted from payload and saved to cookies
Encrypted payload (containing session key, timestamp, source and destination hostname) in base64 is part of the filename itself. Destination server checks the timestamp to prevent replay attacks.
22
+
9
23
## Installation
10
24
11
25
```sh
12
26
pip install django-shared-session
13
27
```
14
28
15
-
This tool uses request inside template, so please make sure you have enabled `RequestContext` in your template engine context processors.
29
+
This tool accesses request inside template, so please make sure you have `RequestContext`enabled in your template's engine context processors.
16
30
17
31
## Usage
18
32
Add `shared_session` to `INSTALLED_APPS` and set shared session domains in Django settings file.
@@ -59,6 +73,26 @@ layout.html:
59
73
60
74
If you want to share sessions also in Django admin interface, you can overwrite `admin/base_site.html` and include the loader.
61
75
76
+
## Advanced options
77
+
78
+
`SHARED_SESSION_ALWAYS_REPLACE` – Always replace session cookie, even if the session is not empty. (default: False)
79
+
`SHARED_SESSION_TIMEOUT` – Expiration timeout. Session needs to be delivered to destination site before this time. (default: 30)
80
+
81
+
### Signals
82
+
83
+
Signal `session_replaced` is triggered when target's site session cookie was changed or created.
84
+
You can connect your own handlers to run additional functions.
0 commit comments