-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Redis session repository with Jackson cannot serialize BadCredentialException #1013
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
Comments
Thanks for the report @YLombardi. I've reproduced the issue using our Redis with JSON serialization Boot sample app and this diff: diff --git a/samples/boot/redis-json/src/main/java/sample/web/HomeController.java b/samples/boot/redis-json/src/main/java/sample/web/HomeController.java
index ae8150e7..d73e2254 100644
--- a/samples/boot/redis-json/src/main/java/sample/web/HomeController.java
+++ b/samples/boot/redis-json/src/main/java/sample/web/HomeController.java
@@ -15,8 +15,11 @@
*/
package sample.web;
+import java.util.UUID;
+
import javax.servlet.http.HttpServletRequest;
+import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.stereotype.Controller;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -34,6 +37,7 @@ public class HomeController {
HttpServletRequest request) {
if (!ObjectUtils.isEmpty(key) && !ObjectUtils.isEmpty(value)) {
request.getSession().setAttribute(key, value);
+ request.getSession().setAttribute(UUID.randomUUID().toString(), new BadCredentialsException("test"));
}
return "home";
} This should perhaps be handled by Spring Security, WDYT @rwinch? Same error was reported in spring-projects/spring-security#4370 (comment). |
@YLombardi Thanks for the report! @vpavic Thanks for reaching out. I agree. Can you create a ticket or PR in Spring Security to track this? In the meantime adding your own mapping for the missing classes should work around the issue. |
Thanks for your quick reply. @rwinch How can I add my own mapping ? Do I have to create a Mixin for the class ? |
@YLombardi Yes you need to create your own Mixin. If you get something working you can submit a PR which will speed up getting this merged into Spring Security |
Closing since this has been addressed on Spring Security side by spring-projects/spring-security#5087. |
I just migrate my application to spring-boot 2 / Spring 5 and I have difficulties to configure the session cache.
I use spring-security, spring-session-data-redis and jackson2.
When I use a good login/password, everything works fine. The session is stored in Redis with a Json format.
But if I enter a wrong password, the application try to store the BadCredentialException and ActiveDirectoryAuthenticationException in Redis (I have 2 AuthenticationProvider : PreAuthenticatedAuthenticationProvider and ActiveDirectoryLdapAuthenticationProvider).
The problem is that Jackson cannot serialize the BadCredentialException.
Here is my configuration :
Is it possible to configure Spring to store the session only if the login is a success ?
The text was updated successfully, but these errors were encountered: