Search code examples
faunadb

Faunadb dev: fixed secret key


I’m using the dev container and I need to have a fixed secret key. Here’s my current script to create the container and the db.

#!/usr/bin/env bash

docker pull fauna/faunadb
docker container stop faunadb || true && docker container rm faunadb || true
docker run --name faunadb -d \
        --health-cmd="faunadb-admin status" --health-interval=5s \
        -p 8443:8443 \
        -p 8084:8084 \
        fauna/faunadb
./docker/wait-for-healthy.sh faunadb 30

echo n | fauna add-endpoint http://localhost:8443/ --alias localhost --key secret
fauna create-database generator_dev --endpoint=localhost
fauna create-key generator_dev --endpoint=localhost

curl -u secret: http://localhost:8084/import --data-binary "@functions/schemas/schema.graphql"

I would like this command to always return the same secret key

fauna create-key generator_dev --endpoint=localhost

Is that possible? I need a fixed secret key because I need to import the schema in the next step, so the easy way is to have a known secret key

Any idea is appreciated


Solution

  • By default, the Fauna Dev Docker image uses secret as the root-level admin key's secret. That would provided the consistency you seek without requiring additional key generation.

    When you create a key, the BCrypt algorithm is employed, and the Snowflake-inspired document id is incorporated into the hash. That means that there is no way to "generate" a consistent key multiple times.

    For most situations, where you are simulating a production workload, you would have to create a new key, capture the returned secret, and use the secret in subsequent queries. How you do that is up to you.