{"id":122,"date":"2004-04-12T16:43:54","date_gmt":"2004-04-12T22:43:54","guid":{"rendered":"http:\/\/www.mooreds.com\/wordpress\/?p=122"},"modified":"2004-04-12T16:43:54","modified_gmt":"2004-04-12T22:43:54","slug":"is-transparent-access-control-worth-unintelligible-error-messages","status":"publish","type":"post","link":"https:\/\/www.mooreds.com\/wordpress\/archives\/122","title":{"rendered":"Is transparent access control worth unintelligible error messages?"},"content":{"rendered":"<p>Partly egged on by <a href='http:\/\/jroller.com\/page\/rkischuk\/20040226'>Rob<\/a> and <a href='http:\/\/www.jroller.com\/page\/voidmain'>Brian<\/a>, I just took a long overdue look at container managed security for web applications.<\/p>\n<p>My conclusion: it&#8217;s nice, but there is one major flaw that dooms the whole premise.  Users expect informative error messages when they &#8216;sign in&#8217; and there&#8217;s no way to do that with container managed security.<\/p>\n<p>I was using Tomcat 4.1, which is to say, I was examining the servlet 2.3 specification.  (I just looked at the 2.4 specification and can see no amelioration of the above issue.)  I also focused on the FORM method of authentication, as that&#8217;s the most customizable.  (I imagine, for an intranet app obsessed with security, client certificates would be an worthwhile avenue of investigation.)  I found the <a href='http:\/\/java.sun.com\/products\/servlet\/download.html#specs'>servlet specs<\/a> to be very helpful in this process. <\/p>\n<p>With the FORM method of authentication, you can customize the appearance of your login and error pages, to some extent.  This is a huge win.  <\/p>\n<p>I really liked the automatic access control&#8211;no checking at the beginning of every ActionForm or JSP for any specific attribute.  Additionally, you can protect different URL patterns easily, and for most of the applications I write, this is enough.  If you need to protect buttons on a page, you can always resort to <a href='http:\/\/java.sun.com\/j2ee\/1.4\/docs\/api\/javax\/servlet\/http\/HttpServletRequest.html#isUserInRole(java.lang.String)'>isUserInRole<\/a>.<\/p>\n<p>Also, you can protect the login and error pages, which <a href='http:\/\/archives.real-time.com\/pipermail\/tomcat-users\/2002-July\/071706.html'>should never be accessed directly<\/a> in a separate \/safe directory, to which you can prohibit all access.  <\/p>\n<p>For the times when the user is denied access to a resource, you you can create a custom 403 error page, using the <a href='http:\/\/www.jguru.com\/faq\/view.jsp?EID=492774'>error-page<\/a> directive in web.xml.  Unfortunately, you only seem to get three attributes: <code>javax.servlet.error.message<\/code>, <code>javax.servlet.error.request_uri<\/code> and <code>javax.servlet.error.status_code<\/code>, which limits the nature of your response.  These were what Tomcat gave me&#8211;I don&#8217;t think it&#8217;s part of the spec.  Regardless, IE, with default settings, <a href='http:\/\/www.washington.edu\/computing\/web\/publishing\/errordocs.html'>doesn&#8217;t display any custom error messages<\/a>, which makes this a rather moot point for general webapps.  <\/p>\n<p>Creating a logout page is fairly easy, just call <code>session.invalidate()<\/code> (though there seem to be some  <a href='http:\/\/publib-b.boulder.ibm.com\/Redbooks.nsf\/RedbookAbstracts\/tips0220.html?Open'>non standard<\/a> methods of doing it as well).<\/p>\n<p>However, as mentioned above, I just don&#8217;t think that users will accept the generic login error messages that you are forced to give.  For instance, you can&#8217;t tell whether a user didn&#8217;t enter a password, or entered an incorrect password.  You can&#8217;t redirect them back to a login page with helpful error messages around the incorrect box.  These are fundamental issues with authentication&#8211;no serious webapp simply throws up its hands when a user doesn&#8217;t login correctly the *first* time. <\/p>\n<p>Separate from user experience, but still related to authentication behavior, you can&#8217;t &#8216;lock out&#8217; users who&#8217;ve attempted to login too many times.  Sure, you can keep track of how many times they&#8217;ve tried to login, but the authentication process is out of your hands.<\/p>\n<p>Additionally, the fact that you&#8217;re tied to a particular implementation for user\/role definition means that writing custom authentication code that just accesses a RDMBS is actually more portable. <\/p>\n<p>The answer, to the question posed in the title of this post: &#8220;is transparent access control worth unintelligible error messages?&#8221;, is almost always &#8220;no.&#8221;  And folks accuse developers of not having any sense of user interface!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Partly egged on by Rob and Brian, I just took a long overdue look at container managed security for web applications. My conclusion: it&#8217;s nice, but there is one major [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,6],"tags":[],"class_list":["post-122","post","type-post","status-publish","format-standard","hentry","category-java","category-programming"],"_links":{"self":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts\/122","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/comments?post=122"}],"version-history":[{"count":0,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts\/122\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/media?parent=122"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/categories?post=122"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/tags?post=122"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}