InsiderPhD / Generic-University

Vulnerable API
385 stars 102 forks source link

Add additional interesting endpoints #2

Open InsiderPhD opened 4 years ago

InsiderPhD commented 4 years ago

The endpoints currently focus on grades, classes, user and roles, it might be interesting to add some more to better flush out the application, plus gives more to brute force. The controllers presently have easy copy and paste functionality to add the RESTful endpoints

    private $model = UniClass::class;

    public function __construct()
    {
        $this->model = \App::make($this->model);
    }

    function index()
    {
        return $this->model::all();
    }

    function store(Request $request)
    {
        return $this->model->create($request->input());
    }

    function show($id)
    {
        return $this->model->find($id);
    }

    function update(Request $request, $id)
    {

        if ($model = $this->model->find($id)) {
            $model->update($request->input());
            return $model;
        }
        return json_encode('Resource: ' . $id . ' with presented ID does not exist.');
    }

    function destroy($id)
    {
        $this->model->destroy($id);
    }