Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It's not possible. But there is another way. You can define you own web expression that will be responsible for extracting of id parameter from URL. It may looks like that:</p> <pre><code>&lt;security:intercept-url pattern="/user/{id}/edit" access="getIdUrlPathParameter() == principal.userId"/&gt; </code></pre> <p>To do so you need: <br/> 1. Add CustomWebSecurityExpressionRoot that extends <strong>WebSecurityExpressionRoot</strong> <br/> 2. Add getIdUrlPathParameter() method. It will have access to HttpServletRequest object. <br/> 3. Define CustomWebSecurityExpressionHandler that extends <strong>DefaultWebSecurityExpressionHandler</strong>. Override createSecurityExpressionRoot method abd use your CustomWebSecurityExpressionRoot here. <br/> 4. Define custom access decision manager (xml below) <br/> 5. Inject it into your <strong>http</strong> element via access-decision-manager-ref attribute</p> <pre><code>&lt;security:http access-decision-manager-ref="customAccessDecisionManagerBean" &gt; &lt;security:intercept-url pattern="/user/{id}/edit" access="getIdUrlPathParameter() == principal.userId"/&gt; &lt;/security:http&gt; &lt;bean id="customWebSecurityExpressionHandler" class="com.domain.security.CustomWebSecurityExpressionHandler"/&gt; &lt;bean id="customAccessDecisionManagerBean" class="org.springframework.security.access.vote.AffirmativeBased"&gt; &lt;property name="decisionVoters"&gt; &lt;list&gt; &lt;bean class="org.springframework.security.web.access.expression.WebExpressionVoter"&gt; &lt;property name="expressionHandler" ref="customWebSecurityExpressionHandler" /&gt; &lt;/bean&gt; &lt;/list&gt; &lt;/property&gt; &lt;/bean&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload