Databunker Documentation

repository·master·Indexed 23 days ago

https://github.com/securitybunker/databunker

A self-hosted, Go-based tool for the secure tokenization and storage of sensitive personal records (PII, PHI, KYC). Databunker acts as a secure vault to separate sensitive data from application databases for GDPR compliance and protection against injection attacks. Documentation covers installation via Docker and Helm on Kubernetes, configuration of external databases, TLS/SSL certificate management, and REST API usage.

Tokens
20.3K
Snippets
41
Records
138
Agent score
79%

What's inside Databunker

  1. Manage TLS Secrets for Ingress

    master

    You can manage TLS certificates in three ways:

    1. Helm-managed: Copy your certificate and key values directly into the ingress.secrets entry in your values.yaml.
    2. External management: Create a TLS secret manually in Kubernetes (e.g., named databunker.service-tls).
    3. Cert-manager: Use a tool like cert-manager to manage secrets automatically.

    Certificate files must be PEM-encoded. Example formats:

    Certificate:

    -----BEGIN CERTIFICATE-----
    ...
    -----END CERTIFICATE-----

    Private Key:

    -----BEGIN RSA PRIVATE KEY-----
    ...
    -----END RSA PRIVATE KEY-----
  2. Use the Shareable Record API

    master

    The Shareable Record API allows you to create temporary, public records that reference internal objects (users, sessions, etc.). This is useful for sharing specific profile parts or session details with 3rd party systems or logs without requiring authentication for the recipient.

    Note: Access to the record data is open to anyone who has the {record} token; no access token or password is required for retrieval.

  3. Manage additional user data with User App API

    master

    The User App API allows you to store supplemental information (like shipping addresses) that is separate from the core user profile.

    • Create/Overwrite: POST /v1/userapp/token/{token}/{appname}. Submitting multiple times for the same user and appname will overwrite the previous value.
    • Update: PUT /v1/userapp/token/{token}/{appname}.
    • Get specific app record: GET /v1/userapp/token/{token}/{appname}.
    • Get all app records for a user: GET /v1/userapp/token/{token}.
    • List all apps: GET /v1/userapps.
    # Create a shipping record
    curl -s http://localhost:3000/v1/userapp/token/$TOKEN/shipping \
      -H "X-Bunker-Token: $XTOKEN" -H "Content-Type: application/json" \
      -d '{"country":"UK","city":"London","address":"221B Baker Street","postcode":"12345","status":"new"}'
  4. How Databunker works: Tokenization and Storage

    master

    Databunker operates as a secure vault for sensitive personal data (PII/PHI/KYC). The workflow follows these steps:

    1. Storage: You send sensitive data to Databunker via its API.
    2. Tokenization: Databunker returns a UUID token. You store this token in your primary application database instead of the actual sensitive data.
    3. Querying: When you need the data, you query Databunker using the token or secure, hash-based indexing.
    4. Protection: This architecture ensures that even if your main database is compromised via SQL or GraphQL injection, the attacker only retrieves meaningless UUID tokens, not plaintext personal information.
  5. Manage user consent with the Consent API

    master

    Databunker provides an API for storing and managing user consent (e.g., GDPR compliance). Consent is identified by a brief value, which is a unique, short ID per user.

    Constraints for brief:

    • Allowed characters: [a-z0-9-]
    • Maximum length: 64 characters.

    Available Endpoints

    Resource / HTTP methodPOST (create/approve)GET (read)DELETE (withdraw)
    /v1/consent/token/{token}/{brief}
    /v1/consent/login/{login}/{brief}
    /v1/consent/email/{email}/{brief}
    /v1/consent/phone/{phone}/{brief}
    /v1/consent/token/{token}N/A✅ (all records)N/A
    /v1/consent/login/{login}N/A✅ (all records)N/A
    /v1/consent/email/{email}N/A✅ (all records)N/A
    /v1/consent/phone/{phone}N/A✅ (all records)N/A
    /v1/consents/{brief}N/A✅ (all users)N/A
  6. Manage user sessions with Session API

    master

    The Session API is used to store and manage session-related PII (e.g., IP addresses, user agents, or mobile device info). Each session record has an expiration period; once expired, the record is automatically deleted.

    • Create Session: POST /v1/session/{token,login,email,phone}/{identity}. You can provide an expiration parameter (e.g., "3d") to specify the TTL.
    • Get specific session: GET /v1/session/session/:session.
    • Get all sessions for a user: GET /v1/session/{token,login,email,phone}/{identity}. This endpoint supports pagination via offset and limit query parameters.
  7. Push Databunker container images

    master

    Project admins can push the built container images to the registry. This includes pushing the specific version tag and optionally the latest tag.

    docker login
    VERSION=$(cat ./version.txt)
    docker push securitybunker/databunker:$VERSION
    # Optionally, push container with the latest tag
    docker tag securitybunker/databunker:$VERSION securitybunker/databunker:latest
    docker push securitybunker/databunker:latest
  8. Upgrade Databunker cluster to the latest version

    master

    You can upgrade your Databunker deployment using Helm without losing access to encrypted records. The initial deployment creates a Kubernetes secret named databunker which contains the DATABUNKER_MASTERKEY (for record encryption) and the DATABUNKER_ROOTTOKEN (for service access). This secret is preserved during upgrades.

    To upgrade, run helm upgrade with the same external database and certificate configurations used during the initial installation.

    helm repo update
    MYSQL_RDS_HOST=$(terraform output -raw rds_hostname)
    helm upgrade databunker --set mariadb.enabled=false \
      --set externalDatabase.host=$MYSQL_RDS_HOST \
      --set externalDatabase.existingSecret=databunker-mysql-rds \
      --set certificates.customCertificate.certificateSecret=databunkertls
  9. Install the Databunker DEMO using NodePort

    master

    To deploy the Databunker DEMO using a NodePort service, use the following command. By default, the service will be accessible on port 30300. You can access the UI locally at http://localhost:30300/.

    helm install demo databunker/databunker-demo --set service.type=NodePort
  10. Configure private registry images

    master

    To use an image from a private registry, you must specify an imagePullSecrets configuration. Note that imagePullSecrets cannot be passed via the --set flag in Helm; it must be provided in a values.yaml file.

    1. Manually create the image pull secret in your Kubernetes namespace.
    2. Add the secret name to your values.yaml.
    imagePullSecrets:
      - name: SECRET_NAME
  11. Deploy Databunker service on EKS using Helm

    master

    After provisioning AWS infrastructure, follow these steps to deploy the Databunker service onto your EKS cluster using Helm. This process requires setting up your Kubernetes configuration, generating a self-signed SSL certificate, and configuring the Helm chart to use your external RDS instance.

    Prerequisites:

    1. Set your KUBECONFIG environment variable to point to the generated Kubernetes configuration file.
    2. Generate an SSL certificate and store it as a Kubernetes secret named databunkertls.
    3. Add and update the Databunker Helm repository.
    4. Retrieve the rds_hostname from Terraform output.
    # 1. Configure kubectl
    export KUBECONFIG=`pwd`/`ls -1 kubeconfig_*`
    
    # 2. Create SSL certificate and Kubernetes secret
    openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout tls.key -out tls.crt -subj "/CN=localhost"
    kubectl create secret tls databunkertls --key="tls.key" --cert="tls.crt"
    
    # 3. Setup Helm repository
    helm repo add databunker https://databunker.org/charts/
    helm repo update
    
    # 4. Deploy Databunker
    MYSQL_RDS_HOST=$(terraform output -raw rds_hostname)
    helm install databunker databunker/databunker --set mariadb.enabled=false \
      --set externalDatabase.host=$MYSQL_RDS_HOST \
      --set externalDatabase.existingSecret=databunker-mysql-rds \
      --set certificates.customCertificate.certificateSecret=databunkertls