I'm developping my very first app (a card game) where I use SpringBoot as back and Angular as front, they comunicate via API.
For this, I have a couple of @RestController where I have every methods I need (get, post, put, delete) for classes match
: /api/matches
and user
: /api/users
like the following :
@RestController
@CrossOrigin("*")
@RequestMapping("/matches")
public class MatchApiController {
@GetMapping
public List<Match> findAll() {
//blabla
}
//Other methods
}
And my classes are like this :
@Entity
@Table(name = "`match`")
public class Match {
//stuff
}
The app is working as intended but, I somehow found out that I can call other classes from my model in API. For example, if I go to /api/cards
I can see every cards of the database, which is very not much appreciated. Even worse : if I go to /api/users
I can see every user with their encrypted password ...
Actually, the API returns everything that is in the database, is that normal ? Am I missing something here ?
So my statement is the following :
Technically, I only need to retrieve match informations through /api/matches/4
for example. I also need the methods in the couple @RestController
.
I don't need any other information in /api
.
Is there any way to 'disable' classes I don't need in API ?
Or do I have to manually block them ? Maybe is there a simpler way to do this ?