spring-projects / spring-projects/spring-security

Allow @postfilter to manage custom objects

Open
#5,036 12 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage
Dominant language
Java
Stars
9.6k
Forks
6.3k
Avg merge
2d 11h
Merged PRs (30d)
52

Description

This is not a bug but an improvement suggestion.

I'd like to use @postfilter annotation to filter data in a collection based on security roles. My problem is that the controller returns a HashMap which contains the collection HashMap<String, List<MyObj>>

By using the @postfilter I get the following exception:
java.lang.IllegalArgumentException: Filter target must be a collection or array type, but was {result=[myObj: []]} because the return type is the HashMap containing the list of MyObj for the key result
This is due to the check in the DefaultMethodSecurityExpressionHandler.filter which checks if the filterTarget is a collection or array.

The best would be to have the opportunity to specify in the SPEL expression the referred object containing the collection.

I'm using Spring Security 3.2.9.RELEASE

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

The relevant entry point named is DefaultMethodSecurityExpressionHandler.filter; start by tracing its target-type check and the method-security filtering tests. Define and test how a HashMap containing a filtered collection should be addressed, with completion shown by coverage for the reported HashMap<String, List> case and unchanged collection or array behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
authorization, security
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.