Break interface for MySQL database with ACL

99% of what the REST API does is a managed interface between the client and the database, and yet I can’t find any libraries that do just that for the rest of my life.

All libraries focus on providing a REST interface to the developer, who then establishes a connection to the database. It seems to me that I don’t need to create a library that already interacts with the database, and all that the developer needs is to define some ACL rules and connect some logic here or there.

So, before I continue and put my thoughts into action, actually creating such a library, can I just ask someone who knows about this subject; Has anyone implemented something like this? Will I reinvent the wheel?

I'm talking about PHP-based approaches, by the way, I have nothing against other languages, PHP is just my cup of tea. But in this regard, I did not find any implementations in other languages.

And in case my explanation does not make it very clear, this is essentially what I want:

<?php class post_controller extends controller { protected static $config = array( 'select' => true, 'insert' => true, 'update' => true, 'delete' => false, 'fields' => array( 'id' => array( 'select' => true, 'update' => false ), 'name' => array( 'select' => true, 'update' => true ), 'content' => array( 'select' => true, 'update' => true ) ) ); /** * GET, POST, DELETE are implemented already by the parent controller * Just overriding PUT to modify the content entry */ function put($data) { $data->content = htmlentities($data); return parent::put($data); } } ?> 

Thanks in advance to anyone who provides their material and apologies if this is not the right question about Stackoverflow.

Edit:

To clarify, this type of service will be used for specific use cases, I do not think it is a type of thing that anyone can use for any type of web service.

+4
source share
1 answer

I created a similar system for SOAP and I must say that it is very easy to do. I have not seen any ready-made libraries that would help you do this (and I doubt that they exist - see the next paragraph), but to create my own solution it does not take more than a few hours (maximum per day for testing and including documentation).

This is another question if you really want to do this. REST can be (incorrectly) used for this purpose, but is intended for resource management. Entries in the database rarely have a one-to-one mapping to resources. If they do this in your case (as I had), then feel free to do it, otherwise it would be better to provide a proper REST API. Why expose your internal database structure to the world? YMMV, of course.

0
source

All Articles