Repository: freedomofpress/securedrop

Issue:
Reset identity via Torbutton both after using SecureDrop
It would be good to instruct everyone accessing the SecureDrop web interface to reset their identity after visiting the page. Even though Tor Browser does isolate most of it's state between sites and closes the rendezvous point circuit to once you've navigated away from a site, it's probably safest to do things this way because not everything has been wiped from memory. For example, if you press ctrl+shift+t (on Linux) after closing a tab, Tor Browser will re-open it. So it would be best practice to reset identity after using SD if you wish to continue using Tor Browsers.



Discussion:
@fowlslegs Either reset identity via TorButton, or just quit the browser (not just close the window) when they're done. Remember when bank and credit card processor websites would tell you to do that? That was so your session cookies would get cleared by the browser shutdown. It was always kind of stupid when they did it, but it makes more sense in our weird use case where cookies with `Expires:` might actually be more of a forensic risk than session cookies.

We could add a message encouraging either a reset or a full browser shutdown after a source logs out, which is being added in #1165.

As far as choosing between resetting identity or shutting the browser down, I'm not sure which is better. "Reset Identity" is a nicer user experience, IMO, since it brings that back into a "fresh" Tor Browser.


Resolving patch:
diff --git a/securedrop/source.py b/securedrop/source.py
--- a/securedrop/source.py
+++ b/securedrop/source.py
@@ -9,7 +9,7 @@
 from threading import Thread
 import operator
 from flask import (Flask, request, render_template, session, redirect, url_for,
-                   flash, abort, g, send_file)
+                   flash, abort, g, send_file, Markup)
 from flask_wtf.csrf import CsrfProtect
 from flask.ext.assets import Environment
 
@@ -394,11 +394,18 @@ def login():
             flash("Sorry, that is not a recognized codename.", "error")
     return render_template('login.html')
 
+
 @app.route('/logout')
 def logout():
     if logged_in():
         session.clear()
-        flash("Thank you for logging out.", "notification")
+        tor_msg = Markup("""<strong>Important:</strong> Thank you for logging out.
+                         Please fully end your session by restarting
+                         Tor Browser: Click the <img src='static/i/toronion.png'
+                         alt='Tor icon' /> Tor onion icon in the toolbar above,
+                         click <strong>  New Identity</strong> and click
+                         <strong>Yes</strong> in the dialog box that appears.""")
+        flash(tor_msg, "error")
 
     return redirect(url_for('index'))
         


Test patch:
diff --git a/securedrop/tests/functional/source_navigation_steps.py b/securedrop/tests/functional/source_navigation_steps.py
--- a/securedrop/tests/functional/source_navigation_steps.py
+++ b/securedrop/tests/functional/source_navigation_steps.py
@@ -62,5 +62,5 @@ def _source_submits_a_message(self):
 
     def _source_logs_out(self):
         logout_button = self.driver.find_element_by_id('logout').click()
-        notification = self.driver.find_element_by_css_selector('p.notification')
+        notification = self.driver.find_element_by_css_selector('p.error')
         self.assertIn('Thank you for logging out.', notification.text)