0
I have a php application that consumes the firebase service Account api. I use the.json credential file provided by firebase.
I would like to know how I can protect this file from improper access? The code below is of the class that provides the service. The credential is in the same folder.
namespace App\Services\Google\Firebase;
use Kreait\Firebase\Factory; use Kreait\Firebase\ServiceAccount;
class FirebaseService {
public $database;
public $firebase;
public function __construct() {
// This assumes that you have placed the Firebase credentials in the same
directory
// as this PHP file.
$serviceAccount = ServiceAccount::fromJsonFile(__DIR__ . '/credencial.json');
$this->firebase = (new Factory)
->withServiceAccount($serviceAccount)
// The following line is optional if the project id in your credentials file
// is identical to the subdomain of your Firebase project. If you need it,
// make sure to replace the URL with the URL of your project.
->withDatabaseUri('url...')
->create();
$this->database = $this->firebase->getDatabase();
}
}
Where you kept the file?
– Rosário Pereira Fernandes
In the same folder where I created the class to provide the Firebase service.
– Cardoso Dev