Is it possible to make all database interaction within an app limited to read? - mysql

I have an existing Laravel application with various functions, controllers, authentication, middleware, CRUD, admin functionality, and more. I want to be able to deploy this application onto some hosting and have others view all of the pages, but I do not want them to be able to edit or create values in the database. So, for example, while I have CRUD for all of the resources, I want them to be able to read all of the resources but not edit, create, or delete anything. I also want them to not have to register/login, but I know how to fix that.
I have tried LOCK TABLE [tablename] READ in MySQL, but that does not seem to have done anything. Currently, my only other idea would be to go through and set ifs checking if the user is authenticated to save database interactions, but this would be a little laborious.
Is there any feasible or simpler way of doing this? Thanks for any help.

Related

PHP script for front-end management of MySql tables

I'm looking for a PHP script that will allow me to easily manage 'MySql' tables. By managing I mean not their creation but the possibility of adding new records, modifying and deleting them.
It must be possible to specify for each user which tables he will have access to and with which modalities (insertion only, modification only, etc.).
For each user I will also have to specify whether he will be able to see all or some of the columns in the table and with which permissions.
Also I'll need to know who did what, a sort of global change LOG.
My idea was to have a back-end in which I specified the users and how to access the various tables/columns and a front-end for the users.
In the front-end users will be able to add/modify/delete records and data they are allowed and the ability to filter and/or sort the various records.
I know I could use some PHP frameworks or rely on CMS but I have to write a lot of code by hand and it seems hardly credible that such a product is not already available.
Does anyone know if there is something like this?
I had tried starting with PHP frameworks but implementing everything from scratch stopped me.
I expect there is already something available.
Thanks.
Davide.

Interconnect multiple databases on the same MySQL server

I am looking for a solution that lets me interconnect several databases.
But let me explain it with the exact example:
I have a main domain (front page for public clients) and four sub-domains (development, management, client, ...) in the clients webhosting.
Each domain has its own database and runs different software (WordPress, dolibarr, sysPass, our own software), but all databases are stored on the same mySQL server.
If a CRUD is made, I want that the other databases also "do" something with that data.
Basically, automation.
For example - a user on development.subdomain.xyz sets a project task to "finished".
When the UPDATE is done to the "development" database, I want an INSERT with parts of that data into the "management" database and an UPDATE towards the "client" database.
I could write up some script that connects to all four databases and does the operations necessary.
But that feels a little hard to maintain if multiple users shall have access to this "logic" system?
I could also use the provided API's and process the data (again in a script form rather than implementing a whole UI).
That feels like adding an unnecessary, extra security concern and again hard to maintain?
If I want to add additional functionality - like sending an Email as well, that would even make it harder for non-coders to interact.
So I found several of these "Low-Code Business Process Management" tools and now I'm at a loss.
Is that what I'm looking for? Can you throw me some tags, keywords or links to guide my search for possible solutions?
I do not even know how to call such a system or search for it - which stops me from progressing.
Thank you for all tips :)

Creating individual user profiles

I am working on a project and one of the key components is creating customized user profiles. I already have a schema design for the user data that will generate said profile. But I am lost on how the technology works.
I am mostly front-end so it has been sort of overwhelming. The goal is to allow multiple user profile creations and so far I have only seen that this can be achievable via NodeJs or PHP. I have not found any guides.
I am not sure if I am asking the right questions.
Any help is appreciated. Thank you.
Since you mention you already have schema for the user table, I assume you are going to design your own database and backend node.js API to handle user profiles. You may want to build authentication functionalities in the future. If you are not familiar with Node.js yet, I recommend you to start with https://www.tutorialspoint.com/nodejs/index.htm. It's a good tutorial for beginners.
The whole purpose of a back-end node.js API is building numbers of service with specified route. Once a http request is made to a particular path, it takes parameters and execute some script. In you case the scripts will do something in database containing user profile data, for example, add a row in your data table. This operation is equivalent to creating a new user. Then, the API send response to front-end.
Keep in mind maintaining user profile data is nothing special than regular data. You should be able to pick it up with a couple of days training if you know javascriopt. But if you have to build authentication functionality you need more technologies.

Add joint primary key to wordpress posts table

I am working out how to synchronize wordpress installations where both can be updated simultaneously, and both can work offline, then come online to sync.
I think the easiest way to sync posts between sites, is to include the site id in the primary key of the posts. Therefore, any post is identified by an incremental id and the id of the server location it was created from.
Is this possible to achieve with a plugin?
What dangers lie ahead if I pursue this path?
Is there a better, alternative way to achieve what I am trying to achieve?
It is possible in several ways:
- Write a stored procedure inside the first Wordpress installation's php files, that inserts the content into the other database when something is written to it. This one probably won't work offline.
- Write a function that compares the two databases at a schedule time using a simple sql query and creates a diff log. Then copies over the difference to the other database.
It depends why you need to do this, but if this works, I would recommend this solution:
- Keep one wordpress installation. Maintain one database, and connect to it from the other website to load the content. You can create your own SQL connection to it and load whatever content you need.
- Keep one wordpress installation, and use it's RSS feed to read the content and display it in whichever second website you need to do it in.
I can't imagine how a plugin would be of much help, especially keeping the databases in sync offline too. In my experience, its usually better to write your custom php scripts, rather than use a plugin so you can have a more direct control over the functionality.
Hope this helps.

Linux web front-end best practices

I want to build a web based front-end to manage/administer my Linux box. E.g. I want to be able to add users, manage the file system and all those sorts of things. Think of it as a cPanel clone but more for system admin rather that web admin.
I was thinking about creating a service that runs on my box and that performs all the system levels tasks. This way I can have a clear separation between my web based front-end and the actual logic. The server pages can than make calls to my specialized server or queue tasks that way. However, I'm not sure if this would be the best way to go about this.
I guess another important question would be, how I would deal with security when building something like this?
PS: This just as a pet project and learning experience so I'm not interested in existing solutions that do a similar thing.
Have the specialized service daemon running as a distinct user -- let's call it 'managerd'. Set up your /etc/sudoers file so that 'managerd' can execute the various commands you want it to be able to run, as root, without a password.
Have the web server drop "trigger" files containing the commands to run in a directory that is mode '770' with a group that only the web server user and 'managerd' are members of. Make sure that 'managerd' verifies that the files have the correct ownership before executing the command.
Make sure that the web interface side is locked down -- run it over HTTPS only, require authentication, and if all possible, put in IP-specific ACLs, so that you can only access it from known locations, in advance.
Your solution seems like a very sensible solution to the 'root' issue.
Couple of suggestions:
Binding the 'specialised service' to localhost as well would help to guarantee that requests can't be made externally.
Checking request call functions that perform the actions and not directly give the service full unrestricted access. So calling a function "addToGroup(user,group)" instead of a generic "performAction(command)".