appendix-namespace.xml 158 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <appendix version="5.0" xml:id="appendix-namespace" xmlns="http://docbook.org/ns/docbook"
  3. xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
  4. <info>
  5. <title>The Security Namespace</title>
  6. </info>
  7. <para> This appendix provides a reference to the elements available in the security namespace
  8. and information on the underlying beans they create (a knowledge of the individual classes
  9. and how they work together is assumed - you can find more information in the project Javadoc
  10. and elsewhere in this document). If you haven't used the namespace before, please read the
  11. <link linkend="ns-config">introductory chapter</link> on namespace configuration, as
  12. this is intended as a supplement to the information there. Using a good quality XML editor
  13. while editing a configuration based on the schema is recommended as this will provide
  14. contextual information on which elements and attributes are available as well as comments
  15. explaining their purpose. The namespace is written in <link
  16. xlink:href="http://www.relaxng.org/">RELAX NG</link> Compact format and later converted into
  17. an XSD schema. If you are familiar with this format, you may wish to examine the <link
  18. xlink:href="https://fisheye.springsource.org/browse/spring-security/config/src/main/resources/org/springframework/security/config/spring-security-3.2.rnc"
  19. >schema file</link> directly.</para>
  20. <section xml:id="nsa-web">
  21. <title>Web Application Security</title>
  22. <section xml:id="nsa-debug">
  23. <title><literal>&lt;debug&gt;</literal></title>
  24. <para>Enables Spring Security debugging infrastructure. This will provide human-readable (multi-line)
  25. debugging information to monitor requests coming into the security filters. This may include sensitive
  26. information, such as request parameters or headers, and should only be used in a development
  27. environment.</para>
  28. </section>
  29. <section xml:id="nsa-http">
  30. <title><literal>&lt;http&gt;</literal></title>
  31. <para> If you use an <literal>&lt;http&gt;</literal> element within your application, a
  32. <classname>FilterChainProxy</classname> bean named "springSecurityFilterChain" is
  33. created and the configuration within the element is used to build a filter chain within
  34. <classname>FilterChainProxy</classname>. As of Spring Security 3.1, additional
  35. <literal>http</literal> elements can be used to add extra filter chains <footnote>
  36. <para>See the <link linkend="ns-web-xml">introductory chapter</link> for how to set
  37. up the mapping from your <literal>web.xml</literal></para>
  38. </footnote>. Some core filters are always created in a filter chain and others will be
  39. added to the stack depending on the attributes and child elements which are present. The
  40. positions of the standard filters are fixed (see <link linkend="filter-stack">the
  41. filter order table</link> in the namespace introduction), removing a common source of
  42. errors with previous versions of the framework when users had to configure the filter
  43. chain explicitly in the <classname>FilterChainProxy</classname> bean. You can, of course,
  44. still do this if you need full control of the configuration. </para>
  45. <para> All filters which require a reference to the
  46. <interfacename>AuthenticationManager</interfacename> will be automatically injected with
  47. the internal instance created by the namespace configuration (see the <link
  48. linkend="ns-auth-manager">introductory chapter</link> for more on the
  49. <interfacename>AuthenticationManager</interfacename>). </para>
  50. <para> Each <literal>&lt;http&gt;</literal> namespace block always creates an
  51. <classname>SecurityContextPersistenceFilter</classname>, an
  52. <classname>ExceptionTranslationFilter</classname> and a
  53. <classname>FilterSecurityInterceptor</classname>. These are fixed and cannot be replaced
  54. with alternatives. </para>
  55. <section xml:id="nsa-http-attributes">
  56. <title><literal>&lt;http&gt;</literal> Attributes</title>
  57. <para> The attributes on the <literal>&lt;http&gt;</literal> element control some of the
  58. properties on the core filters. </para>
  59. <section xml:id="nsa-http-access-decision-manager-ref">
  60. <title><literal>access-decision-manager-ref</literal></title>
  61. <para> Optional attribute specifying the ID of the
  62. <interfacename>AccessDecisionManager</interfacename> implementation which should
  63. be used for authorizing HTTP requests. By default an
  64. <classname>AffirmativeBased</classname> implementation is used for with a
  65. <classname>RoleVoter</classname> and an
  66. <classname>AuthenticatedVoter</classname>. </para>
  67. </section>
  68. <section xml:id="nsa-http-access-denied-page">
  69. <title><literal>access-denied-page</literal></title>
  70. <para> Deprecated in favour of the <link linkend="nsa-access-denied-handler">access-denied-handler</link>
  71. child element.</para>
  72. </section>
  73. <section xml:id="nsa-http-authentication-manager-ref">
  74. <title><literal>authentication-manager-ref</literal></title>
  75. <para>A reference to the <interfacename>AuthenticationManager</interfacename> used for the
  76. <classname>FilterChain</classname> created by this http element.</para>
  77. </section>
  78. <section xml:id="nsa-http-auto-config">
  79. <title><literal>auto-config</literal></title>
  80. <para>Automatically registers a login form, BASIC authentication, logout
  81. services. If set to "true", all of these capabilities are added
  82. (although you can still customize the configuration of each by providing the respective element). If
  83. unspecified, defaults to "false". Use of this attribute is not recommended. Use explicit
  84. configuration elements instead to avoid confusion.
  85. </para>
  86. </section>
  87. <section xml:id="nsa-http-create-session">
  88. <title><literal>create-session</literal></title>
  89. <para>Controls the eagerness with which an HTTP session is created by Spring Security classes.
  90. Options include:
  91. <itemizedlist>
  92. <listitem>
  93. <literal>always</literal> - Spring Security will proactively create a session if one
  94. does not exist.
  95. </listitem>
  96. <listitem>
  97. <literal>ifRequired</literal> - Spring Security will only create a session only if one
  98. is required (default value).
  99. </listitem>
  100. <listitem>
  101. <literal>never</literal> - Spring Security will never create a session, but will
  102. make use of one if the application does.</listitem>
  103. <listitem>
  104. <literal>stateless</literal> - Spring Security will not create a session and ignore the
  105. session for obtaining a Spring <interfacename>Authentication</interfacename>.
  106. </listitem>
  107. </itemizedlist>
  108. </para>
  109. </section>
  110. <section xml:id="nsa-http-disable-url-rewriting">
  111. <title><literal>disable-url-rewriting</literal></title>
  112. <para>Prevents session IDs from being appended to URLs in the application. Clients
  113. must use cookies if this attribute is set to <literal>true</literal>. The default is
  114. <literal>false</literal>.</para>
  115. </section>
  116. <section xml:id="nsa-http-entry-point-ref">
  117. <title><literal>entry-point-ref</literal></title>
  118. <para> Normally the <interfacename>AuthenticationEntryPoint</interfacename> used
  119. will be set depending on which authentication mechanisms have been configured.
  120. This attribute allows this behaviour to be overridden by defining a customized
  121. <interfacename>AuthenticationEntryPoint</interfacename> bean which will start
  122. the authentication process.</para>
  123. </section>
  124. <section xml:id="nsa-http-jaas-api-provision">
  125. <title><literal>jaas-api-provision</literal></title>
  126. <para>If available, runs the request as the <literal>Subject</literal> acquired from
  127. the <classname>JaasAuthenticationToken</classname> which is implemented by
  128. adding a <classname>JaasApiIntegrationFilter</classname> bean to the stack.
  129. Defaults to <literal>false</literal>.</para>
  130. </section>
  131. <section xml:id="nsa-http-name">
  132. <title><literal>name</literal></title>
  133. <para>A bean identifier, used for referring to the bean elsewhere in the context.</para>
  134. </section>
  135. <section xml:id="nsa-http-once-per-request">
  136. <title><literal>once-per-request</literal></title>
  137. <para>Corresponds to the <literal>observeOncePerRequest</literal> property of
  138. <classname>FilterSecurityInterceptor</classname>. Defaults to <literal>true</literal>.</para>
  139. </section>
  140. <section xml:id="nsa-http-path-type">
  141. <title><literal>path-type</literal></title>
  142. <para>Deprecated in favor of <link linkend="nsa-http-request-matcher">request-matcher</link>.
  143. </para>
  144. </section>
  145. <section xml:id="nsa-http-pattern">
  146. <title><literal>pattern</literal></title>
  147. <para>Defining a pattern for the <link linkend="nsa-http">http</link> element controls the
  148. requests which will be filtered through the list of filters which it defines.
  149. The interpretation is dependent on the configured <link
  150. linkend="nsa-http-request-matcher">request-matcher</link>. If no pattern is defined,
  151. all requests will be matched, so the most specific patterns should be declared
  152. first.</para>
  153. </section>
  154. <section xml:id="nsa-http-realm">
  155. <title><literal>realm</literal></title>
  156. <para>Sets the realm name used for basic authentication (if enabled). Corresponds
  157. to the <literal>realmName</literal> property on
  158. <classname>BasicAuthenticationEntryPoint</classname>.</para>
  159. </section>
  160. <section xml:id="nsa-http-request-matcher">
  161. <title><literal>request-matcher</literal></title>
  162. <para>Defines the <interfacename>RequestMatcher</interfacename> strategy used in
  163. the <classname>FilterChainProxy</classname> and the beans created by the
  164. <literal>intercept-url</literal> to match incoming requests. Options are
  165. currently <literal>ant</literal>, <literal>regex</literal> and
  166. <literal>ciRegex</literal>, for ant, regular-expression and case-insensitive
  167. regular-expression repsectively. A separate instance is created for each
  168. <link linkend="nsa-intercept-url">intercept-url</link> element using its
  169. <link linkend="nsa-intercept-url-pattern">pattern</link> and
  170. <link linkend="nsa-intercept-url-method">method</link> attributes. Ant paths
  171. are matched using an <classname>AntPathRequestMatcher</classname> and regular expressions
  172. are matched using a <classname>RegexRequestMatcher</classname>. See the Javadoc
  173. for these classes for more details on exactly how the matching is preformed. Ant
  174. paths are the default strategy.</para>
  175. </section>
  176. <section xml:id="nsa-http-request-matcher-ref">
  177. <title><literal>request-matcher-ref</literal></title>
  178. <para>A referenece to a bean that implements <interfacename>RequestMatcher</interfacename> that
  179. will determine if this <classname>FilterChain</classname> should be used. This is a more
  180. powerful alternative to <link linkend="nsa-http-pattern">pattern</link>.</para>
  181. </section>
  182. <section xml:id="nsa-http-security">
  183. <title><literal>security</literal></title>
  184. <para>A request pattern can be mapped to an empty filter chain, by setting this
  185. attribute to <literal>none</literal>. No security will be applied and none of
  186. Spring Security's features will be available.</para>
  187. </section>
  188. <section xml:id="nsa-http-security-context-repository-ref">
  189. <title><literal>security-context-repository-ref</literal></title>
  190. <para>Allows injection of a custom
  191. <interfacename>SecurityContextRepository</interfacename> into the
  192. <classname>SecurityContextPersistenceFilter</classname>.</para>
  193. </section>
  194. <section xml:id="nsa-http-servlet-api-provision">
  195. <title><literal>servlet-api-provision</literal></title>
  196. <para>Provides versions of <literal>HttpServletRequest</literal> security methods
  197. such as <literal>isUserInRole()</literal> and <literal>getPrincipal()</literal>
  198. which are implemented by adding a
  199. <classname>SecurityContextHolderAwareRequestFilter</classname> bean to the
  200. stack. Defaults to <literal>true</literal>.</para>
  201. </section>
  202. <section xml:id="nsa-http-use-expressions">
  203. <title><literal>use-expressions</literal></title>
  204. <para>Enables EL-expressions in the <literal>access</literal> attribute, as
  205. described in the chapter on <link linkend="el-access-web">expression-based
  206. access-control</link>.</para>
  207. </section>
  208. </section>
  209. <section xml:id="nsa-http-children">
  210. <title>Child Elements of &lt;http&gt;</title>
  211. <itemizedlist>
  212. <listitem><link linkend="nsa-access-denied-handler">access-denied-handler</link></listitem>
  213. <listitem><link linkend="nsa-anonymous">anonymous</link></listitem>
  214. <listitem><link linkend="nsa-csrf">csrf</link></listitem>
  215. <listitem><link linkend="nsa-custom-filter">custom-filter</link></listitem>
  216. <listitem><link linkend="nsa-expression-handler">expression-handler</link></listitem>
  217. <listitem><link linkend="nsa-form-login">form-login</link></listitem>
  218. <listitem><link linkend="nsa-headers">headers</link></listitem>
  219. <listitem><link linkend="nsa-http-basic">http-basic</link></listitem>
  220. <listitem><link linkend="nsa-intercept-url">intercept-url</link></listitem>
  221. <listitem><link linkend="nsa-jee">jee</link></listitem>
  222. <listitem><link linkend="nsa-logout">logout</link></listitem>
  223. <listitem><link linkend="nsa-openid-login">openid-login</link></listitem>
  224. <listitem><link linkend="nsa-port-mappings">port-mappings</link></listitem>
  225. <listitem><link linkend="nsa-remember-me">remember-me</link></listitem>
  226. <listitem><link linkend="nsa-request-cache">request-cache</link></listitem>
  227. <listitem><link linkend="nsa-session-management">session-management</link></listitem>
  228. <listitem><link linkend="nsa-x509">x509</link></listitem>
  229. </itemizedlist>
  230. </section>
  231. </section>
  232. <section xml:id="nsa-access-denied-handler">
  233. <title><literal>&lt;access-denied-handler&gt;</literal></title>
  234. <para>This element allows you to set the <literal>errorPage</literal> property for the
  235. default <interfacename>AccessDeniedHandler</interfacename> used by the
  236. <classname>ExceptionTranslationFilter</classname>, using the
  237. <link linkend="nsa-access-denied-handler-error-page">error-page</link> attribute, or
  238. to supply your own implementation using the
  239. <link linkend="nsa-access-denied-handler-ref">ref</link> attribute. This is discussed
  240. in more detail in the section on the <link linkend="access-denied-handler">
  241. <classname>ExceptionTranslationFilter</classname></link>.</para>
  242. <section xml:id="nsa-access-denied-handler-parents">
  243. <title>Parent Elements of <literal>&lt;access-denied-handler&gt;</literal></title>
  244. <itemizedlist>
  245. <listitem><link linkend="nsa-http">http</link></listitem>
  246. </itemizedlist>
  247. </section>
  248. <section xml:id="nsa-access-denied-handler-attributes">
  249. <title><literal>&lt;access-denied-handler&gt;</literal> Attributes</title>
  250. <section xml:id="nsa-access-denied-handler-error-page">
  251. <title><literal>error-page</literal></title>
  252. <para>The access denied page that an authenticated user will be redirected to if they request a
  253. page which they don't have the authority to access.</para>
  254. </section>
  255. <section xml:id="nsa-access-denied-handler-ref">
  256. <title><literal>ref</literal></title>
  257. <para>Defines a reference to a Spring bean of type <interfacename>AccessDeniedHandler
  258. </interfacename>.</para>
  259. </section>
  260. </section>
  261. </section>
  262. <section xml:id="nsa-headers">
  263. <title><literal>&lt;headers&gt;</literal></title>
  264. <para>This element allows for configuring additional (security) headers to be send with the response.
  265. It enables easy configuration for several headers and also allows for setting custom headers through
  266. the <link linkend="nsa-header">header</link> element.
  267. <itemizedlist>
  268. <listitem><literal>Cache-Control</literal>, <literal>Pragma</literal>, and <literal>Expires</literal> - Can be set using the
  269. <link linkend="nsa-cache-control">cache-control</link> element. This ensures that the
  270. browser does not cache your secured pages.</listitem>
  271. <listitem><literal>Strict-Transport-Security</literal> - Can be set using the
  272. <link linkend="nsa-hsts">hsts</link> element. This ensures that the
  273. browser automatically requests HTTPS for future requests.</listitem>
  274. <listitem><literal>X-Frame-Options</literal> - Can be set using the
  275. <link linkend="nsa-frame-options">frame-options</link> element. The
  276. <link xlink:href="http://en.wikipedia.org/wiki/Clickjacking#X-Frame-Options">X-Frame-Options
  277. </link> header can be used to prevent clickjacking attacks.</listitem>
  278. <listitem><literal>X-XSS-Protection</literal> - Can be set using the
  279. <link linkend="nsa-xss-protection">xss-protection</link> element.
  280. The <link xlink:href="http://en.wikipedia.org/wiki/Cross-site_scripting">X-XSS-Protection
  281. </link> header can be used by browser to do basic control.</listitem>
  282. <listitem><literal>X-Content-Type-Options</literal> - Can be set using the
  283. <link linkend="nsa-content-type-options">content-type-options</link> element. The
  284. <link xlink:href="http://blogs.msdn.com/b/ie/archive/2008/09/02/ie8-security-part-vi-beta-2-update.aspx">X-Content-Type-Options</link>
  285. header prevents Internet Explorer from MIME-sniffing a response away from the declared
  286. content-type. This also applies to Google Chrome, when downloading extensions. </listitem>
  287. </itemizedlist>
  288. </para>
  289. <section xml:id="nsa-headers-parents">
  290. <title>Parent Elements of <literal>&lt;headers&gt;</literal></title>
  291. <itemizedlist>
  292. <listitem><link linkend="nsa-http">http</link></listitem>
  293. </itemizedlist>
  294. </section>
  295. <section xml:id="nsa-headers-children">
  296. <title>Child Elements of <literal>&lt;headers&gt;</literal></title>
  297. <itemizedlist>
  298. <listitem><link linkend="nsa-cache-control">cache-control</link></listitem>
  299. <listitem><link linkend="nsa-content-type-options">content-type-options</link></listitem>
  300. <listitem><link linkend="nsa-frame-options">frame-options</link></listitem>
  301. <listitem><link linkend="nsa-header">header</link></listitem>
  302. <listitem><link linkend="nsa-hsts">hsts</link></listitem>
  303. <listitem><link linkend="nsa-xss-protection">xss-protection</link></listitem>
  304. </itemizedlist>
  305. </section>
  306. </section>
  307. <section xml:id="nsa-cache-control">
  308. <title><literal>&lt;cache-control&gt;</literal></title>
  309. <para>Adds <literal>Cache-Control</literal>, <literal>Pragma</literal>, and <literal>Expires</literal>
  310. headers to ensure that the browser does not cache your secured pages.</para>
  311. <section xml:id="nsa-cache-control-parents">
  312. <title>Parent Elements of <literal>&lt;cache-control&gt;</literal></title>
  313. <itemizedlist>
  314. <listitem><link linkend="nsa-headers">headers</link></listitem>
  315. </itemizedlist>
  316. </section>
  317. </section>
  318. <section xml:id="nsa-hsts">
  319. <title><literal>&lt;hsts&gt;</literal></title>
  320. <para>When enabled adds the <link xlink:href="http://tools.ietf.org/html/rfc6797">Strict-Transport-Security</link> header to the response
  321. for any secure request. This allows the server to instruct browsers to automatically use HTTPS for future requests.</para>
  322. <section xml:id="nsa-hsts-attributes">
  323. <title><literal>&lt;hsts&gt;</literal> Attributes</title>
  324. <section xml:id="nsa-hsts-include-subdomains">
  325. <title><literal>include-sub-domains</literal></title>
  326. <para>
  327. Specifies if subdomains should be included. Default true.
  328. </para>
  329. </section>
  330. <section xml:id="nsa-hsts-max-age-seconds">
  331. <title><literal>max-age-seconds</literal></title>
  332. <para>
  333. Specifies the maximum ammount of time the host should be considered a Known HSTS Host. Default one year.
  334. </para>
  335. </section>
  336. <section xml:id="nsa-hsts-request-matcher-ref">
  337. <title><literal>request-matcher-ref</literal></title>
  338. <para>
  339. The RequestMatcher instance to be used to determine if the header should be set. Default is if HttpServletRequest.isSecure() is true.
  340. </para>
  341. </section>
  342. </section>
  343. <section xml:id="nsa-hsts-parents">
  344. <title>Parent Elements of <literal>&lt;hsts&gt;</literal></title>
  345. <itemizedlist>
  346. <listitem><link linkend="nsa-headers">headers</link></listitem>
  347. </itemizedlist>
  348. </section>
  349. </section>
  350. <section xml:id="nsa-frame-options">
  351. <title><literal>&lt;frame-options&gt;</literal></title>
  352. <para>When enabled adds the <link xlink:href="http://tools.ietf.org/html/draft-ietf-websec-x-frame-options">X-Frame-Options header</link> to the response, this allows newer browsers to do some security
  353. checks and prevent <link xlink:href="http://en.wikipedia.org/wiki/Clickjacking">clickjacking</link> attacks.</para>
  354. <section xml:id="nsa-frame-options-attributes">
  355. <title><literal>&lt;frame-options&gt;</literal> Attributes</title>
  356. <section xml:id="nsa-frame-options-policy">
  357. <title><literal>policy</literal></title>
  358. <para>
  359. <itemizedlist>
  360. <listitem><literal>DENY</literal> The page cannot be displayed in a frame, regardless of
  361. the site attempting to do so. This is the default when frame-options-policy is specified.</listitem>
  362. <listitem><literal>SAMEORIGIN</literal> The page can only be displayed in a frame on the
  363. same origin as the page itself</listitem>
  364. <listitem><literal>ALLOW-FROM <link linkend="nsa-frame-options-origin">origin</link></literal>
  365. The page can only be displayed in a frame on the specified origin.
  366. </listitem>
  367. </itemizedlist>
  368. In other words, if you specify DENY, not only will attempts to load the page in a frame fail
  369. when loaded from other sites, attempts to do so will fail when loaded from the same site. On the
  370. other hand, if you specify SAMEORIGIN, you can still use the page in a frame as long as the site
  371. including it in a frame it is the same as the one serving the page.
  372. </para>
  373. </section>
  374. <section xml:id="nsa-frame-options-strategy">
  375. <title><literal>strategy</literal></title>
  376. <para>
  377. Select the <classname>AllowFromStrategy</classname> to use when using the ALLOW-FROM policy.
  378. <itemizedlist>
  379. <listitem><literal>static</literal> Use a single static ALLOW-FROM value. The value can be set
  380. through the <link linkend="nsa-frame-options-value">value</link> attribute.
  381. </listitem>
  382. <listitem><literal>regexp</literal> Use a regelur expression to validate incoming requests and
  383. if they are allowed. The regular expression can be set through the <link linkend="nsa-frame-options-value">value</link>
  384. attribute. The request parameter used to retrieve the value to validate can be specified
  385. using the <link linkend="nsa-frame-options-from-parameter">from-parameter</link>.
  386. </listitem>
  387. <listitem><literal>whitelist</literal>A comma-seperated list containing the allowed domains.
  388. The comma-seperated list can be set through the <link linkend="nsa-frame-options-value">value</link>
  389. attribute. The request parameter used to retrieve the value to validate can be specified
  390. using the <link linkend="nsa-frame-options-from-parameter">from-parameter</link>.
  391. </listitem>
  392. </itemizedlist>
  393. </para>
  394. </section>
  395. <section xml:id="nsa-frame-options-ref">
  396. <title><literal>ref</literal></title>
  397. <para>
  398. Instead of using one of the predefined strategies it is also possible to use a custom <classname>AllowFromStrategy</classname>.
  399. The reference to this bean can be specified through this ref attribute.
  400. </para>
  401. </section>
  402. <section xml:id="nsa-frame-options-value">
  403. <title><literal>value</literal></title>
  404. <para>The value to use when ALLOW-FROM is used a <link linkend="nsa-frame-options-strategy">strategy</link>.</para>
  405. </section>
  406. <section xml:id="nsa-frame-options-from-parameter">
  407. <title><literal>from-parameter</literal></title>
  408. <para>
  409. Specify the name of the request parameter to use when using regexp or whitelist for the ALLOW-FROM
  410. strategy.
  411. </para>
  412. </section>
  413. </section>
  414. <section xml:id="nsa-frame-options-parents">
  415. <title>Parent Elements of <literal>&lt;frame-options&gt;</literal></title>
  416. <itemizedlist>
  417. <listitem><link linkend="nsa-headers">headers</link></listitem>
  418. </itemizedlist>
  419. </section>
  420. </section>
  421. <section xml:id="nsa-xss-protection">
  422. <title><literal>&lt;xss-protection&gt;</literal></title>
  423. <para>Adds the <link xlink:href="http://blogs.msdn.com/b/ie/archive/2008/07/02/ie8-security-part-iv-the-xss-filter.aspx">X-XSS-Protection header</link>
  424. to the response to assist in protecting against <link xlink:href="http://en.wikipedia.org/wiki/Cross-site_scripting#Non-Persistent">reflected / “Type-1” Cross-Site Scripting (XSS)</link>
  425. attacks. This is in no-way a full protection to XSS attacks!</para>
  426. <section xml:id="nsa-xss-protection-attributes">
  427. <section xml:id="nsa-xss-protection-enabled">
  428. <title><literal>xss-protection-enabled</literal></title>
  429. <para>Enable or Disable <link xlink:href="http://en.wikipedia.org/wiki/Cross-site_scripting#Non-Persistent">reflected / “Type-1” Cross-Site Scripting (XSS)</link> protection.</para>
  430. </section>
  431. <section xml:id="nsa-xss-protection-block">
  432. <title><literal>xss-protection-block</literal></title>
  433. <para>When true and xss-protection-enabled is true, adds mode=block to the header. This indicates to the browser that the
  434. page should not be loaded at all. When false and xss-protection-enabled is true, the page will still be rendered when
  435. an reflected attack is detected but the response will be modified to protect against the attack. Note that there are
  436. sometimes ways of bypassing this mode which can often times make blocking the page more desirable.</para>
  437. </section>
  438. </section>
  439. <section xml:id="nsa-xss-protection-parents">
  440. <title>Parent Elements of <literal>&lt;xss-protection&gt;</literal></title>
  441. <itemizedlist>
  442. <listitem><link linkend="nsa-headers">headers</link></listitem>
  443. </itemizedlist>
  444. </section>
  445. </section>
  446. <section xml:id="nsa-content-type-options">
  447. <title><literal>&lt;content-type-options&gt;</literal></title>
  448. <para>Add the X-Content-Type-Options header with the value of nosniff to the response. This
  449. <link xlink:href="http://blogs.msdn.com/b/ie/archive/2008/09/02/ie8-security-part-vi-beta-2-update.aspx">disables MIME-sniffing</link>
  450. for IE8+ and Chrome extensions.</para>
  451. <section xml:id="nsa-content-type-options-parents">
  452. <title>Parent Elements of <literal>&lt;content-type-options&gt;</literal></title>
  453. <itemizedlist>
  454. <listitem><link linkend="nsa-headers">headers</link></listitem>
  455. </itemizedlist>
  456. </section>
  457. </section>
  458. <section xml:id="nsa-header">
  459. <title><literal>&lt;header&gt;</literal></title>
  460. <para>Add additional headers to the response, both the name and value need to be specified.</para>
  461. <section xml:id="nsa-header-attributes">
  462. <title><literal>&lt;header-attributes&gt;</literal> Attributes</title>
  463. <section xml:id="nsa-header-name">
  464. <title><literal>header-name</literal></title>
  465. <para>The <literal>name</literal> of the header.</para>
  466. </section>
  467. <section xml:id="nsa-header-value">
  468. <title><literal>header-value</literal></title>
  469. <para>The <literal>value</literal> of the header to add.</para>
  470. </section>
  471. <section xml:id="nsa-header-ref">
  472. <title><literal>header-ref</literal></title>
  473. <para>Reference to a custom implementation of the <classname>HeaderWriter</classname> interface.</para>
  474. </section>
  475. </section>
  476. <section xml:id="nsa-header-parents">
  477. <title>Parent Elements of <literal>&lt;header&gt;</literal></title>
  478. <itemizedlist>
  479. <listitem><link linkend="nsa-headers">headers</link></listitem>
  480. </itemizedlist>
  481. </section>
  482. </section>
  483. <section xml:id="nsa-anonymous">
  484. <title><literal>&lt;anonymous&gt;</literal></title>
  485. <para>Adds an <classname>AnonymousAuthenticationFilter</classname> to the stack and an
  486. <classname>AnonymousAuthenticationProvider</classname>. Required if you are using
  487. the <literal>IS_AUTHENTICATED_ANONYMOUSLY</literal> attribute.</para>
  488. <section xml:id="nsa-anonymous-parents">
  489. <title>Parent Elements of <literal>&lt;anonymous&gt;</literal></title>
  490. <itemizedlist>
  491. <listitem><link linkend="nsa-http">http</link></listitem>
  492. </itemizedlist>
  493. </section>
  494. <section xml:id="nsa-anonymous-attributes">
  495. <title><literal>&lt;anonymous&gt;</literal> Attributes</title>
  496. <section xml:id="nsa-anonymous-enabled">
  497. <title><literal>enabled</literal></title>
  498. <para>With the default namespace setup, the anonymous "authentication" facility is automatically
  499. enabled. You can disable it using this property.</para>
  500. </section>
  501. <section xml:id="nsa-anonymous-granted-authority">
  502. <title><literal>granted-authority</literal></title>
  503. <para>The granted authority that should be assigned to the anonymous request. Commonly this is used
  504. to assign the anonymous request particular roles, which can subsequently be used in authorization
  505. decisions. If unset, defaults to <literal>ROLE_ANONYMOUS</literal>.</para>
  506. </section>
  507. <section xml:id="nsa-anonymous-key">
  508. <title><literal>key</literal></title>
  509. <para>The key shared between the provider and filter. This generally does not need to be set. If
  510. unset, it will default to a secure randomly generated value. This means setting this value can
  511. improve startup time when using the anonymous functionality since secure random values can take
  512. a while to be generated.</para>
  513. </section>
  514. <section xml:id="nsa-anonymous-username">
  515. <title><literal>username</literal></title>
  516. <para>The username that should be assigned to the anonymous request. This allows the principal to
  517. be identified, which may be important for logging and auditing. if unset, defaults to
  518. <literal>anonymousUser</literal>.</para>
  519. </section>
  520. </section>
  521. </section>
  522. <section xml:id="nsa-csrf">
  523. <title><literal>&lt;csrf&gt;</literal></title>
  524. <para>This element will add <link xlink:href="http://en.wikipedia.org/wiki/Cross-site_request_forgery">Cross Site Request Forger (CSRF)</link>
  525. protection to the application. It also updates the default RequestCache
  526. to only replay "GET" requests upon successful authentication.</para>
  527. <section xml:id="nsa-csrf-parents">
  528. <title>Parent Elements of <literal>&lt;csrf&gt;</literal></title>
  529. <itemizedlist>
  530. <listitem><link linkend="nsa-http">http</link></listitem>
  531. </itemizedlist>
  532. </section>
  533. <section xml:id="nsa-csrf-attributes">
  534. <title><literal>&lt;csrf&gt;</literal> Attributes</title>
  535. <section xml:id="nsa-csrf-token-repository-ref">
  536. <title><literal>token-repository-ref</literal></title>
  537. <para>The CsrfTokenRepository to use. The default is
  538. <classname>HttpSessionCsrfTokenRepository</classname>.</para>
  539. </section>
  540. <section xml:id="nsa-csrf-request-matcher-ref">
  541. <title><literal>request-matcher-ref</literal></title>
  542. <para>The RequestMatcher instance to be used to determine if CSRF should be applied. Default is any
  543. HTTP method except "GET", "TRACE", "HEAD", "OPTIONS".</para>
  544. </section>
  545. </section>
  546. </section>
  547. <section xml:id="nsa-custom-filter">
  548. <title><literal>&lt;custom-filter&gt;</literal></title>
  549. <para>This element is used to add a filter to the filter chain. It doesn't create any
  550. additional beans but is used to select a bean of type
  551. <interfacename>javax.servlet.Filter</interfacename> which is already defined in the
  552. application context and add that at a particular position in the filter chain
  553. maintained by Spring Security. Full details can be found in the <link linkend="ns-custom-filters">
  554. namespace chapter</link>.</para>
  555. <section xml:id="nsa-custom-filter-parents">
  556. <title>Parent Elements of <literal>&lt;custom-filter&gt;</literal></title>
  557. <itemizedlist>
  558. <listitem><link linkend="nsa-http">http</link></listitem>
  559. </itemizedlist>
  560. </section>
  561. <section xml:id="nsa-custom-filter-attributes">
  562. <title><literal>&lt;custom-filter&gt;</literal> Attributes</title>
  563. <section xml:id="nsa-custom-filter-after">
  564. <title><literal>after</literal></title>
  565. <para>The filter immediately after which the custom-filter should be placed in the chain. This
  566. feature will only be needed by advanced users who wish to mix their own filters into the
  567. security filter chain and have some knowledge of the standard Spring Security filters. The
  568. filter names map to specific Spring Security implementation filters.</para>
  569. </section>
  570. <section xml:id="nsa-custom-filter-before">
  571. <title><literal>before</literal></title>
  572. <para>The filter immediately before which the custom-filter should be placed in the chain</para>
  573. </section>
  574. <section xml:id="nsa-custom-filter-position">
  575. <title><literal>position</literal></title>
  576. <para>The explicit position at which the custom-filter should be placed in the chain. Use if you
  577. are replacing a standard filter.</para>
  578. </section>
  579. <section xml:id="nsa-custom-filter-ref">
  580. <title><literal>ref</literal></title>
  581. <para>Defines a reference to a Spring bean that implements <interfacename>Filter</interfacename>.</para>
  582. </section>
  583. </section>
  584. </section>
  585. <section xml:id="nsa-expression-handler">
  586. <title><literal>&lt;expression-handler&gt;</literal></title>
  587. <para>Defines the <interfacename>SecurityExpressionHandler</interfacename> instance which will be used if
  588. expression-based access-control is enabled. A default implementation (with no ACL support) will be used
  589. if not supplied.</para>
  590. <section xml:id="nsa-expression-handler-parents">
  591. <title>Parent Elements of <literal>&lt;expression-handler&gt;</literal></title>
  592. <itemizedlist>
  593. <listitem><link linkend="nsa-global-method-security">global-method-security</link></listitem>
  594. <listitem><link linkend="nsa-http">http</link></listitem>
  595. </itemizedlist>
  596. </section>
  597. <section xml:id="nsa-expression-handler-attributes">
  598. <title><literal>&lt;expression-handler&gt;</literal> Attributes</title>
  599. <section xml:id="nsa-expression-handler-ref">
  600. <title><literal>ref</literal></title>
  601. <para>Defines a reference to a Spring bean that implements <interfacename>SecurityExpressionHandler</interfacename>.</para>
  602. </section>
  603. </section>
  604. </section>
  605. <section xml:id="nsa-form-login">
  606. <title><literal>&lt;form-login&gt;</literal></title>
  607. <para>Used to add an <classname>UsernamePasswordAuthenticationFilter</classname> to the
  608. filter stack and an <classname>LoginUrlAuthenticationEntryPoint</classname> to the
  609. application context to provide authentication on demand. This will always take
  610. precedence over other namespace-created entry points. If no attributes are supplied,
  611. a login page will be generated automatically at the URL "/spring_security_login" <footnote>
  612. <para>This feature is really just provided for convenience and is not intended for
  613. production (where a view technology will have been chosen and can be used to
  614. render a customized login page). The class
  615. <classname>DefaultLoginPageGeneratingFilter</classname> is responsible for
  616. rendering the login page and will provide login forms for both normal form login
  617. and/or OpenID if required.</para>
  618. </footnote> The behaviour can be customized using the <link linkend="nsa-form-login-attributes">
  619. <literal>&lt;form-login&gt;</literal> Attributes</link>.</para>
  620. <section xml:id="nsa-form-login-parents">
  621. <title>Parent Elements of <literal>&lt;form-login&gt;</literal></title>
  622. <itemizedlist>
  623. <listitem><link linkend="nsa-http">http</link></listitem>
  624. </itemizedlist>
  625. </section>
  626. <section xml:id="nsa-form-login-attributes">
  627. <title><literal>&lt;form-login&gt;</literal> Attributes</title>
  628. <section xml:id="nsa-form-login-always-use-default-target">
  629. <title><literal>always-use-default-target</literal></title>
  630. <para>If set to <literal>true</literal>, the user will always start at the value given by
  631. <link linkend="nsa-form-login-default-target-url">default-target-url</link>, regardless
  632. of how they arrived at the login page. Maps to the <literal>alwaysUseDefaultTargetUrl</literal>
  633. property of <classname>UsernamePasswordAuthenticationFilter</classname>. Default value is
  634. <literal>false</literal>.</para>
  635. </section>
  636. <section xml:id="nsa-form-login-authentication-details-source-ref">
  637. <title><literal>authentication-details-source-ref</literal></title>
  638. <para>Reference to an <interfacename>AuthenticationDetailsSource</interfacename> which will be used
  639. by the authentication filter</para>
  640. </section>
  641. <section xml:id="nsa-form-login-authentication-failure-handler-ref">
  642. <title><literal>authentication-failure-handler-ref</literal></title>
  643. <para>Can be used as an alternative to
  644. <link linkend="nsa-form-login-authentication-failure-url">authentication-failure-url</link>,
  645. giving you full control over the navigation flow after an authentication failure. The value
  646. should be he name of an <interfacename>AuthenticationFailureHandler</interfacename> bean in the
  647. application context.</para>
  648. </section>
  649. <section xml:id="nsa-form-login-authentication-failure-url">
  650. <title><literal>authentication-failure-url</literal></title>
  651. <para>Maps to the <literal>authenticationFailureUrl</literal> property of
  652. <classname>UsernamePasswordAuthenticationFilter</classname>. Defines the URL the
  653. browser will be redirected to on login failure. Defaults to
  654. <literal>/spring_security_login?login_error</literal>, which will be automatically handled by
  655. the automatic login page generator, re-rendering the login page with an error message.</para>
  656. </section>
  657. <section xml:id="nsa-form-login-authentication-success-handler-ref">
  658. <title><literal>authentication-success-handler-ref</literal></title>
  659. <para>This can be used as an alternative to
  660. <link linkend="nsa-form-login-default-target-url">default-target-url</link>
  661. and <link linkend="nsa-form-login-always-use-default-target">always-use-default-target</link>,
  662. giving you full control over the navigation flow after a successful authentication. The value
  663. should be the name of an <interfacename>AuthenticationSuccessHandler</interfacename> bean in
  664. the application context. By default, an implementation of
  665. <classname>SavedRequestAwareAuthenticationSuccessHandler</classname> is used and
  666. injected with the <link linkend="nsa-form-login-default-target-url">default-target-url
  667. </link>.</para>
  668. </section>
  669. <section xml:id="nsa-form-login-default-target-url">
  670. <title><literal>default-target-url</literal></title>
  671. <para>Maps to the <literal>defaultTargetUrl</literal> property of
  672. <classname>UsernamePasswordAuthenticationFilter</classname>. If not set, the
  673. default value is "/" (the application root). A user will be taken to this URL
  674. after logging in, provided they were not asked to login while attempting to
  675. access a secured resource, when they will be taken to the originally requested
  676. URL.</para>
  677. </section>
  678. <section xml:id="nsa-form-login-login-page">
  679. <title><literal>login-page</literal></title>
  680. <para> The URL that should be used to render the login page. Maps to the
  681. <literal>loginFormUrl</literal> property of the
  682. <classname>LoginUrlAuthenticationEntryPoint</classname>. Defaults to
  683. "/spring_security_login".</para>
  684. </section>
  685. <section xml:id="nsa-form-login-login-processing-url">
  686. <title><literal>login-processing-url</literal></title>
  687. <para> Maps to the <literal>filterProcessesUrl</literal> property of
  688. <classname>UsernamePasswordAuthenticationFilter</classname>. The default value
  689. is "/j_spring_security_check".</para>
  690. </section>
  691. <section xml:id="nsa-form-login-password-parameter">
  692. <title><literal>password-parameter</literal></title>
  693. <para>The name of the request parameter which contains the password. Defaults to "j_password".</para>
  694. </section>
  695. <section xml:id="nsa-form-login-username-parameter">
  696. <title><literal>username-parameter</literal></title>
  697. <para>The name of the request parameter which contains the username. Defaults to "j_username".</para>
  698. </section>
  699. </section>
  700. </section>
  701. <section xml:id="nsa-http-basic">
  702. <title><literal>&lt;http-basic&gt;</literal></title>
  703. <para>Adds a <classname>BasicAuthenticationFilter</classname> and
  704. <classname>BasicAuthenticationEntryPoint</classname> to the configuration. The
  705. latter will only be used as the configuration entry point if form-based login is not
  706. enabled.</para>
  707. <section xml:id="nsa-http-basic-parents">
  708. <title>Parent Elements of <literal>&lt;http-basic&gt;</literal></title>
  709. <itemizedlist>
  710. <listitem><link linkend="nsa-http">http</link></listitem>
  711. </itemizedlist>
  712. </section>
  713. <section xml:id="nsa-http-basic-attributes">
  714. <title><literal>&lt;http-basic&gt;</literal> Attributes</title>
  715. <section xml:id="nsa-http-basic-authentication-details-source-ref">
  716. <title><literal>authentication-details-source-ref</literal></title>
  717. <para>Reference to an <interfacename>AuthenticationDetailsSource</interfacename> which will be used
  718. by the authentication filter</para>
  719. </section>
  720. <section xml:id="nsa-http-basic-entry-point-ref">
  721. <title><literal>entry-point-ref</literal></title>
  722. <para>Sets the <interfacename>AuthenticationEntryPoint</interfacename> which is used by the
  723. <classname>BasicAuthenticationFilter</classname>.</para>
  724. </section>
  725. </section>
  726. </section>
  727. <section xml:id="nsa-http-firewall">
  728. <title><literal>&lt;http-firewall></literal> Element</title>
  729. <para>This is a top-level element which can be used to inject a custom implementation of
  730. <interfacename>HttpFirewall</interfacename> into the
  731. <classname>FilterChainProxy</classname> created by the namespace. The default
  732. implementation should be suitable for most applications.</para>
  733. <section xml:id="nsa-http-firewall-attributes">
  734. <title><literal>&lt;http-firewall&gt;</literal> Attributes</title>
  735. <section xml:id="nsa-http-firewall-ref">
  736. <title><literal>ref</literal></title>
  737. <para>Defines a reference to a Spring bean that implements <interfacename>HttpFirewall</interfacename>.</para>
  738. </section>
  739. </section>
  740. </section>
  741. <section xml:id="nsa-intercept-url">
  742. <title><literal>&lt;intercept-url&gt;</literal></title>
  743. <para>This element is used to define the set of URL patterns that the application is
  744. interested in and to configure how they should be handled. It is used to construct
  745. the <interfacename>FilterInvocationSecurityMetadataSource</interfacename> used by
  746. the <classname>FilterSecurityInterceptor</classname>. It is also responsible for
  747. configuring a <classname>ChannelProcessingFilter</classname> if particular URLs
  748. need to be accessed by HTTPS, for example. When matching the specified patterns
  749. against an incoming request, the matching is done in the order in which the elements
  750. are declared. So the most specific matches patterns should come first and the most
  751. general should come last.</para>
  752. <section xml:id="nsa-intercept-url-parents">
  753. <title>Parent Elements of <literal>&lt;intercept-url&gt;</literal></title>
  754. <itemizedlist>
  755. <listitem><link linkend="nsa-filter-invocation-definition-source">filter-invocation-definition-source</link></listitem>
  756. <listitem><link linkend="nsa-filter-security-metadata-source">filter-security-metadata-source</link></listitem>
  757. <listitem><link linkend="nsa-http">http</link></listitem>
  758. </itemizedlist>
  759. </section>
  760. <section xml:id="nsa-intercept-url-attributes">
  761. <title><literal>&lt;intercept-url&gt;</literal> Attributes</title>
  762. <section xml:id="nsa-intercept-url-access">
  763. <title><literal>access</literal></title>
  764. <para>Lists the access attributes which will be stored in the
  765. <interfacename>FilterInvocationSecurityMetadataSource</interfacename> for the
  766. defined URL pattern/method combination. This should be a comma-separated list of
  767. the security configuration attributes (such as role names).</para>
  768. </section>
  769. <section xml:id="nsa-intercept-url-filters">
  770. <title><literal>filters</literal></title>
  771. <para>Can only take the value <quote>none</quote>. This will cause any matching
  772. request to bypass the Spring Security filter chain entirely. None of the rest of
  773. the <literal>&lt;http&gt;</literal> configuration will have any effect on the
  774. request and there will be no security context available for its duration. Access
  775. to secured methods during the request will fail.</para>
  776. </section>
  777. <section xml:id="nsa-intercept-url-method">
  778. <title><literal>method</literal></title>
  779. <para>The HTTP Method which will be used in combination with the pattern to match
  780. an incoming request. If omitted, any method will match. If an identical pattern
  781. is specified with and without a method, the method-specific match will take
  782. precedence.</para>
  783. </section>
  784. <section xml:id="nsa-intercept-url-pattern">
  785. <title><literal>pattern</literal></title>
  786. <para>The pattern which defines the URL path. The content will depend on the
  787. <literal>request-matcher</literal> attribute from the containing http element,
  788. so will default to ant path syntax.</para>
  789. </section>
  790. <section xml:id="nsa-intercept-url-requires-channel">
  791. <title><literal>requires-channel</literal></title>
  792. <para>Can be <quote>http</quote> or <quote>https</quote> depending on whether a
  793. particular URL pattern should be accessed over HTTP or HTTPS respectively.
  794. Alternatively the value <quote>any</quote> can be used when there is no
  795. preference. If this attribute is present on any
  796. <literal>&lt;intercept-url&gt;</literal> element, then a
  797. <classname>ChannelProcessingFilter</classname> will be added to the filter
  798. stack and its additional dependencies added to the application
  799. context.<!--See the chapter on <link
  800. linkend="channel-security-config">channel security</link> for an example
  801. configuration using traditional beans. --></para>
  802. <para>If a <literal>&lt;port-mappings&gt;</literal> configuration is added, this
  803. will be used to by the <classname>SecureChannelProcessor</classname> and
  804. <classname>InsecureChannelProcessor</classname> beans to determine the ports
  805. used for redirecting to HTTP/HTTPS. </para>
  806. </section>
  807. </section>
  808. </section>
  809. <section xml:id="nsa-jee">
  810. <title><literal>&lt;jee&gt;</literal></title>
  811. <para>Adds a J2eePreAuthenticatedProcessingFilter to the filter chain to provide integration with container
  812. authentication.</para>
  813. <section xml:id="nsa-jee-parents">
  814. <title>Parent Elements of <literal>&lt;jee&gt;</literal></title>
  815. <itemizedlist>
  816. <listitem><link linkend="nsa-http">http</link></listitem>
  817. </itemizedlist>
  818. </section>
  819. <section xml:id="nsa-jee-attributes">
  820. <title><literal>&lt;jee&gt;</literal> Attributes</title>
  821. <section xml:id="nsa-jee-mappable-roles">
  822. <title><literal>mappable-roles</literal></title>
  823. <para>A comma-separate list of roles to look for in the incoming HttpServletRequest.</para>
  824. </section>
  825. <section xml:id="nsa-jee-user-service-ref">
  826. <title><literal>user-service-ref</literal></title>
  827. <para>A reference to a user-service (or UserDetailsService bean) Id</para>
  828. </section>
  829. </section>
  830. </section>
  831. <section xml:id="nsa-logout">
  832. <title><literal>&lt;logout&gt;</literal></title>
  833. <para>Adds a <classname>LogoutFilter</classname> to the filter stack. This is
  834. configured with a <classname>SecurityContextLogoutHandler</classname>.</para>
  835. <section xml:id="nsa-logout-parents">
  836. <title>Parent Elements of <literal>&lt;logout&gt;</literal></title>
  837. <itemizedlist>
  838. <listitem><link linkend="nsa-http">http</link></listitem>
  839. </itemizedlist>
  840. </section>
  841. <section xml:id="nsa-logout-attributes">
  842. <title><literal>&lt;logout&gt;</literal> Attributes</title>
  843. <section xml:id="nsa-logout-delete-cookies">
  844. <title>The <literal>delete-cookies</literal> attribute</title>
  845. <para>A comma-separated list of the names of cookies which should be deleted when the user logs out.
  846. </para>
  847. </section>
  848. <section xml:id="nsa-logout-invalidate-session">
  849. <title>The <literal>invalidate-session</literal> attribute</title>
  850. <para> Maps to the <literal>invalidateHttpSession</literal> of the
  851. <classname>SecurityContextLogoutHandler</classname>. Defaults to "true", so the
  852. session will be invalidated on logout.</para>
  853. </section>
  854. <section xml:id="nsa-logout-logout-success-url">
  855. <title>The <literal>logout-success-url</literal> attribute</title>
  856. <para>The destination URL which the user will be taken to after logging out.
  857. Defaults to "/". </para>
  858. <para>Setting this attribute will inject the <classname>SessionManagementFilter</classname>
  859. with a <classname>SimpleRedirectInvalidSessionStrategy</classname> configured with
  860. the attribute value. When an invalid session ID is submitted, the strategy will be invoked,
  861. redirecting to the configured URL.</para>
  862. </section>
  863. <section xml:id="nsa-logout-logout-url">
  864. <title>The <literal>logout-url</literal> attribute</title>
  865. <para> The URL which will cause a logout (i.e. which will be processed by the
  866. filter). Defaults to "/j_spring_security_logout". </para>
  867. </section>
  868. <section xml:id="nsa-logout-success-handler-ref">
  869. <title>The <literal>success-handler-ref</literal> attribute</title>
  870. <para>May be used to supply an instance of <interfacename>LogoutSuccessHandler</interfacename>
  871. which will be invoked to control the navigation after logging out.
  872. </para>
  873. </section>
  874. </section>
  875. </section>
  876. <section xml:id="nsa-openid-login">
  877. <title><literal>&lt;openid-login&gt;</literal></title>
  878. <para> Similar to <literal>&lt;form-login&gt;</literal> and has the same attributes. The
  879. default value for <literal>login-processing-url</literal> is
  880. "/j_spring_openid_security_check". An
  881. <classname>OpenIDAuthenticationFilter</classname> and
  882. <classname>OpenIDAuthenticationProvider</classname> will be registered. The latter
  883. requires a reference to a <interfacename>UserDetailsService</interfacename>. Again,
  884. this can be specified by <literal>id</literal>, using the <literal>user-service-ref</literal>
  885. attribute, or will be located automatically in the application context. </para>
  886. <section xml:id="nsa-openid-login-parents">
  887. <title>Parent Elements of <literal>&lt;openid-login&gt;</literal></title>
  888. <itemizedlist>
  889. <listitem><link linkend="nsa-http">http</link></listitem>
  890. </itemizedlist>
  891. </section>
  892. <section xml:id="nsa-openid-login-attributes">
  893. <title><literal>&lt;openid-login&gt;</literal> Attributes</title>
  894. <section xml:id="nsa-openid-login-always-use-default-target">
  895. <title><literal>always-use-default-target</literal></title>
  896. <para>Whether the user should always be redirected to the default-target-url after login.</para>
  897. </section>
  898. <section xml:id="nsa-openid-login-authentication-details-source-ref">
  899. <title><literal>authentication-details-source-ref</literal></title>
  900. <para>Reference to an AuthenticationDetailsSource which will be used by the authentication filter</para>
  901. </section>
  902. <section xml:id="nsa-openid-login-authentication-failure-handler-ref">
  903. <title><literal>authentication-failure-handler-ref</literal></title>
  904. <para>Reference to an AuthenticationFailureHandler bean which should be used to handle a failed
  905. authentication request. Should not be used in combination with authentication-failure-url as the
  906. implementation should always deal with navigation to the subsequent destination</para>
  907. </section>
  908. <section xml:id="nsa-openid-login-authentication-failure-url">
  909. <title><literal>authentication-failure-url</literal></title>
  910. <para>The URL for the login failure page. If no login failure URL is specified, Spring Security will
  911. automatically create a failure login URL at /spring_security_login?login_error and a corresponding
  912. filter to render that login failure URL when requested.</para>
  913. </section>
  914. <section xml:id="nsa-openid-login-authentication-success-handler-ref">
  915. <title><literal>authentication-success-handler-ref</literal></title>
  916. <para>Reference to an AuthenticationSuccessHandler bean which should be used to handle a successful
  917. authentication request. Should not be used in combination with
  918. <link linkend="nsa-openid-login-default-target-url">default-target-url</link> (or
  919. <link linkend="nsa-openid-login-always-use-default-target">
  920. always-use-default-target</link>) as the implementation should always deal with navigation
  921. to the subsequent destination</para>
  922. </section>
  923. <section xml:id="nsa-openid-login-default-target-url">
  924. <title><literal>default-target-url</literal></title>
  925. <para>The URL that will be redirected to after successful authentication, if the user's previous action
  926. could not be resumed. This generally happens if the user visits a login page without having first requested a
  927. secured operation that triggers authentication. If unspecified, defaults to the root of the application.</para>
  928. </section>
  929. <section xml:id="nsa-openid-login-login-page">
  930. <title><literal>login-page</literal></title>
  931. <para>The URL for the login page. If no login URL is specified, Spring Security will automatically
  932. create a login URL at /spring_security_login and a corresponding filter to render that login URL when requested.
  933. </para>
  934. </section>
  935. <section xml:id="nsa-openid-login-login-processing-url">
  936. <title><literal>login-processing-url</literal></title>
  937. <para>The URL that the login form is posted to. If unspecified, it defaults to /j_spring_security_check.</para>
  938. </section>
  939. <section xml:id="nsa-openid-login-password-parameter">
  940. <title><literal>password-parameter</literal></title>
  941. <para>The name of the request parameter which contains the password. Defaults to "j_password".</para>
  942. </section>
  943. <section xml:id="nsa-openid-login-user-service-ref">
  944. <title><literal>user-service-ref</literal></title>
  945. <para>A reference to a user-service (or UserDetailsService bean) Id</para>
  946. </section>
  947. <section xml:id="nsa-openid-login-username-parameter">
  948. <title><literal>username-parameter</literal></title>
  949. <para>The name of the request parameter which contains the username. Defaults to "j_username".</para>
  950. </section>
  951. </section>
  952. <section xml:id="nsa-openid-login-children">
  953. <title>Child Elements of &lt;openid-login&gt;</title>
  954. <itemizedlist>
  955. <listitem><link linkend="nsa-attribute-exchange">attribute-exchange</link></listitem>
  956. </itemizedlist>
  957. </section>
  958. </section>
  959. <section xml:id="nsa-attribute-exchange">
  960. <title><literal>&lt;attribute-exchange&gt;</literal></title>
  961. <para>The <literal>attribute-exchange</literal> element defines the list of
  962. attributes which should be requested from the identity provider. An example can be found
  963. in the <link linkend="ns-openid">OpenID Support</link> section of the namespace configuration
  964. chapter. More than one can be used, in which case each must have an <literal>identifier-match</literal>
  965. attribute, containing a regular expression which is matched against the supplied
  966. OpenID identifier. This allows different attribute lists to be fetched from
  967. different providers (Google, Yahoo etc).</para>
  968. <section xml:id="nsa-attribute-exchange-parents">
  969. <title>Parent Elements of <literal>&lt;attribute-exchange&gt;</literal></title>
  970. <itemizedlist>
  971. <listitem><link linkend="nsa-openid-login">openid-login</link></listitem>
  972. </itemizedlist>
  973. </section>
  974. <section xml:id="nsa-attribute-exchange-attributes">
  975. <title><literal>&lt;attribute-exchange&gt;</literal> Attributes</title>
  976. <section xml:id="nsa-attribute-exchange-identifier-match">
  977. <title><literal>identifier-match</literal></title>
  978. <para>A regular expression which will be compared against the claimed identity, when deciding which
  979. attribute-exchange configuration to use during authentication.</para>
  980. </section>
  981. </section>
  982. <section xml:id="nsa-attribute-exchange-children">
  983. <title>Child Elements of <literal>&lt;attribute-exchange&gt;</literal></title>
  984. <itemizedlist>
  985. <listitem><link linkend="nsa-openid-attribute">openid-attribute</link></listitem>
  986. </itemizedlist>
  987. </section>
  988. </section>
  989. <section xml:id="nsa-openid-attribute">
  990. <title><literal>&lt;openid-attribute&gt;</literal></title>
  991. <para>Attributes used when making an OpenID AX
  992. <link xlink:href="http://openid.net/specs/openid-attribute-exchange-1_0.html#fetch_request">
  993. Fetch Request</link></para>
  994. <section xml:id="nsa-openid-attribute-parents">
  995. <title>Parent Elements of <literal>&lt;openid-attribute&gt;</literal></title>
  996. <itemizedlist>
  997. <listitem><link linkend="nsa-attribute-exchange">attribute-exchange</link></listitem>
  998. </itemizedlist>
  999. </section>
  1000. <section xml:id="nsa-openid-attribute-attributes">
  1001. <title><literal>&lt;openid-attribute&gt;</literal> Attributes</title>
  1002. <section xml:id="nsa-openid-attribute-count">
  1003. <title><literal>count</literal></title>
  1004. <para>Specifies the number of attributes that you wish to get back. For example, return 3 emails.
  1005. The default value is 1.</para>
  1006. </section>
  1007. <section xml:id="nsa-openid-attribute-name">
  1008. <title><literal>name</literal></title>
  1009. <para>Specifies the name of the attribute that you wish to get back. For example, email.</para>
  1010. </section>
  1011. <section xml:id="nsa-openid-attribute-required">
  1012. <title><literal>required</literal></title>
  1013. <para>Specifies if this attribute is required to the OP, but does not error out if the OP does not
  1014. return the attribute. Default is false.</para>
  1015. </section>
  1016. <section xml:id="nsa-openid-attribute-type">
  1017. <title><literal>type</literal></title>
  1018. <para>Specifies the attribute type. For example, http://axschema.org/contact/email. See your OP's
  1019. documentation for valid attribute types.</para>
  1020. </section>
  1021. </section>
  1022. </section>
  1023. <section xml:id="nsa-port-mappings">
  1024. <title><literal>&lt;port-mappings&gt;</literal></title>
  1025. <para> By default, an instance of <classname>PortMapperImpl</classname> will be added to
  1026. the configuration for use in redirecting to secure and insecure URLs. This element
  1027. can optionally be used to override the default mappings which that class defines.
  1028. Each child <literal>&lt;port-mapping&gt;</literal> element defines a pair of
  1029. HTTP:HTTPS ports. The default mappings are 80:443 and 8080:8443. An example of
  1030. overriding these can be found in the <link linkend="ns-requires-channel"
  1031. >namespace introduction</link>. </para>
  1032. <section xml:id="nsa-port-mappings-parents">
  1033. <title>Parent Elements of <literal>&lt;port-mappings&gt;</literal></title>
  1034. <itemizedlist>
  1035. <listitem><link linkend="nsa-http">http</link></listitem>
  1036. </itemizedlist>
  1037. </section>
  1038. <section xml:id="nsa-port-mappings-children">
  1039. <title>Child Elements of <literal>&lt;port-mappings&gt;</literal></title>
  1040. <itemizedlist>
  1041. <listitem><link linkend="nsa-port-mapping">port-mapping</link></listitem>
  1042. </itemizedlist>
  1043. </section>
  1044. </section>
  1045. <section xml:id="nsa-port-mapping">
  1046. <title><literal>&lt;port-mapping&gt;</literal></title>
  1047. <para>Provides a method to map http ports to https ports when forcing a redirect.</para>
  1048. <section xml:id="nsa-port-mapping-parents">
  1049. <title>Parent Elements of <literal>&lt;port-mapping&gt;</literal></title>
  1050. <itemizedlist>
  1051. <listitem><link linkend="nsa-port-mappings">port-mappings</link></listitem>
  1052. </itemizedlist>
  1053. </section>
  1054. <section xml:id="nsa-port-mapping-attributes">
  1055. <title><literal>&lt;port-mapping&gt;</literal> Attributes</title>
  1056. <section xml:id="nsa-port-mapping-http">
  1057. <title><literal>http</literal></title>
  1058. <para>The http port to use.</para>
  1059. </section>
  1060. <section xml:id="nsa-port-mapping-https">
  1061. <title><literal>https</literal></title>
  1062. <para>The https port to use.</para>
  1063. </section>
  1064. </section>
  1065. </section>
  1066. <section xml:id="nsa-remember-me">
  1067. <title><literal>&lt;remember-me&gt;</literal></title>
  1068. <para> Adds the <classname>RememberMeAuthenticationFilter</classname> to the stack. This
  1069. in turn will be configured with either a
  1070. <classname>TokenBasedRememberMeServices</classname>, a
  1071. <classname>PersistentTokenBasedRememberMeServices</classname> or a user-specified
  1072. bean implementing <interfacename>RememberMeServices</interfacename> depending on the
  1073. attribute settings. </para>
  1074. <section xml:id="nsa-remember-me-parents">
  1075. <title>Parent Elements of <literal>&lt;remember-me&gt;</literal></title>
  1076. <itemizedlist>
  1077. <listitem><link linkend="nsa-http">http</link></listitem>
  1078. </itemizedlist>
  1079. </section>
  1080. <section xml:id="nsa-remember-me-attributes">
  1081. <title><literal>&lt;remember-me&gt;</literal> Attributes</title>
  1082. <section xml:id="nsa-remember-me-authentication-success-handler-ref">
  1083. <title><literal>authentication-success-handler-ref</literal></title>
  1084. <para>Sets the <code>authenticationSuccessHandler</code> property on the
  1085. <classname>RememberMeAuthenticationFilter</classname> if custom navigation is required.
  1086. The value should be the name of a <interfacename>AuthenticationSuccessHandler</interfacename>
  1087. bean in the application context. </para>
  1088. </section>
  1089. <section xml:id="nsa-remember-me-data-source-ref">
  1090. <title><literal>data-source-ref</literal></title>
  1091. <para>A reference to a <interfacename>DataSource</interfacename> bean. If this is set,
  1092. <classname>PersistentTokenBasedRememberMeServices</classname> will be used and configured with a
  1093. <classname>JdbcTokenRepositoryImpl</classname> instance. </para>
  1094. </section>
  1095. <section xml:id="nsa-remember-me-remember-me-parameter">
  1096. <title><literal>remember-me-parameter</literal></title>
  1097. <para>The name of the request parameter which toggles remember-me authentication. Defaults to "_spring_security_remember_me".
  1098. Maps to the "parameter" property of <classname>AbstractRememberMeServices</classname>.</para>
  1099. </section>
  1100. <section xml:id="nsa-remember-me-key">
  1101. <title><literal>key</literal></title>
  1102. <para>Maps to the "key" property of
  1103. <classname>AbstractRememberMeServices</classname>. Should be set to a unique
  1104. value to ensure that remember-me cookies are only valid within the one
  1105. application <footnote>
  1106. <para>This doesn't affect the use of
  1107. <classname>PersistentTokenBasedRememberMeServices</classname>, where the
  1108. tokens are stored on the server side.</para>
  1109. </footnote>. If this is not set a secure random value will be generated. Since generating secure
  1110. random values can take a while, setting this value explicitly can help improve startup times when
  1111. using the remember me functionality.</para>
  1112. </section>
  1113. <section xml:id="nsa-remember-me-services-alias">
  1114. <title><literal>services-alias</literal></title>
  1115. <para>Exports the internally defined <interfacename>RememberMeServices</interfacename> as a bean alias,
  1116. allowing it to be used by other beans in the application context.</para>
  1117. </section>
  1118. <section xml:id="nsa-remember-me-services-ref">
  1119. <title><literal>services-ref</literal></title>
  1120. <para> Allows complete control of the
  1121. <interfacename>RememberMeServices</interfacename> implementation that will be
  1122. used by the filter. The value should be the <literal>id</literal> of a bean in the application
  1123. context which implements this interface. Should also implement
  1124. <interfacename>LogoutHandler</interfacename> if a logout filter is in use.</para>
  1125. </section>
  1126. <section xml:id="nsa-remember-me-token-repository-ref">
  1127. <title><literal>token-repository-ref</literal></title>
  1128. <para> Configures a <classname>PersistentTokenBasedRememberMeServices</classname>
  1129. but allows the use of a custom
  1130. <interfacename>PersistentTokenRepository</interfacename> bean. </para>
  1131. </section>
  1132. <section xml:id="nsa-remember-me-token-validity-seconds">
  1133. <title><literal>token-validity-seconds</literal></title>
  1134. <para> Maps to the <literal>tokenValiditySeconds</literal> property of
  1135. <classname>AbstractRememberMeServices</classname>. Specifies the period in
  1136. seconds for which the remember-me cookie should be valid. By default it will be
  1137. valid for 14 days. </para>
  1138. </section>
  1139. <section xml:id="nsa-remember-me-use-secure-cookie">
  1140. <title><literal>use-secure-cookie</literal></title>
  1141. <para>It is recommended that remember-me cookies are only submitted over HTTPS and thus should
  1142. be flagged as <quote>secure</quote>. By default, a secure cookie will be used if the
  1143. connection over which the login request is made is secure (as it should be).
  1144. If you set this property to <literal>false</literal>, secure cookies will not be used.
  1145. Setting it to <literal>true</literal> will always set the secure flag on the cookie.
  1146. This attribute maps to the <literal>useSecureCookie</literal> property of
  1147. <classname>AbstractRememberMeServices</classname>.
  1148. </para>
  1149. </section>
  1150. <section xml:id="nsa-remember-me-user-service-ref">
  1151. <title><literal>user-service-ref</literal></title>
  1152. <para> The remember-me services implementations require access to a
  1153. <interfacename>UserDetailsService</interfacename>, so there has to be one
  1154. defined in the application context. If there is only one, it will be selected
  1155. and used automatically by the namespace configuration. If there are multiple
  1156. instances, you can specify a bean <literal>id</literal> explicitly using this attribute. </para>
  1157. </section>
  1158. </section>
  1159. </section>
  1160. <section xml:id="nsa-request-cache">
  1161. <title><literal>&lt;request-cache></literal> Element</title>
  1162. <para>Sets the <interfacename>RequestCache</interfacename> instance which will be used
  1163. by the <classname>ExceptionTranslationFilter</classname> to store request
  1164. information before invoking an
  1165. <interfacename>AuthenticationEntryPoint</interfacename>. </para>
  1166. <section xml:id="nsa-request-cache-parents">
  1167. <title>Parent Elements of <literal>&lt;request-cache&gt;</literal></title>
  1168. <itemizedlist>
  1169. <listitem><link linkend="nsa-http">http</link></listitem>
  1170. </itemizedlist>
  1171. </section>
  1172. <section xml:id="nsa-request-cache-attributes">
  1173. <title><literal>&lt;request-cache&gt;</literal> Attributes</title>
  1174. <section xml:id="nsa-request-cache-ref">
  1175. <title><literal>ref</literal></title>
  1176. <para>Defines a reference to a Spring bean that is a <interfacename>RequestCache</interfacename>.</para>
  1177. </section>
  1178. </section>
  1179. </section>
  1180. <section xml:id="nsa-session-management">
  1181. <title><literal>&lt;session-management&gt;</literal></title>
  1182. <para> Session-management related functionality is implemented by the addition of a
  1183. <classname>SessionManagementFilter</classname> to the filter stack.</para>
  1184. <section xml:id="nsa-session-management-parents">
  1185. <title>Parent Elements of <literal>&lt;session-management&gt;</literal></title>
  1186. <itemizedlist>
  1187. <listitem><link linkend="nsa-http">http</link></listitem>
  1188. </itemizedlist>
  1189. </section>
  1190. <section xml:id="nsa-session-management-attributes">
  1191. <title><literal>&lt;session-management&gt;</literal> Attributes</title>
  1192. <section xml:id="nsa-session-management-invalid-session-url">
  1193. <title><literal>invalid-session-url</literal></title>
  1194. <para>Setting this attribute will inject the <classname>SessionManagementFilter</classname>
  1195. with a <classname>SimpleRedirectInvalidSessionStrategy</classname> configured with
  1196. the attribute value. When an invalid session ID is submitted, the strategy will be invoked,
  1197. redirecting to the configured URL.
  1198. </para>
  1199. </section>
  1200. <section xml:id="nsa-session-management-session-authentication-error-url">
  1201. <title><literal>session-authentication-error-url</literal></title>
  1202. <para>Defines the URL of the error page which should be shown when the SessionAuthenticationStrategy
  1203. raises an exception. If not set, an unauthorized (401) error code will be returned to the client.
  1204. Note that this attribute doesn't apply if the error occurs during a form-based login, where the URL
  1205. for authentication failure will take precedence.</para>
  1206. </section>
  1207. <section xml:id="nsa-session-management-session-authentication-strategy-ref">
  1208. <title><literal>session-authentication-strategy-ref</literal></title>
  1209. <para>Allows injection of the SessionAuthenticationStrategy instance used by the
  1210. SessionManagementFilter</para>
  1211. </section>
  1212. <section xml:id="nsa-session-management-session-fixation-protection">
  1213. <title><literal>session-fixation-protection</literal></title>
  1214. <para>Indicates how session fixation protection will be applied when a user authenticates. If
  1215. set to "none", no protection will be applied. "newSession" will create a
  1216. new empty session, with only Spring Security-related attributes migrated. "migrateSession" will create
  1217. a new session and copy all session attributes to the new session. In Servlet 3.1 (Java EE 7)
  1218. and newer containers, specifying "changeSessionId" will keep the existing session and use the
  1219. container-supplied session fixation protection (HttpServletRequest#changeSessionId()). Defaults to
  1220. "changeSessionId" in Servlet 3.1 and newer containers, "migrateSession" in older containers. Throws an
  1221. exception if "changeSessionId" is used in older containers.</para>
  1222. <para> If session fixation protection is enabled, the
  1223. <classname>SessionManagementFilter</classname> is injected with an appropriately
  1224. configured <classname>DefaultSessionAuthenticationStrategy</classname>. See the
  1225. Javadoc for this class for more details. </para>
  1226. </section>
  1227. </section>
  1228. <section xml:id="nsa-session-management-children">
  1229. <title>Child elements of <literal>&lt;session-management&gt;</literal></title>
  1230. <itemizedlist>
  1231. <listitem><link linkend="nsa-concurrency-control">concurrency-control</link></listitem>
  1232. </itemizedlist>
  1233. </section>
  1234. </section>
  1235. <section xml:id="nsa-concurrency-control">
  1236. <title><literal>&lt;concurrency-control&gt;</literal></title>
  1237. <para> Adds support for concurrent session control, allowing limits to be placed on the
  1238. number of active sessions a user can have. A
  1239. <classname>ConcurrentSessionFilter</classname> will be created, and a
  1240. <classname>ConcurrentSessionControlAuthenticationStrategy</classname> will be used with the
  1241. <classname>SessionManagementFilter</classname>. If a <literal>form-login</literal>
  1242. element has been declared, the strategy object will also be injected into the
  1243. created authentication filter. An instance of
  1244. <interfacename>SessionRegistry</interfacename> (a
  1245. <classname>SessionRegistryImpl</classname> instance unless the user wishes to use a
  1246. custom bean) will be created for use by the strategy.</para>
  1247. <section xml:id="nsa-concurrency-control-parents">
  1248. <title>Parent Elements of <literal>&lt;concurrency-control&gt;</literal></title>
  1249. <itemizedlist>
  1250. <listitem><link linkend="nsa-session-management">session-management</link></listitem>
  1251. </itemizedlist>
  1252. </section>
  1253. <section xml:id="nsa-concurrency-control-attributes">
  1254. <title><literal>&lt;concurrency-control&gt;</literal> Attributes</title>
  1255. <section xml:id="nsa-concurrency-control-error-if-maximum-exceeded">
  1256. <title><literal>error-if-maximum-exceeded</literal></title>
  1257. <para>If set to "true" a
  1258. <exceptionname>SessionAuthenticationException</exceptionname> will be raised
  1259. when a user attempts to exceed the maximum allowed number of sessions. The
  1260. default behaviour is to expire the original session. </para>
  1261. </section>
  1262. <section xml:id="nsa-concurrency-control-expired-url">
  1263. <title><literal>expired-url</literal></title>
  1264. <para> The URL a user will be redirected to if they attempt to use a session which
  1265. has been "expired" by the concurrent session controller because the user has
  1266. exceeded the number of allowed sessions and has logged in again elsewhere.
  1267. Should be set unless <literal>exception-if-maximum-exceeded</literal> is set. If
  1268. no value is supplied, an expiry message will just be written directly back to
  1269. the response. </para>
  1270. </section>
  1271. <section xml:id="nsa-concurrency-control-max-sessions">
  1272. <title><literal>max-sessions</literal></title>
  1273. <para>Maps to the <literal>maximumSessions</literal> property of
  1274. <classname>ConcurrentSessionControlAuthenticationStrategy</classname>.</para>
  1275. </section>
  1276. <section xml:id="nsa-concurrency-control-session-registry-alias">
  1277. <title><literal>session-registry-alias</literal></title>
  1278. <para> It can also be useful to have a reference to the internal session registry
  1279. for use in your own beans or an admin interface. You can expose the internal bean
  1280. using the <literal>session-registry-alias</literal> attribute, giving it a name
  1281. that you can use elsewhere in your configuration. </para>
  1282. </section>
  1283. <section xml:id="nsa-concurrency-control-session-registry-ref">
  1284. <title><literal>session-registry-ref</literal></title>
  1285. <para> The user can supply their own <interfacename>SessionRegistry</interfacename>
  1286. implementation using the <literal>session-registry-ref</literal> attribute. The
  1287. other concurrent session control beans will be wired up to use it. </para>
  1288. </section>
  1289. </section>
  1290. </section>
  1291. <section xml:id="nsa-x509">
  1292. <title><literal>&lt;x509&gt;</literal></title>
  1293. <para> Adds support for X.509 authentication. An
  1294. <classname>X509AuthenticationFilter</classname> will be added to the stack and an
  1295. <classname>Http403ForbiddenEntryPoint</classname> bean will be created. The latter
  1296. will only be used if no other authentication mechanisms are in use (its only
  1297. functionality is to return an HTTP 403 error code). A
  1298. <classname>PreAuthenticatedAuthenticationProvider</classname> will also be created
  1299. which delegates the loading of user authorities to a
  1300. <interfacename>UserDetailsService</interfacename>. </para>
  1301. <section xml:id="nsa-x509-parents">
  1302. <title>Parent Elements of <literal>&lt;x509&gt;</literal></title>
  1303. <itemizedlist>
  1304. <listitem><link linkend="nsa-http">http</link></listitem>
  1305. </itemizedlist>
  1306. </section>
  1307. <section xml:id="nsa-x509-attributes">
  1308. <title><literal>&lt;x509&gt;</literal> Attributes</title>
  1309. <section xml:id="nsa-x509-authentication-details-source-ref">
  1310. <title><literal>authentication-details-source-ref</literal></title>
  1311. <para>A reference to an <interfacename>AuthenticationDetailsSource</interfacename></para>
  1312. </section>
  1313. <section xml:id="nsa-x509-subject-principal-regex">
  1314. <title><literal>subject-principal-regex</literal></title>
  1315. <para> Defines a regular expression which will be used to extract the username from
  1316. the certificate (for use with the
  1317. <interfacename>UserDetailsService</interfacename>). </para>
  1318. </section>
  1319. <section xml:id="nsa-x509-user-service-ref">
  1320. <title><literal>user-service-ref</literal></title>
  1321. <para> Allows a specific <interfacename>UserDetailsService</interfacename> to be
  1322. used with X.509 in the case where multiple instances are configured. If not set,
  1323. an attempt will be made to locate a suitable instance automatically and use
  1324. that. </para>
  1325. </section>
  1326. </section>
  1327. </section>
  1328. <section xml:id="nsa-filter-chain-map">
  1329. <title><literal>&lt;filter-chain-map&gt;</literal></title>
  1330. <para>Used to explicitly configure a FilterChainProxy instance with a FilterChainMap</para>
  1331. <section xml:id="nsa-filter-chain-map-attributes">
  1332. <title><literal>&lt;filter-chain-map&gt;</literal> Attributes</title>
  1333. <section xml:id="nsa-filter-chain-map-path-type">
  1334. <title><literal>path-type</literal></title>
  1335. <para>Superseded by the
  1336. <link linkend="nsa-filter-chain-map-request-matcher">request-matcher</link> attribute</para>
  1337. </section>
  1338. <section xml:id="nsa-filter-chain-map-request-matcher">
  1339. <title><literal>request-matcher</literal></title>
  1340. <para>Supersedes the 'path-type' attribute. Defines the strategy use for matching incoming requests.
  1341. Currently the options are 'ant' (for ant path patterns), 'regex' for regular expressions and 'ciRegex' for
  1342. case-insensitive regular expressions.</para>
  1343. </section>
  1344. </section>
  1345. <section xml:id="nsa-filter-chain-map-children">
  1346. <title>Child Elements of <literal>&lt;filter-chain-map&gt;</literal></title>
  1347. <itemizedlist>
  1348. <listitem><link linkend="nsa-filter-chain">filter-chain</link></listitem>
  1349. </itemizedlist>
  1350. </section>
  1351. </section>
  1352. <section xml:id="nsa-filter-chain">
  1353. <title><literal>&lt;filter-chain&gt;</literal></title>
  1354. <para>Used within to define a specific URL pattern and the list of filters which apply to the URLs matching
  1355. that pattern. When multiple filter-chain elements are assembled in a list in order to configure a FilterChainProxy,
  1356. the most specific patterns must be placed at the top of the list, with most general ones at the bottom.</para>
  1357. <section xml:id="nsa-filter-chain-parents">
  1358. <title>Parent Elements of <literal>&lt;filter-chain&gt;</literal></title>
  1359. <itemizedlist>
  1360. <listitem><link linkend="nsa-filter-chain-map">filter-chain-map</link></listitem>
  1361. </itemizedlist>
  1362. </section>
  1363. <section xml:id="nsa-filter-chain-attributes">
  1364. <title><literal>&lt;filter-chain&gt;</literal> Attributes</title>
  1365. <section xml:id="nsa-filter-chain-filters">
  1366. <title><literal>filters</literal></title>
  1367. <para>A comma separated list of references to Spring beans that implement
  1368. <interfacename>Filter</interfacename>. The value "none" means that no
  1369. <interfacename>Filter</interfacename>'s should be used for this
  1370. <classname>FilterChain</classname>.</para>
  1371. </section>
  1372. <section xml:id="nsa-filter-chain-pattern">
  1373. <title><literal>pattern</literal></title>
  1374. <para>A-pattern that creates RequestMatcher in combination with the
  1375. <link linkend="nsa-filter-chain-map-request-matcher">request-matcher</link></para>
  1376. </section>
  1377. <section xml:id="nsa-filter-chain-request-matcher-ref">
  1378. <title><literal>request-matcher-ref</literal></title>
  1379. <para>A reference to a <interfacename>RequestMatcher</interfacename> that will be used to determine if the
  1380. <interfacename>Filter</interfacename>'s from the <literal>filters</literal> attribute should be invoked.</para>
  1381. </section>
  1382. </section>
  1383. </section>
  1384. <section xml:id="nsa-filter-invocation-definition-source">
  1385. <title><literal>&lt;filter-invocation-definition-source&gt;</literal></title>
  1386. <para>Deprecated synonym for filter-security-metadata-source</para>
  1387. <section xml:id="nsa-filter-invocation-definition-source-attributes">
  1388. <title><literal>&lt;filter-invocation-definition-source&gt;</literal> Attributes</title>
  1389. <section xml:id="nsa-filter-invocation-definition-source-id">
  1390. <title><literal>id</literal></title>
  1391. <para>A bean identifier, used for referring to the bean elsewhere in the context.</para>
  1392. </section>
  1393. <section xml:id="nsa-filter-invocation-definition-source-lowercase-comparisons">
  1394. <title><literal>lowercase-comparisons</literal></title>
  1395. <para>Compare after forcing to lowercase</para>
  1396. </section>
  1397. <section xml:id="nsa-filter-invocation-definition-source-path-type">
  1398. <title><literal>path-type</literal></title>
  1399. <para>Superseded by
  1400. <link linkend="nsa-filter-invocation-definition-source-request-matcher">request-matcher</link></para>
  1401. </section>
  1402. <section xml:id="nsa-filter-invocation-definition-source-request-matcher">
  1403. <title><literal>request-matcher</literal></title>
  1404. <para>Supersedes the 'path-type' attribute. Defines the strategy use for matching incoming requests.
  1405. Currently the options are 'ant' (for ant path patterns), 'regex' for regular expressions and 'ciRegex' for
  1406. case-insensitive regular expressions.</para>
  1407. </section>
  1408. <section xml:id="nsa-filter-invocation-definition-source-use-expressions">
  1409. <title><literal>use-expressions</literal></title>
  1410. <para>Enables the use of expressions in the 'access' attributes in &lt;intercept-url&gt; elements
  1411. rather than the traditional list of configuration attributes. Defaults to 'false'. If
  1412. enabled, each attribute should contain a single boolean expression. If the expression evaluates to 'true', access will be
  1413. granted.</para>
  1414. </section>
  1415. </section>
  1416. <section xml:id="nsa-filter-invocation-definition-source-children">
  1417. <title>Child Elements of <literal>&lt;filter-invocation-definition-source&gt;</literal></title>
  1418. <itemizedlist>
  1419. <listitem><link linkend="nsa-intercept-url">intercept-url</link></listitem>
  1420. </itemizedlist>
  1421. </section>
  1422. </section>
  1423. <section xml:id="nsa-filter-security-metadata-source">
  1424. <title><literal>&lt;filter-security-metadata-source&gt;</literal></title>
  1425. <para>Used to explicitly configure a FilterSecurityMetadataSource bean for use with a FilterSecurityInterceptor. Usually
  1426. only needed if you are configuring a FilterChainProxy explicitly, rather than using the
  1427. &lt;http&gt; element. The intercept-url elements used should only contain pattern, method and access attributes. Any
  1428. others will result in a configuration error.</para>
  1429. <section xml:id="nsa-filter-security-metadata-source-attributes">
  1430. <title><literal>&lt;filter-security-metadata-source&gt;</literal> Attributes</title>
  1431. <section xml:id="nsa-filter-security-metadata-source-id">
  1432. <title><literal>id</literal></title>
  1433. <para>A bean identifier, used for referring to the bean elsewhere in the context.</para>
  1434. </section>
  1435. <section xml:id="nsa-filter-security-metadata-source-lowercase-comparisons">
  1436. <title><literal>lowercase-comparisons</literal></title>
  1437. <para>Compare after forcing to lower case</para>
  1438. </section>
  1439. <section xml:id="nsa-filter-security-metadata-source-path-type">
  1440. <title><literal>path-type</literal></title>
  1441. <para>Superseded by
  1442. <link linkend="nsa-filter-security-metadata-source-request-matcher">request-matcher</link>
  1443. </para>
  1444. </section>
  1445. <section xml:id="nsa-filter-security-metadata-source-request-matcher">
  1446. <title><literal>request-matcher</literal></title>
  1447. <para>Supersedes the 'path-type' attribute. Defines the strategy use for matching incoming requests.
  1448. Currently the options are 'ant' (for ant path patterns), 'regex' for regular expressions and 'ciRegex' for
  1449. case-insensitive regular expressions.</para>
  1450. </section>
  1451. <section xml:id="nsa-filter-security-metadata-source-use-expressions">
  1452. <title><literal>use-expressions</literal></title>
  1453. <para>Enables the use of expressions in the 'access' attributes in
  1454. &lt;intercept-url&gt; elements rather than the traditional list of configuration attributes. Defaults to 'false'. If
  1455. enabled, each attribute should contain a single boolean expression. If the expression evaluates to 'true',
  1456. access will be granted.</para>
  1457. </section>
  1458. </section>
  1459. <section xml:id="nsa-filter-security-metadata-source-children">
  1460. <title>Child Elements of <literal>&lt;filter-security-metadata-source&gt;</literal></title>
  1461. <itemizedlist>
  1462. <listitem><link linkend="nsa-intercept-url">intercept-url</link></listitem>
  1463. </itemizedlist>
  1464. </section>
  1465. </section>
  1466. </section>
  1467. <section xml:id="nsa-authentication">
  1468. <title>Authentication Services</title>
  1469. <para> Before Spring Security 3.0, an <interfacename>AuthenticationManager</interfacename>
  1470. was automatically registered internally. Now you must register one explicitly using the
  1471. <literal>&lt;authentication-manager&gt;</literal> element. This creates an instance of
  1472. Spring Security's <classname>ProviderManager</classname> class, which needs to be
  1473. configured with a list of one or more
  1474. <interfacename>AuthenticationProvider</interfacename> instances. These can either be
  1475. created using syntax elements provided by the namespace, or they can be standard bean
  1476. definitions, marked for addition to the list using the
  1477. <literal>authentication-provider</literal> element. </para>
  1478. <section xml:id="nsa-authentication-manager">
  1479. <title><literal>&lt;authentication-manager&gt;</literal></title>
  1480. <para> Every Spring Security application which uses the namespace must have include this
  1481. element somewhere. It is responsible for registering the
  1482. <interfacename>AuthenticationManager</interfacename> which provides authentication
  1483. services to the application. All elements
  1484. which create <interfacename>AuthenticationProvider</interfacename> instances should
  1485. be children of this element.</para>
  1486. <section xml:id="nsa-authentication-manager-attributes">
  1487. <title><literal>&lt;authentication-manager&gt;</literal> Attributes</title>
  1488. <section xml:id="nsa-authentication-manager-alias">
  1489. <title><literal>alias</literal></title>
  1490. <para>This attribute allows you to define an alias name for the
  1491. internal instance for use in your own configuration. Its use is described in the
  1492. <link linkend="ns-auth-manager">namespace introduction</link>.</para>
  1493. </section>
  1494. <section xml:id="nsa-authentication-manager-erase-credentials">
  1495. <title><literal>erase-credentials</literal></title>
  1496. <para>If set to true, the AuthenticationManger will attempt to clear any credentials data in the
  1497. returned Authentication object, once the user has been authenticated. Literally it maps to
  1498. the <literal>eraseCredentialsAfterAuthentication</literal> property of the
  1499. <classname>ProviderManager</classname>. This is discussed in the <link
  1500. linkend="core-services-erasing-credentials">Core Services</link> chapter.</para>
  1501. </section>
  1502. <section xml:id="nsa-authentication-manager-id">
  1503. <title><literal>id</literal></title>
  1504. <para>This attribute allows you to define an id for the internal instance for use in your own
  1505. configuration. It is the same a the alias element, but provides a more consistent experience
  1506. with elements that use the id attribute.</para>
  1507. </section>
  1508. </section>
  1509. <section xml:id="nsa-authentication-manager-children">
  1510. <title>Child Elements of <literal>&lt;authentication-manager&gt;</literal></title>
  1511. <itemizedlist>
  1512. <listitem><link linkend="nsa-authentication-provider">authentication-provider</link></listitem>
  1513. <listitem><link linkend="nsa-ldap-authentication-provider">ldap-authentication-provider</link></listitem>
  1514. </itemizedlist>
  1515. </section>
  1516. </section>
  1517. <section xml:id="nsa-authentication-provider">
  1518. <title><literal>&lt;authentication-provider&gt;</literal></title>
  1519. <para> Unless used with a <literal>ref</literal> attribute, this element is
  1520. shorthand for configuring a <link linkend="core-services-dao-provider"
  1521. ><classname>DaoAuthenticationProvider</classname></link>.
  1522. <classname>DaoAuthenticationProvider</classname> loads user information from a
  1523. <interfacename>UserDetailsService</interfacename> and compares the
  1524. username/password combination with the values supplied at login. The
  1525. <interfacename>UserDetailsService</interfacename> instance can be defined either
  1526. by using an available namespace element (<literal>jdbc-user-service</literal> or
  1527. by using the <literal>user-service-ref</literal> attribute to point to a bean
  1528. defined elsewhere in the application context). You can find examples of these
  1529. variations in the <link linkend="ns-auth-providers">namespace
  1530. introduction</link>. </para>
  1531. <section xml:id="nsa-authentication-provider-parents">
  1532. <title>Parent Elements of <literal>&lt;authentication-provider&gt;</literal></title>
  1533. <itemizedlist>
  1534. <listitem><link linkend="nsa-authentication-manager">authentication-manager</link></listitem>
  1535. </itemizedlist>
  1536. </section>
  1537. <section xml:id="nsa-authentication-provider-attributes">
  1538. <title><literal>&lt;authentication-provider&gt;</literal> Attributes</title>
  1539. <section xml:id="nsa-authentication-provider-ref">
  1540. <title><literal>ref</literal></title>
  1541. <para>Defines a reference to a Spring bean that implements <interfacename>AuthenticationProvider
  1542. </interfacename>.</para>
  1543. <para> If you have written your own
  1544. <interfacename>AuthenticationProvider</interfacename> implementation (or want to
  1545. configure one of Spring Security's own implementations as a traditional bean for
  1546. some reason, then you can use the following syntax to add it to the internal
  1547. <classname>ProviderManager</classname>'s list: <programlisting language="xml"><![CDATA[
  1548. <security:authentication-manager>
  1549. <security:authentication-provider ref="myAuthenticationProvider" />
  1550. </security:authentication-manager>
  1551. <bean id="myAuthenticationProvider" class="com.something.MyAuthenticationProvider"/>
  1552. ]]></programlisting></para>
  1553. </section>
  1554. <section xml:id="nsa-authentication-provider-user-service-ref">
  1555. <title><literal>user-service-ref</literal></title>
  1556. <para>A reference to a bean that implements UserDetailsService that may be created using the standard bean
  1557. element or the custom user-service element.</para>
  1558. </section>
  1559. </section>
  1560. <section xml:id="nsa-authentication-provider-children">
  1561. <title>Child Elements of <literal>&lt;authentication-provider&gt;</literal></title>
  1562. <itemizedlist>
  1563. <listitem><link linkend="nsa-jdbc-user-service">jdbc-user-service</link></listitem>
  1564. <listitem><link linkend="nsa-ldap-user-service">ldap-user-service</link></listitem>
  1565. <listitem><link linkend="nsa-password-encoder">password-encoder</link></listitem>
  1566. <listitem><link linkend="nsa-user-service">user-service</link></listitem>
  1567. </itemizedlist>
  1568. </section>
  1569. </section>
  1570. <section xml:id="nsa-jdbc-user-service">
  1571. <title><literal>&lt;jdbc-user-service&gt;</literal></title>
  1572. <para>Causes creation of a JDBC-based UserDetailsService.</para>
  1573. <section xml:id="nsa-jdbc-user-service-attributes">
  1574. <title><literal>&lt;jdbc-user-service&gt;</literal> Attributes</title>
  1575. <section xml:id="nsa-jdbc-user-service-authorities-by-username-query">
  1576. <title><literal>authorities-by-username-query</literal></title>
  1577. <para>An SQL statement to query for a user's granted authorities given a username.</para>
  1578. <para>The default is
  1579. <programlisting><![CDATA[select username, authority from authorities where username = ?]]></programlisting></para>
  1580. </section>
  1581. <section xml:id="nsa-jdbc-user-service-cache-ref">
  1582. <title><literal>cache-ref</literal></title>
  1583. <para>Defines a reference to a cache for use with a UserDetailsService.</para>
  1584. </section>
  1585. <section xml:id="nsa-jdbc-user-service-data-source-ref">
  1586. <title><literal>data-source-ref</literal></title>
  1587. <para>The bean ID of the DataSource which provides the required tables.</para>
  1588. </section>
  1589. <section xml:id="nsa-jdbc-user-service-group-authorities-by-username-query">
  1590. <title><literal>group-authorities-by-username-query</literal></title>
  1591. <para>An SQL statement to query user's group authorities given a username.</para>
  1592. <para>The default is
  1593. <programlisting><![CDATA[select
  1594. g.id, g.group_name, ga.authority
  1595. from
  1596. groups g, group_members gm, group_authorities ga
  1597. where
  1598. gm.username = ? and g.id = ga.group_id and g.id = gm.group_id]]></programlisting></para>
  1599. </section>
  1600. <section xml:id="nsa-jdbc-user-service-id">
  1601. <title><literal>id</literal></title>
  1602. <para>A bean identifier, used for referring to the bean elsewhere in the context.</para>
  1603. </section>
  1604. <section xml:id="nsa-jdbc-user-service-role-prefix">
  1605. <title><literal>role-prefix</literal></title>
  1606. <para>A non-empty string prefix that will be added to role strings loaded from persistent
  1607. storage (default is "ROLE_"). Use the value "none" for no prefix in cases where the default is non-empty.</para>
  1608. </section>
  1609. <section xml:id="nsa-jdbc-user-service-users-by-username-query">
  1610. <title><literal>users-by-username-query</literal></title>
  1611. <para>An SQL statement to query a username, password, and enabled status given a username.</para>
  1612. <para>The default is
  1613. <programlisting><![CDATA[select username, password, enabled from users where username = ?]]></programlisting></para>
  1614. </section>
  1615. </section>
  1616. </section>
  1617. <section xml:id="nsa-password-encoder">
  1618. <title><literal>&lt;password-encoder&gt;</literal></title>
  1619. <para>Authentication providers can optionally be configured to use a password
  1620. encoder as described in the <link linkend="ns-password-encoder"
  1621. >namespace introduction</link>. This will result in the bean being injected
  1622. with the appropriate <interfacename>PasswordEncoder</interfacename>
  1623. instance, potentially with an accompanying
  1624. <interfacename>SaltSource</interfacename> bean to provide salt values for
  1625. hashing. </para>
  1626. <section xml:id="nsa-password-encoder-parents">
  1627. <title>Parent Elements of <literal>&lt;password-encoder&gt;</literal></title>
  1628. <itemizedlist>
  1629. <listitem><link linkend="nsa-authentication-provider">authentication-provider</link></listitem>
  1630. <listitem><link linkend="nsa-password-compare">password-compare</link></listitem>
  1631. </itemizedlist>
  1632. </section>
  1633. <section xml:id="nsa-password-encoder-attributes">
  1634. <title><literal>&lt;password-encoder&gt;</literal> Attributes</title>
  1635. <section xml:id="nsa-password-encoder-base64">
  1636. <title><literal>base64</literal></title>
  1637. <para>Whether a string should be base64 encoded</para>
  1638. </section>
  1639. <section xml:id="nsa-password-encoder-hash">
  1640. <title><literal>hash</literal></title>
  1641. <para>Defines the hashing algorithm used on user passwords. We recommend strongly against using
  1642. MD4, as it is a very weak hashing algorithm.</para>
  1643. </section>
  1644. <section xml:id="nsa-password-encoder-ref">
  1645. <title><literal>ref</literal></title>
  1646. <para>Defines a reference to a Spring bean that implements <interfacename>PasswordEncoder
  1647. </interfacename>.</para>
  1648. </section>
  1649. </section>
  1650. <section xml:id="nsa-password-encoder-children">
  1651. <title>Child Elements of <literal>&lt;password-encoder&gt;</literal></title>
  1652. <itemizedlist>
  1653. <listitem><link linkend="nsa-salt-source">salt-source</link></listitem>
  1654. </itemizedlist>
  1655. </section>
  1656. </section>
  1657. <section xml:id="nsa-salt-source">
  1658. <title><literal>&lt;salt-source&gt;</literal></title>
  1659. <para>Password salting strategy. A system-wide constant or a property from the UserDetails object
  1660. can be used.</para>
  1661. <section xml:id="nsa-salt-source-parents">
  1662. <title>Parent Elements of <literal>&lt;salt-source&gt;</literal></title>
  1663. <itemizedlist>
  1664. <listitem><link linkend="nsa-password-encoder">password-encoder</link></listitem>
  1665. </itemizedlist>
  1666. </section>
  1667. <section xml:id="nsa-salt-source-attributes">
  1668. <title><literal>&lt;salt-source&gt;</literal> Attributes</title>
  1669. <section xml:id="nsa-salt-source-ref">
  1670. <title><literal>ref</literal></title>
  1671. <para>Defines a reference to a Spring bean Id.</para>
  1672. </section>
  1673. <section xml:id="nsa-salt-source-system-wide">
  1674. <title><literal>system-wide</literal></title>
  1675. <para>A single value that will be used as the salt for a password encoder.</para>
  1676. </section>
  1677. <section xml:id="nsa-salt-source-user-property">
  1678. <title><literal>user-property</literal></title>
  1679. <para>A property of the UserDetails object which will be used as salt by a password encoder.
  1680. Typically something like "username" might be used.</para>
  1681. </section>
  1682. </section>
  1683. </section>
  1684. <section xml:id="nsa-user-service">
  1685. <title><literal>&lt;user-service&gt;</literal></title>
  1686. <para>Creates an in-memory UserDetailsService from a properties file or a list of "user" child
  1687. elements. Usernames are converted to lower-case internally to allow for case-insensitive lookups, so
  1688. this should not be used if case-sensitivity is required.</para>
  1689. <section xml:id="nsa-user-service-attributes">
  1690. <title><literal>&lt;user-service&gt;</literal> Attributes</title>
  1691. <section xml:id="nsa-user-service-id">
  1692. <title><literal>id</literal></title>
  1693. <para>A bean identifier, used for referring to the bean elsewhere in the context.</para>
  1694. </section>
  1695. <section xml:id="nsa-user-service-properties">
  1696. <title><literal>properties</literal></title>
  1697. <para>The location of a Properties file where each line is in the format of
  1698. <programlisting><![CDATA[username=password,grantedAuthority[,grantedAuthority][,enabled|disabled]]]></programlisting></para>
  1699. </section>
  1700. </section>
  1701. <section xml:id="nsa-user-service-children">
  1702. <title>Child Elements of <literal>&lt;user-service&gt;</literal></title>
  1703. <itemizedlist>
  1704. <listitem><link linkend="nsa-user">user</link></listitem>
  1705. </itemizedlist>
  1706. </section>
  1707. </section>
  1708. <section xml:id="nsa-user">
  1709. <title><literal>&lt;user&gt;</literal></title>
  1710. <para>Represents a user in the application.</para>
  1711. <section xml:id="nsa-user-parents">
  1712. <title>Parent Elements of <literal>&lt;user&gt;</literal></title>
  1713. <itemizedlist>
  1714. <listitem><link linkend="nsa-user-service">user-service</link></listitem>
  1715. </itemizedlist>
  1716. </section>
  1717. <section xml:id="nsa-user-attributes">
  1718. <title><literal>&lt;user&gt;</literal> Attributes</title>
  1719. <section xml:id="nsa-user-authorities">
  1720. <title><literal>authorities</literal></title>
  1721. <para>One of more authorities granted to the user. Separate authorities with a comma
  1722. (but no space). For example, "ROLE_USER,ROLE_ADMINISTRATOR"</para>
  1723. </section>
  1724. <section xml:id="nsa-user-disabled">
  1725. <title><literal>disabled</literal></title>
  1726. <para>Can be set to "true" to mark an account as disabled and unusable.</para>
  1727. </section>
  1728. <section xml:id="nsa-user-locked">
  1729. <title><literal>locked</literal></title>
  1730. <para>Can be set to "true" to mark an account as locked and unusable.</para>
  1731. </section>
  1732. <section xml:id="nsa-user-name">
  1733. <title><literal>name</literal></title>
  1734. <para>The username assigned to the user.</para>
  1735. </section>
  1736. <section xml:id="nsa-user-password">
  1737. <title><literal>password</literal></title>
  1738. <para>The password assigned to the user. This may be hashed if the corresponding
  1739. authentication provider supports hashing (remember to set the "hash" attribute of the
  1740. "user-service" element). This attribute be omitted in the case where the data will
  1741. not be used for authentication, but only for accessing authorities. If omitted, the
  1742. namespace will generate a random value, preventing its accidental use for
  1743. authentication. Cannot be empty.</para>
  1744. </section>
  1745. </section>
  1746. </section>
  1747. </section>
  1748. <section xml:id="nsa-method-security">
  1749. <title>Method Security</title>
  1750. <section xml:id="nsa-global-method-security">
  1751. <title><literal>&lt;global-method-security&gt;</literal></title>
  1752. <para> This element is the primary means of adding support for securing methods on
  1753. Spring Security beans. Methods can be secured by the use of annotations (defined at
  1754. the interface or class level) or by defining a set of pointcuts as child elements,
  1755. using AspectJ syntax. </para>
  1756. <section xml:id="nsa-global-method-security-attributes">
  1757. <title><literal>&lt;global-method-security&gt;</literal> Attributes</title>
  1758. <section xml:id="nsa-global-method-security-access-decision-manager-ref">
  1759. <title><literal>access-decision-manager-ref</literal></title>
  1760. <para>Method security uses the same <interfacename>AccessDecisionManager</interfacename>
  1761. configuration as web security, but this can be overridden using this attribute. By default
  1762. an AffirmativeBased implementation is used for with a RoleVoter and an AuthenticatedVoter. </para>
  1763. </section>
  1764. <section xml:id="nsa-global-method-security-authentication-manager-ref">
  1765. <title><literal>authentication-manager-ref</literal></title>
  1766. <para>A reference to an <interfacename>AuthenticationManager</interfacename>
  1767. that should be used for method security.</para>
  1768. </section>
  1769. <section xml:id="nsa-global-method-security-jsr250-annotations">
  1770. <title><literal>jsr250-annotations</literal></title>
  1771. <para>Specifies whether JSR-250 style attributes are to be used (for example "RolesAllowed"). This
  1772. will require the javax.annotation.security classes on the classpath. Setting this to true also
  1773. adds a <classname>Jsr250Voter</classname> to the
  1774. <interfacename>AccessDecisionManager</interfacename>, so you need to make sure you do this if
  1775. you are using a custom implementation and want to use these annotations.</para>
  1776. </section>
  1777. <section xml:id="nsa-global-method-security-metadata-source-ref">
  1778. <title><literal>&lt;metadata-source-ref&gt;</literal> Attribute</title>
  1779. <para> An external <interfacename>MethodSecurityMetadataSource</interfacename>
  1780. instance can be supplied which will take priority over other sources
  1781. (such as the default annotations).
  1782. </para>
  1783. </section>
  1784. <section xml:id="nsa-global-method-security-mode">
  1785. <title>The <literal>mode</literal> Attribute</title>
  1786. <para>This attribute can be set to <quote>aspectj</quote> to specify that AspectJ
  1787. should be used instead of the default Spring AOP. Secured methods must be woven
  1788. with the <classname>AnnotationSecurityAspect</classname> from the
  1789. <literal>spring-security-aspects</literal> module. </para>
  1790. <para>It is important to note that AspectJ follows Java's rule that annotations on
  1791. interfaces are not inherited. This means that methods that define the Security annotaitons
  1792. on the interface will not be secured. Instead, you must place the Security annotation
  1793. on the class when using AspectJ.</para>
  1794. </section>
  1795. <section xml:id="nsa-global-method-security-order">
  1796. <title><literal>order</literal></title>
  1797. <para>Allows the advice "order" to be set for the method security interceptor.</para>
  1798. </section>
  1799. <section xml:id="nsa-global-method-security-pre-post-annotations">
  1800. <title><literal>pre-post-annotations</literal></title>
  1801. <para>Specifies whether the use of Spring Security's pre and post invocation annotations (@PreFilter,
  1802. @PreAuthorize, @PostFilter, @PostAuthorize) should be enabled for this application context.
  1803. Defaults to "disabled".</para>
  1804. </section>
  1805. <section xml:id="nsa-global-method-security-proxy-target-class">
  1806. <title><literal>proxy-target-class</literal></title>
  1807. <para>If true, class based proxying will be used instead of interface based proxying.</para>
  1808. </section>
  1809. <section xml:id="nsa-global-method-security-run-as-manager-ref">
  1810. <title><literal>run-as-manager-ref</literal></title>
  1811. <para>A reference to an optional <interfacename>RunAsManager</interfacename> implementation which
  1812. will be used by the configured <classname>MethodSecurityInterceptor</classname></para>
  1813. </section>
  1814. <section xml:id="nsa-global-method-security-secured-annotations">
  1815. <title><literal>secured-annotations</literal></title>
  1816. <para>Specifies whether the use of Spring Security's @Secured annotations should be enabled for this
  1817. application context. Defaults to "disabled".</para>
  1818. </section>
  1819. </section>
  1820. <section xml:id="nsa-global-method-security-children">
  1821. <title>Child Elements of <literal>&lt;global-method-security&gt;</literal></title>
  1822. <itemizedlist>
  1823. <listitem><link linkend="nsa-after-invocation-provider">after-invocation-provider</link></listitem>
  1824. <listitem><link linkend="nsa-expression-handler">expression-handler</link></listitem>
  1825. <listitem><link linkend="nsa-pre-post-annotation-handling">pre-post-annotation-handling</link></listitem>
  1826. <listitem><link linkend="nsa-protect-pointcut">protect-pointcut</link></listitem>
  1827. </itemizedlist>
  1828. </section>
  1829. </section>
  1830. <section xml:id="nsa-after-invocation-provider">
  1831. <title><literal>&lt;after-invocation-provider&gt;</literal></title>
  1832. <para> This element can be used to decorate an
  1833. <interfacename>AfterInvocationProvider</interfacename> for use by the security
  1834. interceptor maintained by the <literal>&lt;global-method-security&gt;</literal>
  1835. namespace. You can define zero or more of these within the
  1836. <literal>global-method-security</literal> element, each with a
  1837. <literal>ref</literal> attribute pointing to an
  1838. <interfacename>AfterInvocationProvider</interfacename> bean instance within your
  1839. application context. </para>
  1840. <section xml:id="nsa-after-invocation-provider-parents">
  1841. <title>Parent Elements of <literal>&lt;after-invocation-provider&gt;</literal></title>
  1842. <itemizedlist>
  1843. <listitem><link linkend="nsa-global-method-security">global-method-security</link></listitem>
  1844. </itemizedlist>
  1845. </section>
  1846. <section xml:id="nsa-after-invocation-provider-attributes">
  1847. <title><literal>&lt;after-invocation-provider&gt;</literal> Attributes</title>
  1848. <section xml:id="nsa-after-invocation-provider-ref">
  1849. <title><literal>ref</literal></title>
  1850. <para>Defines a reference to a Spring bean that implements <interfacename>
  1851. AfterInvocationProvider</interfacename>.</para>
  1852. </section>
  1853. </section>
  1854. </section>
  1855. <section xml:id="nsa-pre-post-annotation-handling">
  1856. <title><literal>&lt;pre-post-annotation-handling&gt;</literal></title>
  1857. <para>Allows the default expression-based mechanism for handling Spring Security's pre and post invocation
  1858. annotations (@PreFilter, @PreAuthorize, @PostFilter, @PostAuthorize) to be replace entirely. Only
  1859. applies if these annotations are enabled.</para>
  1860. <section xml:id="nsa-pre-post-annotation-handling-parents">
  1861. <title>Parent Elements of <literal>&lt;pre-post-annotation-handling&gt;</literal></title>
  1862. <itemizedlist>
  1863. <listitem><link linkend="nsa-global-method-security">global-method-security</link></listitem>
  1864. </itemizedlist>
  1865. </section>
  1866. <section xml:id="nsa-pre-post-annotation-handling-children">
  1867. <title>Child Elements of <literal>&lt;pre-post-annotation-handling&gt;</literal></title>
  1868. <itemizedlist>
  1869. <listitem><link linkend="nsa-invocation-attribute-factory">invocation-attribute-factory</link></listitem>
  1870. <listitem><link linkend="nsa-post-invocation-advice">post-invocation-advice</link></listitem>
  1871. <listitem><link linkend="nsa-pre-invocation-advice">pre-invocation-advice</link></listitem>
  1872. </itemizedlist>
  1873. </section>
  1874. </section>
  1875. <section xml:id="nsa-invocation-attribute-factory">
  1876. <title><literal>&lt;invocation-attribute-factory&gt;</literal></title>
  1877. <para>Defines the PrePostInvocationAttributeFactory instance which is used to generate pre and post
  1878. invocation metadata from the annotated methods.</para>
  1879. <section xml:id="nsa-invocation-attribute-factory-parents">
  1880. <title>Parent Elements of <literal>&lt;invocation-attribute-factory&gt;</literal></title>
  1881. <itemizedlist>
  1882. <listitem><link linkend="nsa-pre-post-annotation-handling">pre-post-annotation-handling</link></listitem>
  1883. </itemizedlist>
  1884. </section>
  1885. <section xml:id="nsa-invocation-attribute-factory-attributes">
  1886. <title><literal>&lt;invocation-attribute-factory&gt;</literal> Attributes</title>
  1887. <section xml:id="nsa-invocation-attribute-factory-ref">
  1888. <title><literal>ref</literal></title>
  1889. <para>Defines a reference to a Spring bean Id.</para>
  1890. </section>
  1891. </section>
  1892. </section>
  1893. <section xml:id="nsa-post-invocation-advice">
  1894. <title><literal>&lt;post-invocation-advice&gt;</literal></title>
  1895. <para>Customizes the <classname>PostInvocationAdviceProvider</classname> with the ref as the
  1896. <classname>PostInvocationAuthorizationAdvice</classname> for the &lt;pre-post-annotation-handling&gt;
  1897. element.</para>
  1898. <section xml:id="nsa-post-invocation-advice-parents">
  1899. <title>Parent Elements of <literal>&lt;post-invocation-advice&gt;</literal></title>
  1900. <itemizedlist>
  1901. <listitem><link linkend="nsa-pre-post-annotation-handling">pre-post-annotation-handling</link></listitem>
  1902. </itemizedlist>
  1903. </section>
  1904. <section xml:id="nsa-post-invocation-advice-attributes">
  1905. <title><literal>&lt;post-invocation-advice&gt;</literal> Attributes</title>
  1906. <section xml:id="nsa-post-invocation-advice-ref">
  1907. <title><literal>ref</literal></title>
  1908. <para>Defines a reference to a Spring bean Id.</para>
  1909. </section>
  1910. </section>
  1911. </section>
  1912. <section xml:id="nsa-pre-invocation-advice">
  1913. <title><literal>&lt;pre-invocation-advice&gt;</literal></title>
  1914. <para>Customizes the <classname>PreInvocationAuthorizationAdviceVoter</classname> with the ref as the
  1915. <classname>PreInvocationAuthorizationAdviceVoter</classname> for the
  1916. &lt;pre-post-annotation-handling&gt; element.</para>
  1917. <section xml:id="nsa-pre-invocation-advice-parents">
  1918. <title>Parent Elements of <literal>&lt;pre-invocation-advice&gt;</literal></title>
  1919. <itemizedlist>
  1920. <listitem><link linkend="nsa-pre-post-annotation-handling">pre-post-annotation-handling</link></listitem>
  1921. </itemizedlist>
  1922. </section>
  1923. <section xml:id="nsa-pre-invocation-advice-attributes">
  1924. <title><literal>&lt;pre-invocation-advice&gt;</literal> Attributes</title>
  1925. <section xml:id="nsa-pre-invocation-advice-ref">
  1926. <title><literal>ref</literal></title>
  1927. <para>Defines a reference to a Spring bean Id.</para>
  1928. </section>
  1929. </section>
  1930. </section>
  1931. <section xml:id="nsa-protect-pointcut">
  1932. <title>Securing Methods using <literal>&lt;protect-pointcut&gt;</literal></title>
  1933. <para> Rather than defining security attributes on an individual method or class
  1934. basis using the <literal>@Secured</literal> annotation, you can define
  1935. cross-cutting security constraints across whole sets of methods and interfaces
  1936. in your service layer using the <literal>&lt;protect-pointcut&gt;</literal>
  1937. element. You can find an example in the <link
  1938. linkend="ns-protect-pointcut">namespace introduction</link>.</para>
  1939. <section xml:id="nsa-protect-pointcut-parents">
  1940. <title>Parent Elements of <literal>&lt;protect-pointcut&gt;</literal></title>
  1941. <itemizedlist>
  1942. <listitem><link linkend="nsa-global-method-security">global-method-security</link></listitem>
  1943. </itemizedlist>
  1944. </section>
  1945. <section xml:id="nsa-protect-pointcut-attributes">
  1946. <title><literal>&lt;protect-pointcut&gt;</literal> Attributes</title>
  1947. <section xml:id="nsa-protect-pointcut-access">
  1948. <title><literal>access</literal></title>
  1949. <para>Access configuration attributes list that applies to all methods matching the pointcut,
  1950. e.g. "ROLE_A,ROLE_B"</para>
  1951. </section>
  1952. <section xml:id="nsa-protect-pointcut-expression">
  1953. <title><literal>expression</literal></title>
  1954. <para>An AspectJ expression, including the 'execution' keyword. For example, 'execution(int
  1955. com.foo.TargetObject.countLength(String))' (without the quotes).</para>
  1956. </section>
  1957. </section>
  1958. </section>
  1959. <section xml:id="nsa-intercept-methods">
  1960. <title><literal>&lt;intercept-methods&gt;</literal></title>
  1961. <para>Can be used inside a bean definition to add a security interceptor to the bean and set up access
  1962. configuration attributes for the bean's methods</para>
  1963. <section xml:id="nsa-intercept-methods-attributes">
  1964. <title><literal>&lt;intercept-methods&gt;</literal> Attributes</title>
  1965. <section xml:id="nsa-intercept-methods-access-decision-manager-ref">
  1966. <title><literal>access-decision-manager-ref</literal></title>
  1967. <para>Optional AccessDecisionManager bean ID to be used by the created method security interceptor.</para>
  1968. </section>
  1969. </section>
  1970. <section xml:id="nsa-intercept-methods-children">
  1971. <title>Child Elements of <literal>&lt;intercept-methods&gt;</literal></title>
  1972. <itemizedlist>
  1973. <listitem><link linkend="nsa-protect">protect</link></listitem>
  1974. </itemizedlist>
  1975. </section>
  1976. </section>
  1977. <section xml:id="nsa-method-security-metadata-source">
  1978. <title><literal>&lt;method-security-metadata-source&gt;</literal></title>
  1979. <para>Creates a MethodSecurityMetadataSource instance</para>
  1980. <section xml:id="nsa-method-security-metadata-source-attributes">
  1981. <title><literal>&lt;method-security-metadata-source&gt;</literal> Attributes</title>
  1982. <section xml:id="nsa-method-security-metadata-source-id">
  1983. <title><literal>id</literal></title>
  1984. <para>A bean identifier, used for referring to the bean elsewhere in the context.</para>
  1985. </section>
  1986. <section xml:id="nsa-method-security-metadata-source-use-expressions">
  1987. <title><literal>use-expressions</literal></title>
  1988. <para>Enables the use of expressions in the 'access' attributes in
  1989. &lt;intercept-url&gt; elements rather than the traditional list of configuration attributes.
  1990. Defaults to 'false'. If enabled, each attribute should contain a single boolean expression.
  1991. If the expression evaluates to 'true', access will be granted.</para>
  1992. </section>
  1993. </section>
  1994. <section xml:id="nsa-method-security-metadata-source-children">
  1995. <title>Child Elements of <literal>&lt;method-security-metadata-source&gt;</literal></title>
  1996. <itemizedlist>
  1997. <listitem><link linkend="nsa-protect">protect</link></listitem>
  1998. </itemizedlist>
  1999. </section>
  2000. </section>
  2001. <section xml:id="nsa-protect">
  2002. <title><literal>&lt;protect&gt;</literal></title>
  2003. <para>Defines a protected method and the access control configuration attributes that apply to it. We
  2004. strongly advise you NOT to mix "protect" declarations with any services provided "global-method-security".</para>
  2005. <section xml:id="nsa-protect-parents">
  2006. <title>Parent Elements of <literal>&lt;protect&gt;</literal></title>
  2007. <itemizedlist>
  2008. <listitem><link linkend="nsa-intercept-methods">intercept-methods</link></listitem>
  2009. <listitem><link linkend="nsa-method-security-metadata-source">method-security-metadata-source</link></listitem>
  2010. </itemizedlist>
  2011. </section>
  2012. <section xml:id="nsa-protect-attributes">
  2013. <title><literal>&lt;protect&gt;</literal> Attributes</title>
  2014. <section xml:id="nsa-protect-access">
  2015. <title><literal>access</literal></title>
  2016. <para>Access configuration attributes list that applies to the method, e.g. "ROLE_A,ROLE_B".</para>
  2017. </section>
  2018. <section xml:id="nsa-protect-method">
  2019. <title><literal>method</literal></title>
  2020. <para>A method name</para>
  2021. </section>
  2022. </section>
  2023. </section>
  2024. </section>
  2025. <section xml:id="nsa-ldap">
  2026. <title>LDAP Namespace Options</title>
  2027. <para> LDAP is covered in some details in <link linkend="ldap">its own
  2028. chapter</link>. We will expand on that here with some explanation of how the
  2029. namespace options map to Spring beans. The LDAP implementation uses Spring LDAP
  2030. extensively, so some familiarity with that project's API may be useful. </para>
  2031. <section xml:id="nsa-ldap-server">
  2032. <title>Defining the LDAP Server using the <literal>&lt;ldap-server&gt;</literal>
  2033. Element</title>
  2034. <para> This element sets up a Spring LDAP
  2035. <interfacename>ContextSource</interfacename> for use by the other LDAP beans,
  2036. defining the location of the LDAP server and other information (such as a
  2037. username and password, if it doesn't allow anonymous access) for connecting to
  2038. it. It can also be used to create an embedded server for testing. Details of the
  2039. syntax for both options are covered in the <link linkend="ldap-server">LDAP
  2040. chapter</link>. The actual <interfacename>ContextSource</interfacename>
  2041. implementation is <classname>DefaultSpringSecurityContextSource</classname>
  2042. which extends Spring LDAP's <classname>LdapContextSource</classname> class. The
  2043. <literal>manager-dn</literal> and <literal>manager-password</literal> attributes
  2044. map to the latter's <literal>userDn</literal> and <literal>password</literal>
  2045. properties respectively. </para>
  2046. <para> If you only have one server defined in your application context, the other
  2047. LDAP namespace-defined beans will use it automatically. Otherwise, you can give
  2048. the element an "id" attribute and refer to it from other namespace beans using
  2049. the <literal>server-ref</literal> attribute. This is actually the bean <literal>id</literal> of the
  2050. <literal>ContextSource</literal> instance, if you want to use it in other
  2051. traditional Spring beans. </para>
  2052. <section xml:id="nsa-ldap-server-attributes">
  2053. <title><literal>&lt;ldap-server&gt;</literal> Attributes</title>
  2054. <section xml:id="nsa-ldap-server-id">
  2055. <title><literal>id</literal></title>
  2056. <para>A bean identifier, used for referring to the bean elsewhere in the context.</para>
  2057. </section>
  2058. <section xml:id="nsa-ldap-server-ldif">
  2059. <title><literal>ldif</literal></title>
  2060. <para>Explicitly specifies an ldif file resource to load into an embedded LDAP server. The ldiff
  2061. is should be a Spring resource pattern (i.e. classpath:init.ldiff). The default is
  2062. classpath*:*.ldiff</para>
  2063. </section>
  2064. <section xml:id="nsa-ldap-server-manager-dn">
  2065. <title><literal>manager-dn</literal></title>
  2066. <para>Username (DN) of the "manager" user identity which will be used to authenticate to a
  2067. (non-embedded) LDAP server. If omitted, anonymous access will be used.</para>
  2068. </section>
  2069. <section xml:id="nsa-ldap-server-manager-password">
  2070. <title><literal>manager-password</literal></title>
  2071. <para>The password for the manager DN. This is required if the manager-dn is specified.</para>
  2072. </section>
  2073. <section xml:id="nsa-ldap-server-port">
  2074. <title><literal>port</literal></title>
  2075. <para>Specifies an IP port number. Used to configure an embedded LDAP server, for example. The
  2076. default value is 33389.</para>
  2077. </section>
  2078. <section xml:id="nsa-ldap-server-root">
  2079. <title><literal>root</literal></title>
  2080. <para>Optional root suffix for the embedded LDAP server. Default is "dc=springframework,dc=org"
  2081. </para>
  2082. </section>
  2083. <section xml:id="nsa-ldap-server-url">
  2084. <title><literal>url</literal></title>
  2085. <para>Specifies the ldap server URL when not using the embedded LDAP server.</para>
  2086. </section>
  2087. </section>
  2088. </section>
  2089. <section xml:id="nsa-ldap-authentication-provider">
  2090. <title><literal>&lt;ldap-authentication-provider&gt;</literal></title>
  2091. <para> This element is shorthand for the creation of an
  2092. <classname>LdapAuthenticationProvider</classname> instance. By default this will
  2093. be configured with a <classname>BindAuthenticator</classname> instance and a
  2094. <classname>DefaultAuthoritiesPopulator</classname>. As with all namespace
  2095. authentication providers, it must be included as a child of the
  2096. <literal>authentication-provider</literal> element.</para>
  2097. <section xml:id="nsa-ldap-authentication-provider-parents">
  2098. <title>Parent Elements of <literal>&lt;ldap-authentication-provider&gt;</literal></title>
  2099. <itemizedlist>
  2100. <listitem><link linkend="nsa-authentication-manager">authentication-manager</link></listitem>
  2101. </itemizedlist>
  2102. </section>
  2103. <section xml:id="nsa-ldap-authentication-provider-attributes">
  2104. <title><literal>&lt;ldap-authentication-provider&gt;</literal> Attributes</title>
  2105. <section xml:id="nsa-ldap-authentication-provider-group-role-attribute">
  2106. <title><literal>group-role-attribute</literal></title>
  2107. <para>The LDAP attribute name which contains the role name which will be used within Spring
  2108. Security. Maps to the <classname>DefaultLdapAuthoritiesPopulator</classname>'s
  2109. <literal>groupRoleAttribute</literal> property. Defaults to "cn".</para>
  2110. </section>
  2111. <section xml:id="nsa-ldap-authentication-provider-group-search-base">
  2112. <title><literal>group-search-base</literal></title>
  2113. <para>Search base for group membership searches. Maps to the
  2114. <classname>DefaultLdapAuthoritiesPopulator</classname>'s <literal>groupSearchBase</literal>
  2115. constructor argument. Defaults to "" (searching from the root).</para>
  2116. </section>
  2117. <section xml:id="nsa-ldap-authentication-provider-group-search-filter">
  2118. <title><literal>group-search-filter</literal></title>
  2119. <para>Group search filter. Maps to the <classname>DefaultLdapAuthoritiesPopulator</classname>'s
  2120. <literal>groupSearchFilter</literal> property. Defaults to (uniqueMember={0}).
  2121. The substituted parameter is the DN of the user.</para>
  2122. </section>
  2123. <section xml:id="nsa-ldap-authentication-provider-role-prefix">
  2124. <title><literal>role-prefix</literal></title>
  2125. <para>A non-empty string prefix that will be added to role strings loaded from persistent.
  2126. Maps to the <classname>DefaultLdapAuthoritiesPopulator</classname>'s
  2127. <literal>rolePrefix</literal> property. Defaults to "ROLE_". Use the value "none" for
  2128. no prefix in cases where the default is non-empty.</para>
  2129. </section>
  2130. <section xml:id="nsa-ldap-authentication-provider-server-ref">
  2131. <title><literal>server-ref</literal></title>
  2132. <para>The optional server to use. If omitted, and a default LDAP server is registered (using
  2133. &lt;ldap-server&gt; with no Id), that server will be used.</para>
  2134. </section>
  2135. <section xml:id="nsa-ldap-authentication-provider-user-context-mapper-ref">
  2136. <title><literal>user-context-mapper-ref</literal></title>
  2137. <para>Allows explicit customization of the loaded user object by specifying a
  2138. UserDetailsContextMapper bean which will be called with the context information
  2139. from the user's directory entry</para>
  2140. </section>
  2141. <section xml:id="nsa-ldap-authentication-provider-user-details-class">
  2142. <title><literal>user-details-class</literal></title>
  2143. <para>Allows the objectClass of the user entry to be specified. If set, the framework will
  2144. attempt to load standard attributes for the defined class into the returned UserDetails
  2145. object</para>
  2146. </section>
  2147. <section xml:id="nsa-ldap-authentication-provider-user-dn-pattern">
  2148. <title><literal>user-dn-pattern</literal></title>
  2149. <para>If your users are at a fixed location in the directory (i.e. you can work
  2150. out the DN directly from the username without doing a directory search), you
  2151. can use this attribute to map directly to the DN. It maps directly to the
  2152. <literal>userDnPatterns</literal> property of
  2153. <classname>AbstractLdapAuthenticator</classname>. The value is a specific pattern
  2154. used to build the user's DN, for example "uid={0},ou=people". The key
  2155. "{0}" must be present and will be substituted with the username.</para>
  2156. </section>
  2157. <section xml:id="nsa-ldap-authentication-provider-user-search-base">
  2158. <title><literal>user-search-base</literal></title>
  2159. <para>Search base for user searches. Defaults to "". Only used with a 'user-search-filter'.</para>
  2160. <para>If you need to perform a search to locate the user in the directory, then
  2161. you can set these attributes to control the search. The
  2162. <classname>BindAuthenticator</classname> will be configured with a
  2163. <classname>FilterBasedLdapUserSearch</classname> and the attribute values
  2164. map directly to the first two arguments of that bean's constructor. If these
  2165. attributes aren't set and no <literal>user-dn-pattern</literal> has been
  2166. supplied as an alternative, then the default search values of
  2167. <literal>user-search-filter="(uid={0})"</literal> and
  2168. <literal>user-search-base=""</literal> will be used. </para>
  2169. </section>
  2170. <section xml:id="nsa-ldap-authentication-provider-user-search-filter">
  2171. <title><literal>user-search-filter</literal></title>
  2172. <para>The LDAP filter used to search for users (optional). For example "(uid={0})". The
  2173. substituted parameter is the user's login name.</para>
  2174. <para>If you need to perform a search to locate the user in the directory, then
  2175. you can set these attributes to control the search. The
  2176. <classname>BindAuthenticator</classname> will be configured with a
  2177. <classname>FilterBasedLdapUserSearch</classname> and the attribute values
  2178. map directly to the first two arguments of that bean's constructor. If these
  2179. attributes aren't set and no <literal>user-dn-pattern</literal> has been
  2180. supplied as an alternative, then the default search values of
  2181. <literal>user-search-filter="(uid={0})"</literal> and
  2182. <literal>user-search-base=""</literal> will be used. </para>
  2183. </section>
  2184. </section>
  2185. <section xml:id="nsa-ldap-authentication-provider-children">
  2186. <title>Child Elements of <literal>&lt;ldap-authentication-provider&gt;</literal></title>
  2187. <itemizedlist>
  2188. <listitem><link linkend="nsa-password-compare">password-compare</link></listitem>
  2189. </itemizedlist>
  2190. </section>
  2191. </section>
  2192. <section xml:id="nsa-password-compare">
  2193. <title><literal>&lt;password-compare&gt;</literal></title>
  2194. <para> This is used as child element to <literal>&lt;ldap-provider&gt;</literal>
  2195. and switches the authentication strategy from
  2196. <classname>BindAuthenticator</classname> to
  2197. <classname>PasswordComparisonAuthenticator</classname>.</para>
  2198. <section xml:id="nsa-password-compare-parents">
  2199. <title>Parent Elements of <literal>&lt;password-compare&gt;</literal></title>
  2200. <itemizedlist>
  2201. <listitem><link linkend="nsa-ldap-authentication-provider">ldap-authentication-provider</link></listitem>
  2202. </itemizedlist>
  2203. </section>
  2204. <section xml:id="nsa-password-compare-attributes">
  2205. <title><literal>&lt;password-compare&gt;</literal> Attributes</title>
  2206. <section xml:id="nsa-password-compare-hash">
  2207. <title><literal>hash</literal></title>
  2208. <para>Defines the hashing algorithm used on user passwords. We recommend strongly against
  2209. using MD4, as it is a very weak hashing algorithm.</para>
  2210. </section>
  2211. <section xml:id="nsa-password-compare-password-attribute">
  2212. <title><literal>password-attribute</literal></title>
  2213. <para>The attribute in the directory which contains the user password. Defaults to "userPassword".
  2214. </para>
  2215. </section>
  2216. </section>
  2217. <section xml:id="nsa-password-compare-children">
  2218. <title>Child Elements of <literal>&lt;password-compare&gt;</literal></title>
  2219. <itemizedlist>
  2220. <listitem><link linkend="nsa-password-encoder">password-encoder</link></listitem>
  2221. </itemizedlist>
  2222. </section>
  2223. </section>
  2224. <section xml:id="nsa-ldap-user-service">
  2225. <title><literal>&lt;ldap-user-service&gt;</literal></title>
  2226. <para> This element configures an LDAP
  2227. <interfacename>UserDetailsService</interfacename>. The class used is
  2228. <classname>LdapUserDetailsService</classname> which is a combination of a
  2229. <classname>FilterBasedLdapUserSearch</classname> and a
  2230. <classname>DefaultLdapAuthoritiesPopulator</classname>. The attributes it supports
  2231. have the same usage as in <literal>&lt;ldap-provider&gt;</literal>. </para>
  2232. <section xml:id="nsa-ldap-user-service-attributes">
  2233. <title><literal>&lt;ldap-user-service&gt;</literal> Attributes</title>
  2234. <section xml:id="nsa-ldap-user-service-cache-ref">
  2235. <title><literal>cache-ref</literal></title>
  2236. <para>Defines a reference to a cache for use with a UserDetailsService.</para>
  2237. </section>
  2238. <section xml:id="nsa-ldap-user-service-group-role-attribute">
  2239. <title><literal>group-role-attribute</literal></title>
  2240. <para>The LDAP attribute name which contains the role name which will be used within Spring
  2241. Security. Defaults to "cn".</para>
  2242. </section>
  2243. <section xml:id="nsa-ldap-user-service-group-search-base">
  2244. <title><literal>group-search-base</literal></title>
  2245. <para>Search base for group membership searches. Defaults to "" (searching from the root).</para>
  2246. </section>
  2247. <section xml:id="nsa-ldap-user-service-group-search-filter">
  2248. <title><literal>group-search-filter</literal></title>
  2249. <para>Group search filter. Defaults to (uniqueMember={0}). The substituted parameter is the DN of
  2250. the user.</para>
  2251. </section>
  2252. <section xml:id="nsa-ldap-user-service-id">
  2253. <title><literal>id</literal></title>
  2254. <para>A bean identifier, used for referring to the bean elsewhere in the context.</para>
  2255. </section>
  2256. <section xml:id="nsa-ldap-user-service-role-prefix">
  2257. <title><literal>role-prefix</literal></title>
  2258. <para>A non-empty string prefix that will be added to role strings loaded from persistent
  2259. storage (e.g. "ROLE_"). Use the value "none" for no prefix in cases where the default is
  2260. non-empty.</para>
  2261. </section>
  2262. <section xml:id="nsa-ldap-user-service-server-ref">
  2263. <title><literal>server-ref</literal></title>
  2264. <para>The optional server to use. If omitted, and a default LDAP server is registered (using
  2265. &lt;ldap-server&gt; with no Id), that server will be used.</para>
  2266. </section>
  2267. <section xml:id="nsa-ldap-user-service-user-context-mapper-ref">
  2268. <title><literal>user-context-mapper-ref</literal></title>
  2269. <para>Allows explicit customization of the loaded user object by specifying a
  2270. UserDetailsContextMapper bean which will be called with the context information from the
  2271. user's directory entry</para>
  2272. </section>
  2273. <section xml:id="nsa-ldap-user-service-user-details-class">
  2274. <title><literal>user-details-class</literal></title>
  2275. <para>Allows the objectClass of the user entry to be specified. If set, the framework will
  2276. attempt to load standard attributes for the defined class into the returned UserDetails object
  2277. </para>
  2278. </section>
  2279. <section xml:id="nsa-ldap-user-service-user-search-base">
  2280. <title><literal>user-search-base</literal></title>
  2281. <para>Search base for user searches. Defaults to "". Only used with a 'user-search-filter'.</para>
  2282. </section>
  2283. <section xml:id="nsa-ldap-user-service-user-search-filter">
  2284. <title><literal>user-search-filter</literal></title>
  2285. <para>The LDAP filter used to search for users (optional). For example "(uid={0})". The
  2286. substituted parameter is the user's login name.</para>
  2287. </section>
  2288. </section>
  2289. </section>
  2290. </section>
  2291. </appendix>