spring-projects / spring-projects/spring-security

SEC-2400: proxyTargetClass=true required with groovy controllers that use @EnableGlobalMethodSecurity

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

Nobody has claimed this yet.

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

Description

Wesley Hall (Migrated from SEC-2400) said:

If spring webmvc controllers are written in groovy rather than Java the controller mapping is lost when using a @PreAuthorize annotation on a controller method with @EnableGlobalMethodSecurity switched on.

The problem seems to be related to SPR-6268, which is a (now fixed) bug that prevented groovy controllers working at all.

The problem can be resolved with 'proxyTargetClass=true', which was also the solution in SPR-6268, where this was made the default.

Presumably part of the groovy compilation magic involves adding interfaces to classes at compile time which is causing the proxy generation to become interface based breaking AnnotationUtils.

If this is not an easy fix, it might be a good idea to include this in the documentation somewhere because it took me quite a long time to track it down. Not sure how many groovy + spring mvc + spring security people are out there, but I can't be the only one :).

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 by reproducing the Spring MVC case described: a Groovy controller method using @PreAuthorize with @EnableGlobalMethodSecurity enabled, then compare its mapping with proxyTargetClass=true. Done means the controller mapping is retained without the workaround, or the required configuration is documented if the behavior cannot be fixed.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
authorization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.