Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to M2 #1292

Merged
merged 7 commits into from
Apr 20, 2023
Merged

update to M2 #1292

merged 7 commits into from
Apr 20, 2023

Conversation

sdelamo
Copy link
Contributor

@sdelamo sdelamo commented Apr 14, 2023

No description provided.

@wetted wetted self-assigned this Apr 19, 2023
@wetted
Copy link
Contributor

wetted commented Apr 19, 2023

@sdelamo I have been debugging issues with this PR. The majority of tests are failing because OauthRouteBuilder is failing (raising an exception) when it calls DefaultRouteBuilder.GET(loginPath, ExecutionHandle.of(controller, m)). This is the code you had to change with core 4.0.0-M2.

https://ge.micronaut.io/s/nc4ycgxayj3mg/tests/overview?outcome=failed

What I have found so far, is when the call reaches DefaultBeanContext.findExecutionHandle(Class<T> beanType, Qualifier<?> q, String method, Class<?>... arguments) (with a null Qualifier) that unexpectedly returns an empty Optional. Digging in deeper I am not seeing anything I understand to be a root cause.

@graemerocher has made recent changes around this core code for route expression support. Any ideas?

@yawkat
Copy link
Member

yawkat commented Apr 20, 2023

this patch fixes it:

Index: security-jwt/src/main/java/io/micronaut/security/token/jwt/endpoints/TokenRefreshRequest.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/security-jwt/src/main/java/io/micronaut/security/token/jwt/endpoints/TokenRefreshRequest.java b/security-jwt/src/main/java/io/micronaut/security/token/jwt/endpoints/TokenRefreshRequest.java
--- a/security-jwt/src/main/java/io/micronaut/security/token/jwt/endpoints/TokenRefreshRequest.java	(revision 83f4e0261f8c93a1f5a8a7894e714b1ff78f5ebc)
+++ b/security-jwt/src/main/java/io/micronaut/security/token/jwt/endpoints/TokenRefreshRequest.java	(date 1681996043487)
@@ -17,6 +17,7 @@
 
 import com.fasterxml.jackson.annotation.JsonProperty;
 import io.micronaut.core.annotation.NonNull;
+import io.micronaut.core.annotation.Nullable;
 import io.micronaut.serde.annotation.Serdeable;
 
 import jakarta.validation.constraints.NotBlank;
@@ -33,15 +34,15 @@
 
     public static final String GRANT_TYPE_REFRESH_TOKEN = "refresh_token";
 
-    @NonNull
+    @Nullable
     @NotBlank
     @Pattern(regexp = GRANT_TYPE_REFRESH_TOKEN)
     @JsonProperty("grant_type")
     private final String grantType;
 
+    @Nullable
     @NotBlank
     @JsonProperty(GRANT_TYPE_REFRESH_TOKEN)
-    @NonNull
     private final String refreshToken;
 
     /**
@@ -49,8 +50,8 @@
      * @param grantType Grant type
      * @param refreshToken Refresh token
      */
-    public TokenRefreshRequest(@NonNull String grantType,
-                               @NonNull String refreshToken) {
+    public TokenRefreshRequest(@Nullable String grantType,
+                               @Nullable String refreshToken) {
         this.grantType = grantType;
         this.refreshToken = refreshToken;
     }
@@ -59,7 +60,7 @@
      * grantType getter.
      * @return e.g refresh_token
      */
-    @NonNull
+    @Nullable
     public String getGrantType() {
         return grantType;
     }
@@ -68,7 +69,7 @@
      * refreshToken getter.
      * @return e.g. XXXXX
      */
-    @NonNull
+    @Nullable
     public String getRefreshToken() {
         return refreshToken;
     }

OauthController checks these fields for empty/null and returns the custom error in that case. It looks like the new body binder gives 400 before the controller is ever hit, in the case where these fields are null. So it's just respecting the field annotations.

@sdelamo sdelamo requested a review from yawkat April 20, 2023 14:02
@sdelamo sdelamo marked this pull request as ready for review April 20, 2023 14:02
@sonarcloud
Copy link

sonarcloud bot commented Apr 20, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@sdelamo sdelamo merged commit 578faba into master Apr 20, 2023
@sdelamo sdelamo deleted the m2 branch April 20, 2023 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants