Skip to content

Filter out the entity properties from the output of Jackson serialization according to the DenyAll, RolesAllowed annotations.

Notifications You must be signed in to change notification settings

sutra/jackson-module-jsr250

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

87 Commits
 
 
 
 
 
 
 
 

Repository files navigation

About Security Entity Filtering Module

Filter out the entity properties from the output of Jackson serialization according to the DenyAll, RolesAllowed annotations.

How to use

Register the Jsr250Module to ObjectMapper:

ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new Jsr250Module());

Mark your properties with annotations @RolesAllowed, @DenyAll:

public class User {

	@RolesAllowed("ROLE_ADMIN")
	public String getUsername() {
		return username;
	}

	@DenyAll
	public String getPassword() {
		return password;
	}

}

and then the relevant properties would be filtered out from the serialized JSON, check Jsr250ModuleTest for details.

Note: the roles is read from SecurityContextHolder.getContext().getAuthentication().getAuthorities() of spring-security.

About

Filter out the entity properties from the output of Jackson serialization according to the DenyAll, RolesAllowed annotations.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages