سؤال

Is it possible that a website uses the models of another lavarel website to access the database, without the first website having the sql credentials hardcoded. But with the credentials to log into the second lavarel website hardcoded.

This way the first website doesn't have to have the sql credentials on it's ftp server, but can still access the databases through the other website (with their personal login of that website).

If that is impossible, I am wondering, is there a way to access a databases without having to hardcode the credentials anywhere.

UPDATE (the actual problem) Only a part of the database should be visible to a particular user, so i can provide different users with different credentials and they all see something different in the database

هل كانت مفيدة؟

المحلول

What you are talking about is an API. So you'd build out the entire infrastructure on the first website, then on the second website, it would make some kind of calls to the first website to get back the information it needs, usually using some kind of credentials or access token.

This way, you can allow anyone in the world to communicate with your website, kind of like how Facebook, or Twitter does.

As far as accessing your database, you would need to tell your app somewhere the credentials to use, so technically, you do need to hardcode them somewhere as they can't just magically make up some credentials somehow to access a database.

نصائح أخرى

if your different users are defined:

  • use laravel model/db event to replicate the data to a database by user.
  • Or sync each database with a cron job..

These have benefits to avoid security transport problems.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top