{"id":343,"date":"2011-02-18T12:42:30","date_gmt":"2011-02-18T12:42:30","guid":{"rendered":"http:\/\/10sa.com\/sql_stories\/?p=343"},"modified":"2014-01-11T11:49:17","modified_gmt":"2014-01-11T11:49:17","slug":"http-authentication-digest-effective-logout-action","status":"publish","type":"post","link":"http:\/\/10sa.com\/sql_stories\/?p=343","title":{"rendered":"HTTP Authentication Digest &#8211; effective logout action"},"content":{"rendered":"<p>Using <a href=\"http:\/\/tools.ietf.org\/html\/rfc2617\">Digest Access Authentication<\/a> you probably encountered the problem with effective logout. I solved this with timeout option. My solution to this is as follows:<\/p>\n<p>MVC logout action:<\/p>\n<pre lang=\"php\">\r\npublic function logoutAction()\r\n{\r\n  $YourSessionObject->ForceLogout(True);\r\n  \/\/ the rendered page should contains automatic redirection to page for action \/auth\/login\r\n  \/\/ e.g. &lt;meta http-equiv=\"refresh\" content=\"2;url=http:\/\/domain\/auth\/login\"&gt;\r\n  $this->Render();\r\n}\r\n<\/pre>\n<p>MVC login action:<\/p>\n<pre lang=\"php\">\r\npublic function loginAction()\r\n{\r\n  $timeout = 3600;\r\n  if( $YourSessionObject->IsForcedLogout() ){\r\n    $timeout = 1;\r\n    SetInSession->ForceLogout(False);\r\n  }\r\n  \/\/ config for Zend Framework auth.\r\n  $config = array(\r\n    'accept_schemes' =>'digest',\r\n    'realm' =>Zend_Registry::get('realm'),\r\n    'digest_domains' =>'\/',\r\n    \/* IMPORTANT CHANGE *\/\r\n    'nonce_timeout' =>$timeout,\r\n  );\r\n}\r\n<\/pre>\n<p>So, the previous &#8216;authorize&#8217; data in apache header are invalid and thus http server requires to input fresh data.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Using Digest Access Authentication you probably encountered the problem with effective logout. I solved this with timeout option. My solution to this is as follows: MVC logout action: public function logoutAction() { $YourSessionObject->ForceLogout(True); \/\/ the rendered page should contains automatic redirection to page for action \/auth\/login \/\/ e.g. &lt;meta http-equiv=&#8221;refresh&#8221; content=&#8221;2;url=http:\/\/domain\/auth\/login&#8221;&gt; $this->Render(); } MVC login [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[16],"_links":{"self":[{"href":"http:\/\/10sa.com\/sql_stories\/index.php?rest_route=\/wp\/v2\/posts\/343"}],"collection":[{"href":"http:\/\/10sa.com\/sql_stories\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/10sa.com\/sql_stories\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/10sa.com\/sql_stories\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/10sa.com\/sql_stories\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=343"}],"version-history":[{"count":7,"href":"http:\/\/10sa.com\/sql_stories\/index.php?rest_route=\/wp\/v2\/posts\/343\/revisions"}],"predecessor-version":[{"id":694,"href":"http:\/\/10sa.com\/sql_stories\/index.php?rest_route=\/wp\/v2\/posts\/343\/revisions\/694"}],"wp:attachment":[{"href":"http:\/\/10sa.com\/sql_stories\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=343"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/10sa.com\/sql_stories\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=343"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/10sa.com\/sql_stories\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=343"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}