Have RequestMappingAnnotation recognize @CurrentSecurityContext parameters (#1006)

This commit is contained in:
Maxence Labusquiere
2024-01-30 14:54:44 +01:00
committed by GitHub
parent e3d94a9ac4
commit 32d5c114c1
4 changed files with 20 additions and 1 deletions

View File

@@ -239,6 +239,11 @@
<artifactId>spring-boot-test</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>

View File

@@ -73,7 +73,9 @@ public final class RequestMappingAnnotation extends BugChecker implements Method
isType(ANN_PACKAGE_PREFIX + "RequestBody"),
isType(ANN_PACKAGE_PREFIX + "RequestHeader"),
isType(ANN_PACKAGE_PREFIX + "RequestParam"),
isType(ANN_PACKAGE_PREFIX + "RequestPart"))),
isType(ANN_PACKAGE_PREFIX + "RequestPart"),
isType(
"org.springframework.security.core.annotation.CurrentSecurityContext"))),
isSameType(InputStream.class.getCanonicalName()),
isSameType(Locale.class.getCanonicalName()),
isSameType(TimeZone.class.getCanonicalName()),

View File

@@ -16,6 +16,7 @@ final class RequestMappingAnnotationTest {
"import java.util.Locale;",
"import java.util.TimeZone;",
"import org.springframework.http.HttpMethod;",
"import org.springframework.security.core.annotation.CurrentSecurityContext;",
"import org.springframework.ui.Model;",
"import org.springframework.validation.BindingResult;",
"import org.springframework.web.bind.annotation.DeleteMapping;",
@@ -63,6 +64,10 @@ final class RequestMappingAnnotationTest {
" A properRequestPart(@RequestPart String part);",
"",
" @RequestMapping",
" A properCurrentSecurityContext(",
" @CurrentSecurityContext(expression = \"authentication.name\") String user);",
"",
" @RequestMapping",
" A properInputStream(InputStream input);",
"",
" @RequestMapping",

View File

@@ -489,6 +489,13 @@
<artifactId>spring-boot-test</artifactId>
<version>2.7.18</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-bom</artifactId>
<version>5.3.13.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>