Note that there are some explanatory texts on larger screens.

plurals
  1. POSpring Security url-intercept with regular expressions match failure
    primarykey
    data
    text
    <p>Using Spring security 3.2, I am trying to intercept urls as follows:</p> <pre><code>&lt;security:http use-expressions="true" path-type="regex" &gt; &lt;security:intercept-url pattern="/jsp/Error_403.jsp" access="hasAnyRole('ROLE_VISITOR','ROLE_ADMIN','ROLE_BRONZE_SUB','ROLE_BRONZE_TEST','ROLE_SILVER_SUB','ROLE_SILVER_TEST','ROLE_GOLD_SUB','ROLE_GOLD_TEST')" /&gt; &lt;security:intercept-url pattern="/jsp/LoggedOut.jsp" access="hasAnyRole('ROLE_VISITOR','ROLE_ADMIN','ROLE_BRONZE_SUB','ROLE_BRONZE_TEST','ROLE_SILVER_SUB','ROLE_SILVER_TEST','ROLE_GOLD_SUB','ROLE_GOLD_TEST')" /&gt; &lt;security:intercept-url pattern="/jsp/home/header.html" access="hasAnyRole('ROLE_VISITOR','ROLE_ADMIN','ROLE_BRONZE_SUB','ROLE_BRONZE_TEST','ROLE_SILVER_SUB','ROLE_SILVER_TEST','ROLE_GOLD_SUB','ROLE_GOLD_TEST')"/&gt; &lt;security:intercept-url pattern="/unjust?action=statistics" access="hasAnyRole('ROLE_ADMIN','ROLE_GOLD_SUB','ROLE_GOLD_TEST')" /&gt; &lt;security:intercept-url pattern="/unjust?action=browse" access="hasAnyRole('ROLE_ADMIN')" /&gt; &lt;security:intercept-url pattern="/unjust?action=search" access="hasAnyRole('ROLE_ADMIN','ROLE_BRONZE_SUB','ROLE_BRONZE_TEST','ROLE_SILVER_SUB','ROLE_SILVER_TEST','ROLE_GOLD_SUB','ROLE_GOLD_TEST')" /&gt; &lt;security:intercept-url pattern="/unjust?action=home" access="hasAnyRole('ROLE_ADMIN','ROLE_BRONZE_SUB','ROLE_BRONZE_TEST','ROLE_SILVER_SUB','ROLE_SILVER_TEST','ROLE_GOLD_SUB','ROLE_GOLD_TEST')" /&gt; &lt;security:intercept-url pattern="/unjust" access="hasAnyRole('ROLE_VISITOR','ROLE_ADMIN','ROLE_BRONZE_SUB','ROLE_BRONZE_TEST','ROLE_SILVER_SUB','ROLE_SILVER_TEST','ROLE_GOLD_SUB','ROLE_GOLD_TEST')"/&gt; &lt;security:intercept-url pattern="/**" access="denyAll" /&gt; &lt;access-denied-handler error-page="/jsp/Error_403.jsp"/&gt; &lt;security:logout /&gt; &lt;security:openid-login login-page="/openidlogin.jsp" user-service-ref="registeringUserService" authentication-failure-url="/openidlogin.jsp?login_error=true"&gt; &lt;attribute-exchange identifier-match="https://www.google.com/.*"&gt; &lt;openid-attribute name="email" type="http://axschema.org/contact/email" required="true" count="1" /&gt; &lt;openid-attribute name="firstname" type="http://axschema.org/namePerson/first" required="true" /&gt; &lt;openid-attribute name="lastname" type="http://axschema.org/namePerson/last" required="true" /&gt; &lt;/attribute-exchange&gt; &lt;attribute-exchange identifier-match=".*myopenid.com.*"&gt; &lt;openid-attribute name="email" type="http://schema.openid.net/contact/email" required="true" /&gt; &lt;openid-attribute name="fullname" type="http://schema.openid.net/namePerson" required="true" /&gt; &lt;/attribute-exchange&gt; &lt;/security:openid-login&gt; &lt;remember-me token-repository-ref="tokenRepo" /&gt; &lt;/security:http&gt; </code></pre> <p>When I try to execute, for example, the browse action, I cannot authenticate, and the log shows this:</p> <pre><code>12889 [http-bio-8080-exec-14] DEBUG org.springframework.security.web.FilterChainProxy - /unjust?action=statistics at position 11 of 11 in additional filter chain; firing Filter: 'FilterSecurityInterceptor' 12889 [http-bio-8080-exec-14] DEBUG org.springframework.security.web.util.RegexRequestMatcher - Checking match of request : '/unjust?action=statistics'; against '/jsp/Error_403.jsp' 12889 [http-bio-8080-exec-14] DEBUG org.springframework.security.web.util.RegexRequestMatcher - Checking match of request : '/unjust?action=statistics'; against '/jsp/LoggedOut.jsp' 12889 [http-bio-8080-exec-14] DEBUG org.springframework.security.web.util.RegexRequestMatcher - Checking match of request : '/unjust?action=statistics'; against '/jsp/home/header.html' 12889 [http-bio-8080-exec-14] DEBUG org.springframework.security.web.util.RegexRequestMatcher - Checking match of request : '/unjust?action=statistics'; against '/unjust?action=statistics' 12889 [http-bio-8080-exec-14] DEBUG org.springframework.security.web.util.RegexRequestMatcher - Checking match of request : '/unjust?action=statistics'; against '/unjust?action=browse' 12889 [http-bio-8080-exec-14] DEBUG org.springframework.security.web.util.RegexRequestMatcher - Checking match of request : '/unjust?action=statistics'; against '/unjust?action=search$' 12890 [http-bio-8080-exec-14] DEBUG org.springframework.security.web.util.RegexRequestMatcher - Checking match of request : '/unjust?action=statistics'; against '/unjust?action=home' 12890 [http-bio-8080-exec-14] DEBUG org.springframework.security.web.util.RegexRequestMatcher - Checking match of request : '/unjust?action=statistics'; against '/unjust' 12890 [http-bio-8080-exec-14] DEBUG org.springframework.security.web.access.intercept.FilterSecurityInterceptor - Secure object: FilterInvocation: URL: /unjust?action=statistics; Attributes: [denyAll] 12890 [http-bio-8080-exec-14] DEBUG org.springframework.security.web.access.intercept.FilterSecurityInterceptor - Previously Authenticated: [org.springframework.security.openid.OpenIDAuthenticationToken@c8f995e9: Principal: unjust.beans.CustomUserDetails@d66c4fbd: Username: https://www.google.com/accounts/o8/id?xxxxx; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: ROLE_BRONZE_SUB; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@380f4: RemoteIpAddress: 127.0.0.1; SessionId: 6F57A4A404D2BC3CD82391F6973FA715; Granted Authorities: ROLE_BRONZE_SUB, attributes : xxxxxx 12890 [http-bio-8080-exec-14] DEBUG org.springframework.security.access.vote.AffirmativeBased - Voter: org.springframework.security.web.access.expression.WebExpressionVoter@b041b0, returned: -1 12890 [http-bio-8080-exec-14] DEBUG org.springframework.security.web.access.ExceptionTranslationFilter - Access is denied (user is not anonymous); delegating to AccessDeniedHandler org.springframework.security.access.AccessDeniedException: Access is denied </code></pre> <p>I have seen a number of posts on StackOverflow that have a number of different formats for the regular expression, ranging from what I have above to </p> <pre><code>&lt;security:intercept-url pattern="\A^/unjust?action=search.$\Z" </code></pre> <p>I have been able to generate matches using the ant path matcher, however, things then fail when I have a request like this:</p> <pre><code>/unjust?action=browseUNDT&amp;sEcho=1&amp;iColumns=7&amp;sColumns=&amp;iDisplayStart=0&amp;iDisplayLength=10&amp;mDataProp_0=caseName&amp;mDataProp_1=caseId&amp;mDataProp_2=judgmentDate&amp;mDataProp_3=judgmentType&amp;mDataProp_4=judgmentNo&amp;mDataProp_5=docId&amp;mDataProp_6=displayCase&amp;sSearch=&amp;bRegex=false&amp;sSearch_0=&amp;bRegex_0=false&amp;bSearchable_0=true&amp;sSearch_1=&amp;bRegex_1=false&amp;bSearchable_1=true&amp;sSearch_2=&amp;bRegex_2=false&amp;bSearchable_2=true&amp;sSearch_3=&amp;bRegex_3=false&amp;bSearchable_3=true&amp;sSearch_4=&amp;bRegex_4=false&amp;bSearchable_4=true&amp;sSearch_5=&amp;bRegex_5=false&amp;bSearchable_5=true&amp;sSearch_6=&amp;bRegex_6=false&amp;bSearchable_6=true&amp;iSortCol_0=0&amp;sSortDir_0=asc&amp;iSortingCols=1&amp;bSortable_0=true&amp;bSortable_1=true&amp;bSortable_2=true&amp;bSortable_3=true&amp;bSortable_4=true&amp;bSortable_5=true&amp;bSortable_6=true&amp;_=1379771161138 </code></pre> <p>And everything in between.</p> <p>Can someone please steer me towards the correct setup and syntax for this pattern matching?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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