Skip to content

Latest commit

 

History

History
112 lines (72 loc) · 4.35 KB

securing-your-instance.md

File metadata and controls

112 lines (72 loc) · 4.35 KB

By default, your Pizzly instance does not require an authentication method to access its data. It's great for local development but not recommended if you plan to use it with production data.

In this guide, you will learn how to secure your Pizzly instance.

Environment variables

Pizzly use environment variables to restrict access to the instance. Here's short overview

Name Services protected
DASHBOARD_USERNAME Dashboard
DASHBOARD_PASSWORD Dashboard
SECRET_KEY API, Proxy
PUBLISHABLE_KEY Auth, Proxy

DASHBOARD_USERNAME

Your Pizzly dashboard can be protected behind a username & password, using the Basic access authentication method. DASHBOARD_USERNAME is the username.

DASHBOARD_PASSWORD

Your Pizzly dashboard can be protected behind a username & password, using the Basic access authentication method. DASHBOARD_PASSWORD is the password.

Once both are set, your browser will prompt an authorization window:

Authentication prompt to access the dashboard

SECRET_KEY

Your SECRET_KEY should be kept confidential and only stored on your own servers. Your account’s secret API key can perform any request to the API and Proxy services, without restriction.

Once set, authenticate requests to your Pizzly instance by using a basic authorization method and provide the SECRET_KEY as username (without password):

curl -X GET "/api/"
  -u "$SECRET_KEY:"

PUBLISHABLE_KEY

Your PUBLISHABLE_KEY isn’t secret and shouldn't be considered as is. Publishable keys only have the power to make auth & proxy requests. And requests to the proxy service can be deactivated (learn more).

Securing Pizzly on a PaaS (Heroku, Platform.sh, etc.)

Most PaaS provides guides on how to configure environments variables on their platform:

Securing Pizzly with .envrc

If you have SSH access to your server, you can use a configuration file.

  1. In the root directory of your Pizzly project, open the .envrc file. If you don't have one, you can copy the .envrc.example file with this command: cp .envrc.example .envrc

  2. In that file, heads to the "Secure" section. It should look something similar to this:

    #
    # Secure your instance
    #
    # 1. Secure access to the dashboard
    #
    export DASHBOARD_USER=""
    export DASHBOARD_PASSWORD=""
    #
    # 2. Secure requests to the API
    #
    export SECRET_KEY=""
    export PUBLISHABLE_KEY=""
  3. Update each environment variables with new values. Make sure to generate unguessable keys. A password manager can help a lot here.

  4. Accept the changes with:

    direnv allow
  5. Restart your server for the changes to take effect. Locally, you will have to enter:

    yarn build && yarn start
  6. Redeploy your instance

Extra options

Disallow frontend requests to the proxy service

Pizzly's proxy accepts requests having a valid publishableKey. This means that someone that knows your publishableKey can query an API using your Pizzly's instance.

As the key is publicly available on your frontend, this might feel insecure, but remind that the publishableKey is used only to authenticate the request with Pizzly. An attacker would need both a valid publishableKey and a valid authId to make request to a third-party API.

Still, if you aren't feeling safe to accept frontend requests, you can easily refuse them.

  1. Go to your host configuration settings or open your configuration file (.envrc) config file

  2. Set the following environment variable to "TRUE":

    PROXY_USES_SECRET_KEY_ONLY=TRUE
  3. Restart or redeploy your instance. On most PaaS (e.g. Heroku), the instance is automatically restarted when you update an environment variables.

What's next?

Now that your Pizzly instance is secured, here are a few guides that might be helpful: