Ticket #8249: trac_8249-notebook_cookies.patch

File trac_8249-notebook_cookies.patch, 1.5 KB (added by mpatel, 9 years ago)

Expire cookies on logout. sagenb repo.

  • sagenb/notebook/twist.py

    # HG changeset patch
    # User Mitesh Patel <qed777@gmail.com>
    # Date 1266122240 28800
    # Node ID 4beb65b1821d85248e43ac2dd2d0a4655863770a
    # Parent  b69fa684bfc34be8813f7be7e3264270ccac1617
    #8249: Expire the notebook test and session cookies on logout
    
    diff --git a/sagenb/notebook/twist.py b/sagenb/notebook/twist.py
    a b class RedirectLogin(resource.PostableRes 
    24062406    def childFactory(self, request, name):
    24072407        return RedirectLogin()
    24082408
     2409class LogoutRedirectLogin(resource.PostableResource):
     2410    def render(self, ctx):
     2411        response = http.RedirectResponse('/')
     2412
     2413        # Force cookie deletion.
     2414        yesterday = time.time() - 3600 * 24
     2415        c1 = http_headers.Cookie('nb_session_%s' % notebook.port, '',
     2416                                 expires=yesterday)
     2417        c2 = http_headers.Cookie('cookie_test_%s' % notebook.port, '',
     2418                                 expires=yesterday)
     2419        response.headers.setHeader("set-cookie", [c1, c2])
     2420
     2421        return response
     2422
     2423    def childFactory(self, request, name):
     2424        return LogoutRedirectLogin()
     2425
    24092426import sagenb.simple.twist
    24102427
    24112428class Toplevel(resource.PostableResource):
    class AnonymousToplevel(Toplevel): 
    24552472    child_css = CSS()
    24562473    child_javascript = Javascript()
    24572474    child_java = Java()
    2458     child_logout = RedirectLogin()
     2475    child_logout = LogoutRedirectLogin()
    24592476
    24602477    def userchildFactory(self, request, name):
    24612478        # This is called from Toplevel above