Index: /main/waeup.cas/trunk/waeup/cas/server.py
===================================================================
--- /main/waeup.cas/trunk/waeup/cas/server.py	(revision 10414)
+++ /main/waeup.cas/trunk/waeup/cas/server.py	(revision 10415)
@@ -286,5 +286,14 @@
 
     def logout(self, req):
-        return exc.HTTPNotImplemented()
+        url = req.GET.get('url', req.POST.get('url', None))
+        old_val = req.cookies.get('cas-tgc', None)
+        html = self._get_template('logout.html')
+        if url is not None:
+            html = self._get_template('logout_url.html')
+            html = html.replace('URL_HREF', url)
+        resp = Response(html)
+        delete_session_cookie(self.db, resp, old_val)
+        return resp
+
 
 cas_server = CASServer
Index: /main/waeup.cas/trunk/waeup/cas/templates/logout.html
===================================================================
--- /main/waeup.cas/trunk/waeup/cas/templates/logout.html	(revision 10415)
+++ /main/waeup.cas/trunk/waeup/cas/templates/logout.html	(revision 10415)
@@ -0,0 +1,8 @@
+<html>
+  <head>
+    <title>WAeUP Central Authentication Service</title>
+  </head>
+  <body>
+    <p>You have been logged out.</p>
+  </body>
+</html>
Index: /main/waeup.cas/trunk/waeup/cas/templates/logout_url.html
===================================================================
--- /main/waeup.cas/trunk/waeup/cas/templates/logout_url.html	(revision 10415)
+++ /main/waeup.cas/trunk/waeup/cas/templates/logout_url.html	(revision 10415)
@@ -0,0 +1,11 @@
+<html>
+  <head>
+    <title>WAeUP Central Authentication Service</title>
+  </head>
+  <body>
+    <p>You have been logged out.</p>
+    <p>The application you just logged out of has provided a link it
+    would like you to follow. Please <a href="URL_HREF">click here</a>
+    to access URL_HREF.
+  </body>
+</html>
Index: /main/waeup.cas/trunk/waeup/cas/tests/test_server.py
===================================================================
--- /main/waeup.cas/trunk/waeup/cas/tests/test_server.py	(revision 10414)
+++ /main/waeup.cas/trunk/waeup/cas/tests/test_server.py	(revision 10415)
@@ -104,5 +104,5 @@
         req = Request.blank('http://localhost/logout')
         resp = app(req)
-        assert resp.status == '501 Not Implemented'
+        assert resp.status == '200 OK'
 
     def test_login_simple(self):
@@ -217,4 +217,41 @@
         assert resp.status == '200 OK'
         assert b'CAS login successful' in resp.body
+
+    def test_logout_no_cookie(self):
+        # 2.3 logout displays a logout page.
+        app = CASServer()
+        req = Request.blank('https://localhost/logout')
+        resp = app(req)
+        assert resp.status == '200 OK'
+        assert b'logged out' in resp.body
+
+    def test_logout_with_cookie(self):
+        # 2.3 logout destroys any existing SSO session
+        app = CASServer()
+        tgc = create_tgc_value()
+        app.db.add(tgc)
+        value = str(tgc.value)
+        req = Request.blank('https://localhost/logout')
+        req.headers['Cookie'] = 'cas-tgc=%s' % value
+        resp = app(req)
+        assert resp.status == '200 OK'
+        assert b'logged out' in resp.body
+        assert 'Set-Cookie' in resp.headers
+        cookie = resp.headers['Set-Cookie']
+        assert cookie.startswith('cas-tgc=;')
+        assert 'expires' in cookie
+        assert 'Max-Age' in cookie
+        assert len(list(app.db.query(TicketGrantingCookie))) == 0
+
+    def test_logout_url(self):
+        # 2.3.1 with an `url` given we provide a link on logout
+        app = CASServer()
+        params = 'url=http%3A%2F%2Fwww.logout.com'
+        req = Request.blank('https://localhost/logout?%s' % params)
+        resp = app(req)
+        assert resp.status == '200 OK'
+        assert b'logged out' in resp.body
+        assert b'like you to' in resp.body
+        assert b'http://www.logout.com' in resp.body
 
 
