appendix-namespace.xml 156 KB

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