spring-projects / spring-projects/spring-security

SEC-2105: Automatically select WebInvocationPrivlegeEvaluator for AbstractAuthorizeTag

Open
#2,335 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

in: taglibs type: enhancement type: jira
Dominant language
Java
Stars
9.6k
Forks
6.3k
Avg merge
2d 11h
Merged PRs (30d)
52

Description

Rob Winch (Migrated from SEC-2105) said:

Currently the AbstractAuthorizeTag will by default use the first WebInvocationPrivlegeEvaluator that is found in the ApplicationContext. This can be overridden using the updates of SEC-2045. However, the correct WebInvocationPrivlegeEvaluator must be set as a request attribute by users right now.

h3. Select WebInvocationPrivlegeEvaluator per

One solution might be to have the WebInvocationPrivlegeEvaluator be injected by a Filter inside each block. However, this approach will not work when the AbstractAuthorizeTag references a URL in another block. For example, given the following configuration:

<http auto-config="true" pattern="/admin/**">
  <intercept-url pattern="/**" access="ROLE_ADMIN"/>
</http>
<http auto-config="true">
  <intercept-url pattern="/**" access="ROLE_USER"/>
</http>

If a user were currently on the page /user and had the following JSP, the proposed solution would not work:

<c:url value="/admin/" var="adminLink"/>
<sec:authorize url="${adminLink}">
  <a href="${adminLink}">Admin</a>
</sec:authorize>

h3. DelegatingWebInvocationPrivlegeEvaluator

Perhaps a more attractive option would be a DelegatingWebInvocationPrivlegeEvaluator which delegates based upon a RequestMatcher. The concept would be very similar to DelegatingAuthenticationEntryPoint.

This still has problems since users may create their own RequestMatcher interface that uses attributes not populated by the AbstractAuthorizeTag. For example, if the first block was used for JSON requests based upon content type, this is not known by the AbstractAuthorizeTag so the RequestMatcher could never match on it.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with AbstractAuthorizeTag and WebInvocationPrivilegeEvaluator, then compare the proposed delegation approach with DelegatingAuthenticationEntryPoint. Determine how evaluator selection should work when a tag references a URL in another block and when custom RequestMatcher attributes are unavailable. Done means the selection behavior and its limitations are defined and implemented.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
security
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.