spring-projects / spring-projects/spring-data-rest

Support security constraints on projections [DATAREST-1108]

Open
#1,413 0 comments 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Dec 31, 2020.

type: task
Dominant language
Java
Stars
958
Forks
568
PR merge metrics
No merged PRs in 30d

Description

Christopher Smith opened DATAREST-1108 and commented

The projection facility is useful for serializing specific sets of fields. However, there are many cases where only certain sets should be available to particular users (anonymous, non-object-owners, etc.). DATAREST-428 provides one way to customize projection selection based on user attributes, but this approach may be applicable broadly enough to add officially:

Support the standard Spring Security annotations on the projection interface itself. When the projection is requested, evaluate the annotations (e.g., for projection=full, check that #principal.id == #object.owner.id) and apply the security policy:

@Projection(name = "full", types = AResource.class)
@PreAuthorize("#principal.id == #object.owner.id")
public interface AllFieldsProjection {
    ...
}

This would cover a significant portion of the common use cases in a manner that's reusable, easy to understand, and without repeated boilerplate


Affects: 2.5.11 (Hopper SR11)

1 votes, 2 watchers

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.