diff --git a/trac/env.py b/trac/env.py
|
a
|
b
|
|
| 99 | 99 | `base_url` setting also for redirects. This introduces the obvious |
| 100 | 100 | limitation that this environment will only be usable when accessible |
| 101 | 101 | from that URL, as redirects are frequently used. ''(since 0.10.5)''""") |
| | 102 | |
| | 103 | secure_cookies = BoolOption('trac', 'secure_cookies', False, |
| | 104 | """Restrict cookies to HTTPS connections. |
| | 105 | |
| | 106 | When true, set the `secure` flag on all cookies so that they are |
| | 107 | only sent to the server on HTTPS connections. Use this if your Trac |
| | 108 | instance is only accessible through HTTPS. (''since 0.11.2'')""") |
| 102 | 109 | |
| 103 | 110 | project_name = Option('project', 'name', 'My Project', |
| 104 | 111 | """Name of the project.""") |
diff --git a/trac/web/auth.py b/trac/web/auth.py
|
a
|
b
|
|
| 144 | 144 | req.authname = remote_user |
| 145 | 145 | req.outcookie['trac_auth'] = cookie |
| 146 | 146 | req.outcookie['trac_auth']['path'] = req.base_path or '/' |
| | 147 | if self.env.secure_cookies: |
| | 148 | req.outcookie['trac_auth']['secure'] = True |
| 147 | 149 | |
| 148 | 150 | def _do_logout(self, req): |
| 149 | 151 | """Log the user out. |
| … |
… |
|
| 175 | 177 | req.outcookie['trac_auth'] = '' |
| 176 | 178 | req.outcookie['trac_auth']['path'] = req.base_path or '/' |
| 177 | 179 | req.outcookie['trac_auth']['expires'] = -10000 |
| | 180 | if self.env.secure_cookies: |
| | 181 | req.outcookie['trac_auth']['secure'] = True |
| 178 | 182 | |
| 179 | 183 | def _get_name_for_cookie(self, req, cookie): |
| 180 | 184 | db = self.env.get_db_cnx() |
diff --git a/trac/web/main.py b/trac/web/main.py
|
a
|
b
|
|
| 280 | 280 | else: |
| 281 | 281 | req.outcookie['trac_form_token'] = hex_entropy(24) |
| 282 | 282 | req.outcookie['trac_form_token']['path'] = req.base_path or '/' |
| | 283 | if self.env.secure_cookies: |
| | 284 | req.outcookie['trac_form_token']['secure'] = True |
| 283 | 285 | return req.outcookie['trac_form_token'].value |
| 284 | 286 | |
| 285 | 287 | def _pre_process_request(self, req, chosen_handler): |
diff --git a/trac/web/session.py b/trac/web/session.py
|
a
|
b
|
|
| 154 | 154 | self.req.outcookie[COOKIE_KEY] = self.sid |
| 155 | 155 | self.req.outcookie[COOKIE_KEY]['path'] = self.req.base_path or '/' |
| 156 | 156 | self.req.outcookie[COOKIE_KEY]['expires'] = expires |
| | 157 | if self.env.secure_cookies: |
| | 158 | self.req.outcookie[COOKIE_KEY]['secure'] = True |
| 157 | 159 | |
| 158 | 160 | def get_session(self, sid, authenticated=False): |
| 159 | 161 | refresh_cookie = False |