Home

Awesome

Configure your Firebase function to generate Virgil JWT

Greenkeeper badge

This repository contains a backend's function that connects your Virgil and Firebase accounts for implementing end-to-end encryption.

Prerequisites

You can use one of node version managers to switch the version: n or nvm

Configure Your Firebase Project

We assume that you already have a Firebase Project. If you don't, please create one now at your Firebase Console.

Configure User Authentication

If you haven't already, set up Sign-in method in your Firebase Project by enabling any of the Sign-in providers. For the purposes of this tutorial it doesn't matter which sign-in provider you choose.

To set up your Sign-in method, go to your Firebase Console and navigate to Authentication, under Develop. Go to the Sign-in method tab and set up your preferred sing-in method(s).

Deploy the Firebase function

This Firebase function will connect Firebase's and Virgil's authentication via JWT tokens.

Set up Firebase project

<img src="img/firebase_use_add.png" alt="Connect repository to your Firebase project">

Set up Virgil Application

  1. Navigate to the Virgil Dashboard -> Your Application -> E3Kit Section.
<img height="300px" src="img/virgil_app.png" alt="Virgil Application">
  1. Generate .env in the .env file section.
<img height="300px" src="img/virgil_env.png" alt="Virgil Application .env generation">
  1. Download the generated file, paste it into the project root folder and rename it to .env.
<img height="300px" src="img/virgil_creds.png" alt="Virgil Application .env credentials">

Install dependencies

Deploy function

:warning: Since August 17, 2020, Firebase has changed their billing plans. In order to deploy the function and run this demo, you will need to change your project billing plan to "Blaze" in project settings "Usage and Billing".

Now, in your at your Firebase Console in "Develop" -> "Functions" you'll be able to see the function deployed:

<img src="img/firebase_deployed.png" alt="Firebase function deployed">

Troubleshooting

Error: Error parsing triggers: Cannot find module '../virgil_crypto_node.node'

Make sure you've followed the instructions in the README. If you did so, try running this command:

node node_modules/virgil-crypto/scripts/download-node-addon.js

TypeError: Cannot destructure property app_id of 'undefined' or 'null'.

You most likely forgot to generate the .env file or named it incorrectly. Make sure the file is named exactly .env (no '.txt' at the end and no other extensions) and contains your keys in a similar format:

APP_ID=40afa3ea[...]520c1be
APP_KEY_ID=0e6f[...]fd3476c3cf
APP_KEY=MC4CAQt[...]7DprlzC7gG1

License

This library is released under the 3-clause BSD License.

Support

Our developer support team is here to help you. Find out more information on our Help Center.

You can find us on Twitter or send us email support@VirgilSecurity.com.

Also, get extra help from our support team on Slack.