Deserialize the principal in a neutral way
When the principal of the Authentication is an object, it is not necessarily an User: it could be another implementation of UserDetails, or even a completely unrelated type. Since the type of the object is serialized as a property and used by the deserialization anyway, there's no point in enforcing a stricter type.
This commit is contained in:
committed by
Rob Winch
parent
6fd9ff254b
commit
35706ad60a
+1
-2
@@ -20,7 +20,6 @@ import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.userdetails.User;
|
||||
import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
@@ -63,7 +62,7 @@ class PreAuthenticatedAuthenticationTokenDeserializer extends JsonDeserializer<P
|
||||
JsonNode principalNode = readJsonNode(jsonNode, "principal");
|
||||
Object principal = null;
|
||||
if(principalNode.isObject()) {
|
||||
principal = mapper.readValue(principalNode.traverse(mapper), new TypeReference<User>() {});
|
||||
principal = mapper.readValue(principalNode.traverse(mapper), Object.class);
|
||||
} else {
|
||||
principal = principalNode.asText();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user