Skip to content
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

Read-only attribute for @RepositoryRestResource or control over exposed HTTP verbs [DATAREST-1289] #1650

Closed
spring-projects-issues opened this issue Sep 26, 2018 · 6 comments
Assignees
Labels

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Sep 26, 2018

B. K. Oxley (binkley) opened DATAREST-1289 and commented

I'm finding scarce documentation for having read-only REST for a repository.  In particular, I'd like to disable PUT/POST/PATCH/DELETE.  Presently, it seems I need to override every method inherited from CrudRepository that is mutating, and mark them with @RestResource(exported = false).  I'd much rather have either:

A. A readOnly = true attribute on @RepositoryRestResource
B. An attribute to black list or white list which HTTP verbs are exposed

To save work, we've extended CrudRepository (well ... JpaRepository) for a project-specific base interface with mutating methods marked exported = false, but this feels clumsy


No further details from DATAREST-1289

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Sep 27, 2018

B. K. Oxley (binkley) commented

To explain motivation a little further, we'd like to enforce the architecture pattern that reads of the repository are well-supported by built-in features of Spring Data REST.  For writes to the repository, we'd like devs to code controllers that encapsulate the business logic.  Our entities are not simple documents, but capture particular states of business flow.

A trivial example is integrations with external systems.  These require business methods to manage, and direct updating of the repository, bypassing business logic, leaves our system in an indeterminate state

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Oct 1, 2018

B. K. Oxley (binkley) commented

It looks like Lovelace may provide this: https://spring.io/blog/2018/09/27/what-s-new-in-spring-data-lovelace

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Oct 7, 2018

B. K. Oxley (binkley) commented

I find a lot of help here: 

https://docs.spring.io/spring-data/rest/docs/current/reference/html/#customizing-sdr.http-methods.default-exposure

However, in context of Spring Boot, SpringBootRepositoryRestConfigurer is the key class for binding application properties to Data REST settings, and this class is "package" scope without extension hooks

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Oct 8, 2018

Oliver Drotbohm commented

I'm puzzled. You don't need anything Boot specific. Just register a RepositoryRestConfigurer as Spring Bean:

@Bean
RepositoryRestConfigurer customizations() {
  return RepositoryRestConfigurer.withConfig(it -> {
    it.getExposureConfiguration().forDomainType(User.class).disablePutForCreation();
  });
}

Looks like everything you need is in place, isn't it?

@spring-projects-issues spring-projects-issues added status: waiting-for-feedback in: repository type: enhancement labels Dec 31, 2020
@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jan 7, 2021

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

@spring-projects-issues spring-projects-issues added the status: feedback-reminder label Jan 7, 2021
@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jan 14, 2021

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

@spring-projects-issues spring-projects-issues removed status: waiting-for-feedback status: feedback-reminder labels Jan 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants