appendix-namespace.xml 158 KB

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