spring-projects / spring-projects/spring-security
Allow @postfilter to manage custom objects
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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