Skip to content

Commit cab6817

Browse files
committed
Set SwitchUserGrantedAuthorityMixIn in WebJackson2Module
Signed-off-by: John Niang <[email protected]>
1 parent df640f2 commit cab6817

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

web/src/main/java/org/springframework/security/web/jackson2/WebJackson2Module.java

+7-4
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,16 @@
2121

2222
import org.springframework.security.jackson2.SecurityJackson2Modules;
2323
import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken;
24+
import org.springframework.security.web.authentication.switchuser.SwitchUserGrantedAuthority;
2425
import org.springframework.security.web.csrf.DefaultCsrfToken;
2526

2627
/**
2728
* Jackson module for spring-security-web. This module register
28-
* {@link DefaultCsrfTokenMixin} and {@link PreAuthenticatedAuthenticationTokenMixin}. If
29-
* no default typing enabled by default then it'll enable it because typing info is needed
30-
* to properly serialize/deserialize objects. In order to use this module just add this
31-
* module into your ObjectMapper configuration.
29+
* {@link DefaultCsrfTokenMixin}, {@link PreAuthenticatedAuthenticationTokenMixin} and
30+
* {@link SwitchUserGrantedAuthorityMixIn}. If no default typing enabled by default then
31+
* it'll enable it because typing info is needed to properly serialize/deserialize
32+
* objects. In order to use this module just add this module into your ObjectMapper
33+
* configuration.
3234
*
3335
* <pre>
3436
* ObjectMapper mapper = new ObjectMapper();
@@ -53,6 +55,7 @@ public void setupModule(SetupContext context) {
5355
context.setMixInAnnotations(DefaultCsrfToken.class, DefaultCsrfTokenMixin.class);
5456
context.setMixInAnnotations(PreAuthenticatedAuthenticationToken.class,
5557
PreAuthenticatedAuthenticationTokenMixin.class);
58+
context.setMixInAnnotations(SwitchUserGrantedAuthority.class, SwitchUserGrantedAuthorityMixIn.class);
5659
}
5760

5861
}

web/src/main/java/org/springframework/security/web/jackson2/WebServletJackson2Module.java

+5-7
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,16 @@
2222

2323
import org.springframework.security.jackson2.SecurityJackson2Modules;
2424
import org.springframework.security.web.authentication.WebAuthenticationDetails;
25-
import org.springframework.security.web.authentication.switchuser.SwitchUserGrantedAuthority;
2625
import org.springframework.security.web.savedrequest.DefaultSavedRequest;
2726
import org.springframework.security.web.savedrequest.SavedCookie;
2827

2928
/**
3029
* Jackson module for spring-security-web related to servlet. This module registers
31-
* {@link CookieMixin}, {@link SavedCookieMixin}, {@link DefaultSavedRequestMixin},
32-
* {@link WebAuthenticationDetailsMixin}, and {@link SwitchUserGrantedAuthorityMixIn}. If
33-
* no default typing is enabled by default then it will be enabled, because typing info is
34-
* needed to properly serialize/deserialize objects. In order to use this module just add
35-
* this module into your ObjectMapper configuration.
30+
* {@link CookieMixin}, {@link SavedCookieMixin}, {@link DefaultSavedRequestMixin}, and
31+
* {@link WebAuthenticationDetailsMixin}. If no default typing is enabled by default then
32+
* it will be enabled, because typing info is needed to properly serialize/deserialize
33+
* objects. In order to use this module just add this module into your ObjectMapper
34+
* configuration.
3635
*
3736
* <pre>
3837
* ObjectMapper mapper = new ObjectMapper();
@@ -58,7 +57,6 @@ public void setupModule(SetupContext context) {
5857
context.setMixInAnnotations(SavedCookie.class, SavedCookieMixin.class);
5958
context.setMixInAnnotations(DefaultSavedRequest.class, DefaultSavedRequestMixin.class);
6059
context.setMixInAnnotations(WebAuthenticationDetails.class, WebAuthenticationDetailsMixin.class);
61-
context.setMixInAnnotations(SwitchUserGrantedAuthority.class, SwitchUserGrantedAuthorityMixIn.class);
6260
}
6361

6462
}

0 commit comments

Comments
 (0)