Skip to content

guifcoelho/encrypt-and-separate-firebase-credentials-using-laravel

Repository files navigation

Encrypt and separate your Firebase credentials json file from your Laravel project code base

Build Status

Learn how to deploy a Laravel-Firebase web app without the credentials json file in the code base.

Laravel

  1. Install Laravel with composer create-project --prefer-dist laravel/laravel [project]
  2. Run composer require defuse/php-encryption kreait/firebase-php to install the encryption library and the Firebase PHP SDK
  3. Create folders 'app/Services/Firebase/Controllers' and 'app/Services/Firebase/Keys' to add Firebase controllers and keys
  4. Change the 'config/services.php' file, adding at the end:
'firebase' => [
    'encryption_password' => env('FIREBASE_KEY_ENCRYPTION_PASSWORD'),
    'credentials_file_url' => env('FIREBASE_CREDENTIALS_FILE_URL'),
],
  1. Add 'FIREBASE_KEY_ENCRYPTION_PASSWORD', 'FIREBASE_CREDENTIALS', and 'FIREBASE_CREDENTIALS_FILE_URL' to your .env file
  2. Run encrypt-service-keys Firebase [credentials.json] [new_file].encrypt [encryption password] to encrypt the Firebase credentials json file
  3. Save the encrypted file in a public repository

composer.json

  1. In the composer.json file, add command into 'post-autoload-dump': "@php artisan decrypt-service-keys Firebase credentials.json"

Travis-CI

  1. Create Travis .yml file
  2. Add 'APP_KEY', 'FIREBASE_KEY_ENCRYPTION_PASSWORD', 'FIREBASE_CREDENTIALS', and 'FIREBASE_CREDENTIALS_FILE_URL' into the environment variables
  3. Run tests

Heroku

  1. Create app on Heroku
  2. Run heroku buildpacks:set heroku/php
  3. Add 'APP_KEY', 'FIREBASE_KEY_ENCRYPTION_PASSWORD', 'FIREBASE_CREDENTIALS', and 'FIREBASE_CREDENTIALS_FILE_URL' into the environment variables
  4. Create Procfile
  5. Run composer require --dev heroku/heroku-buildpack-php
  6. Link app to your GitHub repo or run git push heroku master

License

This project is open-source software licensed under the MIT license.

About

Encrypt and separate your Firebase credentials json file from your Laravel project code base

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published