faq.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <!--
  2. * ========================================================================
  3. *
  4. * Copyright 2004 Acegi Technology Pty Limited
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. *
  18. * ========================================================================
  19. -->
  20. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  21. <html xmlns="http://www.w3.org/1999/xhtml">
  22. <head>
  23. <title>Frequently Asked Questions (FAQ) on Acegi Security</title>
  24. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  25. </head>
  26. <body>
  27. <h1>Frequently Asked Questions</h1>
  28. <h2>What is Acegi Security?</h2>
  29. <p>Acegi Security is an open source project that provide comprehensive authentication
  30. and authorisation services for enterprise applications based on
  31. <a href="http://www.springframework.org">The Spring Framework</a>.
  32. Acegi Security can authenticate using a variety of pluggable providers, and
  33. can authorise both web requests and method invocations.
  34. Acegi Security provides an integrated security approach across
  35. these various targets, and also offers access control list (ACL) capabilities to
  36. enable individual domain object instances to be secured. At an implementation
  37. level, Acegi Security is managed through Spring's inversion of control and
  38. lifecycle services, and actually enforces security using interception through
  39. servlet Filters and Java AOP frameworks. In terms of AOP framework support, Acegi
  40. Security currently supports AOP Alliance (which is what the
  41. Spring IoC container uses internally) and AspectJ, although additional frameworks
  42. can be easily supported.</p>
  43. <h2>Why not just use web.xml security?</h2>
  44. <p>Let's assuming you're developing an enterprise application based on Spring.
  45. There are four security concerns you typically need to address: authentication,
  46. web request security, service layer security (ie your methods that implement
  47. business logic), and domain object instance security (ie different domain objects
  48. have different permissions). With these typical requirements in mind:
  49. <ol>
  50. <li><b>Authentication</b>: The servlet specification provides an approach
  51. to authentication. However, you will need to configure the container
  52. to perform authentication which typically requires editing of
  53. container-specific "realm" settings. This makes a non-portable
  54. configuration, and if you need to write an actual Java class to implement
  55. the container's authentication interface, it becomes even more non-portable.
  56. With Acegi Security you achieve complete portability - right down to the
  57. WAR level. Also, Acegi Security offers a choice of production-proven
  58. authentication providers and mechanisms, meaning you can switch your
  59. authentication approaches at deployment time. This is particularly
  60. valuable for software vendors writing products that need to work in
  61. an unknown target environment.<br><br></li>
  62. <li><b>Web request security:</b> The servlet specification provides an
  63. approach to secure your request URIs. However, these URIs can only be
  64. expressed in the servlet specification's own limited URI path format.
  65. Acegi Security provides a far more comprehensive approach. For instance,
  66. you can use Ant paths or regular expressions, you can consider parts of the
  67. URI other than simply the requested page (eg you can consider request
  68. parameters), and you can implement your own runtime source of configuration
  69. data. This means your web request security can be dynamically changed during
  70. the actual execution of your webapp.<br><br></li>
  71. <li><b>Service layer and domain object security:</b> The absence of support
  72. in the servlet specification for services layer security or domain object
  73. instance security represent serious limitations for multi-tiered
  74. applications. Typically developers either ignore these requirements, or
  75. implement security logic within their MVC controller code (or even worse,
  76. inside the views). There are serious disadvantages with this approach:<br><br>
  77. <ol>
  78. <li><i>Separation of concerns:</i> Authorization is a
  79. crosscutting concern and should be implemented as such.
  80. MVC controllers or views implementing authorization code
  81. makes it more difficult to test both the controller and
  82. authorization logic, more difficult to debug, and will
  83. often lead to code duplication.</li>
  84. <li><i>Support for rich clients and web services:</i> If an
  85. additional client type must ultimately be supported, any
  86. authorization code embedded within the web layer is
  87. non-reusable. It should be considered that Spring remoting
  88. exporters only export service layer beans (not MVC
  89. controllers). As such authorization logic needs to be
  90. located in the services layer to support a multitude of
  91. client types.</li>
  92. <li><i>Layering issues:</i> An MVC controller or view is simply
  93. the incorrect architectural layer to implement authorization
  94. decisions concerning services layer methods or domain object
  95. instances. Whilst the Principal may be passed to the services
  96. layer to enable it to make the authorization decision, doing
  97. so would introduce an additional argument on every services
  98. layer method. A more elegant approach is to use a ThreadLocal
  99. to hold the Principal, although this would likely increase
  100. development time to a point where it would become more e
  101. conomical (on a cost-benefit basis) to simply use a dedicated
  102. security framework.</li>
  103. <li><i>Authorisation code quality:</i> It is often said of web
  104. frameworks that they "make it easier to do the right things,
  105. and harder to do the wrong things". Security frameworks are
  106. the same, because they are designed in an abstract manner for
  107. a wide range of purposes. Writing your own authorization code
  108. from scratch does not provide the "design check" a framework
  109. would offer, and in-house authorization code will typically
  110. lack the improvements that emerge from widespread deployment,
  111. peer review and new versions.
  112. </ol>
  113. </li>
  114. </ol>
  115. For simple applications, servlet specification may just be enough.
  116. Although when considered within the context of web container portability,
  117. configuration requirements, limited web request security flexibility, and
  118. non-existent services layer and domain object instance security, it becomes
  119. clear why developers often look to alternative solutions.
  120. </p>
  121. <h2>How do you pronounce "Acegi"?</h2>
  122. <p><i>Ah-see-gee</i>. Said quickly, without emphasis on any part.
  123. Acegi isn't an acronym, name of a Greek God or anything similarly
  124. impressive - it's just letters #1, #3, #5, #7 and #9 of the alphabet.</p>
  125. <h2>Is it called "Acegi" or "Acegi Security"?</h2>
  126. <p>It's official name is <i>Acegi Security System for Spring</i>,
  127. although we're happy for it to be abbreviated to
  128. <i>Acegi Security</i>. Please don't just call it <i>Acegi</i>, though,
  129. as that gets confused with the name of the company that maintains Acegi
  130. Security.</p>
  131. <h2>What catches 80% of users reporting problems?</h2>
  132. <p>80% of support questions are because people have not defined
  133. the necessary filters in <code>web.xml</code>, or the filters are being
  134. mapped in the incorrect order. Check the
  135. <a href="reference.html">Reference Guide</a>, which
  136. has a specific section on filter ordering.</p>
  137. <h2>I'm sure my filters are ordered correctly. What else could be wrong?</h2>
  138. <p>The next most common source of problems step from custom
  139. <code>AuthenticationDao</code> implementations that simply don't properly
  140. implement the interface. For example, they return <code>null</code> instead
  141. of the user not found exception, or fail to add in the
  142. <code>GrantedAuthority[]</code>s. We suggest you write the
  143. <code>UserDetails</code> object generated by your <code>AuthenticationDao</code>
  144. to the log and check it looks correct.</p>
  145. <h2>I need some help. What files should I post?</h2>
  146. <p>The most important things to post with any support requests on the
  147. <a href="http://forum.springframework.org">Spring Forums</a> are your
  148. <code>web.xml</code>, <code>applicationContext.xml</code> (or whichever
  149. XML loads the security-related beans) as well as any custom
  150. <code>AuthenticationDao</code> you might be using. For really odd problems,
  151. also switch on debug-level logging and include the resulting log.</p>
  152. <h2>How do I switch on debug-level logging?</h2>
  153. <p>Acegi Security uses Commons Logging, just as Spring does. So you use the
  154. same approach as you'd use for Spring. Most people output to Log4J, so
  155. the following <code>log4j.properties</code> would work:</p>
  156. <pre>
  157. log4j.rootCategory=WARN, stdout
  158. log4j.appender.stdout=org.apache.log4j.ConsoleAppender
  159. log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
  160. log4j.appender.stdout.layout.ConversionPattern=%d %p %c - %m%n
  161. log4j.category.net.sf.acegisecurity=DEBUG</pre>
  162. <h2>How do I store custom properties, like a user's email address?</h2>
  163. <p>In most cases write an <code>AuthenticationDao</code> which returns
  164. a subclass of <code>User</code>. Alternatively, write your own
  165. <code>UserDetails</code> implementation from scratch and return that.</p>
  166. <h2>Why doesn't Acegi Security use JAAS?</h2>
  167. <p>Acegi Security targets <i>enterprise applications</i>, which are typically
  168. multi-user, data-oriented applications that are important to
  169. the core business. Acegi Security was designed to provide a portable and effective
  170. security framework for this target application type. It was not designed for securing
  171. limited privilege runtime environments, such as web browser applets.</p>
  172. <p>We did consider JAAS when designing Acegi Security, but it simply
  173. wasn't suitable for our purpose. We needed to avoid complex JRE configurations,
  174. we needed container portability, and we wanted maximum leveraging of the Spring IoC
  175. container. Particularly as limited privilege runtime environments were not
  176. an actual requirement, this lead to the natural design of Acegi Security as
  177. it exists today.</p>
  178. <p>Acegi Security already provides some JAAS integration. It can today authenticate
  179. via delegation to a JAAS login module. This means it offers the same level of JAAS
  180. integration as many web containers. Indeed the container adapter model supported by
  181. Acegi Security allows Acegi Security and container-managed security to happily
  182. co-exist and benefit from each other. Any debate about Acegi Security and JAAS
  183. should therefore centre on the authorisation issue. An evaluation of major
  184. containers and security frameworks would reveal that Acegi Security is by no
  185. means unusual in not using JAAS for authorisation.</p>
  186. <p>There are many examples of open source applications being preferred to
  187. official standards. A few that come to mind in the Java community include
  188. using Spring managed POJOs (rather than EJBs), Hibernate (instead of entity beans),
  189. Log4J (instead of JDK logging), Tapestry (instead of JSF), and Velocity/FreeMarker
  190. (instead of JSP). It's important to recognise that many open source projects do
  191. develop into de facto standards, and in doing so play a legitimate and beneficial
  192. role in the software development profession.</p>
  193. <h2>Do you welcome contributions?</h2>
  194. <p>Yes. If you've written something and it works well, please feel free to share it.
  195. Simply email the contribution to the
  196. <a href="mail-lists.html">acegisecurity-developers</a> list. If you haven't yet
  197. written the contribution, we encourage you to send your thoughts to the same
  198. list so that you can receive some initial design feedback.</p>
  199. <p>For a contribution to be used, it must have appropriate unit test coverage and
  200. detailed JavaDocs. It will ideally have some comments for the Reference Guide
  201. as well (this can be sent in word processor or HTML format if desired). This
  202. helps ensure the contribution maintains the same quality as the remainder of
  203. the project.</p>
  204. <p>We also welcome documentation improvements, unit tests, illustrations,
  205. people supporting the user community (especially on the forums), design ideas,
  206. articles, blog entries, presentations and alike. If you're looking for something
  207. to do, you can always email the
  208. <a href="mail-lists.html">acegisecurity-developers</a> list and we'll be
  209. pleased to suggest something. :-)</p>
  210. </body>
  211. </html>