0

I am creating a spring boot application. I am adding few endpoints to it. In that process some of the endpoints are secure and some are not.

Once the application is installed I am getting some extra endpoints giving application info which are not even exposed.

Example: Some of the exposed endpoints are

@RestController
@RequestMapping("/category/v1")
public class ControllerClass {
     @RequestMapping(value="/pillars", method=RequestMethod.GET)
     public String pillarGetMethod() {
       //method
     }

     @RequestMapping(value="/frameworks", method=RequestMethod.GET)
     public String frameworkGetMethod() {
       //method
     }
}

Now expectation is we will have

  • /category/v1/pillars
  • /category/v1/frameworks

should get exposed.

But with that

  • /pillars
  • /frameworks

is also getting exposed with response as

{
  "_embedded" : {
    "pillars" : [ {

    } ]
  },
  "_links" : {
    "self" : {
      "href" : "http://<ip>/pillars{?page,size,sort}",
      "templated" : true
    },
    "profile" : {
      "href" : "http://<ip>/profile/pillars"
    },
    "search" : {
      "href" : "http://<ip>/pillars/search"
    }
  },
  "page" : {
    "size" : 20,
    "totalElements" : 5,
    "totalPages" : 1,
    "number" : 0
  }
}

I need help on understanding the output and also how I can stop this from getting exposed.

Marc Tarin
  • 3,109
  • 17
  • 49
Shaleen
  • 829
  • 7
  • 17
  • 2
    Did you define something like PillarRepository and Framework classes extending CrudRepository? If so, the underlying resources are automatically exposed by Spring Boot/Spring Data Rest, unless you annotate the repositories with `@RepositoryRestResource(exported = false)`. – Marc Tarin Sep 25 '17 at 11:05
  • Thank you very much @Marc. It solved the issue. Please add the response as answer, I will be very happy to accept the answer as correct answer. – Shaleen Sep 25 '17 at 11:54

1 Answers1

1

My guess is you defined something like :

public class PillarRepository extends CrudRepository<Pillar, String> { ... }

public class FrameworkPillarRepository extends CrudRepository<Pillar, String> { ... }

If so, the underlying resources are exposed automatically by Spring Boot/Spring Data Rest, unless you annotate the repositories with @RepositoryRestResource(exported = false).

If you just wish to reproduce the automatic GET behavior, but with a custom path, use the path option.

Marc Tarin
  • 3,109
  • 17
  • 49