Security

enterprise

Performance Replication with Paths Filter

Paths filter is a new way of controlling which secrets are moved across clusters and physical regions as a result of replication. With replication filters, users can select which secrets engines will be replicated as part of a performance replication relationship.

By default, all non-local secrets engines and associated data are replicated as part of replication. The paths filter feature enables users to allow or deny which secrets engines are replicated, thereby allowing users to further control the movement of secrets across their infrastructure.

Performance Replication

Challenge

General Data Protection Regulation (GDPR) is designed to strengthen data protection and privacy for all individuals within the European Union. It requires that personally identifiable data not be physically transferred to locations outside the European Union unless the region or country has an equal rigor of data protection regulation as the EU.

Failure to abide by GDPR will result in fines as high as 20 million EUR or 4% of the global annual revenue (whichever greater).

Solution

Leverage Vault's paths filter feature to abide by data movements and sovereignty regulations while ensuring performance access across geographically distributed regions.

The Preparing for GDPR Compliance with HashiCorp Vault webinar discusses the GDPR compliance further in details.

Prerequisites

This intermediate Vault operations guide assumes that you have some working knowledge of Vault.

You need two Vault Enterprise clusters: one representing the EU cluster, and another representing the US cluster both backed by Consul for storage.

Scenario Introduction

An organization has a Vault cluster in EU and wish to span across the United States by setting up a secondary cluster and enable the performance replication. However, some data must remain in EU and should not be replicated to the US cluster.

Guide Scenario

Leverage the paths filter feature to deny the secrets from being replicated, that are subject to GDPR, from being replicated across the regions.

  1. Segment GDPR and non-GDPR secrets
  2. Enable performance replication with paths filter
  3. Secondary cluster re-authentication
  4. Verify the replication paths filter
  5. Enable a local secrets engine

Step 1: Segment GDPR and non-GDPR secrets

In the EU cluster (primary cluster), enable key/value secrets engines:

  • At EU_GDPR_data for GDPR data
  • At US_NON_GDPR_data for non-GDPR data localized for US

Also, create the following namespaces:

  • office_FR is used by the office branch in France
  • office_US is used by the office branch in US
  1. Enable the key/value v2 secrets engine at the EU_GDPR_data path.

    $ vault secrets enable -path=EU_GDPR_data kv-v2
    
  2. Enable the key/value v2 secrets engine at the US_NON_GDPR_data path.

    $ vault secrets enable -path=US_NON_GDPR_data kv-v2
    
  3. Create a namespace named office_FR.

    $ vault namespace create office_FR
    
  4. Create a namespace named office_US.

    $ vault namespace create office_US
    

Step 2: Enable performance replication with paths filters

  1. Enable performance replication on the primary cluster.

    $ vault write -f sys/replication/performance/primary/enable
    WARNING! The following warnings were returned from Vault:
    
    This cluster is being enabled as a primary for replication. Vault will be
    unavailable for a brief period and will resume service shortly.
    
  2. Generate a secondary token.

    $ vault write sys/replication/performance/primary/secondary-token id="secondary"
    Key                              Value
    ---                              -----
    wrapping_token:                  eyJhbGciOiJFUzUxMiIsInR5cCI6IkpXVCJ9.eyJhZGRyIjoiaHR0cDovLzE3Mi4zMS4yMC4xODA6ODIwMyIsImV4cCI6MTUyNTg0ODAxMywiaWF0IjoxNTI1ODQ2MjEzLCJqdGkiOiJlNTFiMjUxZi01ZTg2LTg4OWEtNGZmMy03NTQzMjRkNTdlMGQiLCJ0eXBlIjoid3JhcHBpbmcifQ.MIGGAkE2dDj3nmaoLHg7oldQ1iZPD0U8doyj3x3mQUVfTl8W99QYG8GM6VGVzhRPGvKctGriuo2oXN_8euWQb01M1y6n7gJBSu-qdXw-v2RieOyopAHls1bWhw4sO9Nlds8IDFA15vqkLXnq2g4_5lvlhxpP7B8dEOHvWXkHG4kJ_mKvrgR0dU0
    wrapping_accessor:               6ded4fb0-5e8c-2a37-1b3e-823673220348
    wrapping_token_ttl:              30m
    wrapping_token_creation_time:    2018-05-09 06:10:13.437421436 +0000 UTC
    wrapping_token_creation_path:    sys/replication/performance/primary/secondary-token
    
  3. Create a paths filter to deny EU_GDPR_data (kv-v2) and office_FR (namespace) from being replicated.

    $ vault write sys/replication/performance/primary/paths-filter/secondary  \
            mode="deny" paths="EU_GDPR_data/, office_FR"
    
  4. Enable performance replication on the secondary cluster by passing the wrapping_token obtained from the primary cluster.

    $ vault write sys/replication/performance/secondary/enable token="..."
    

Step 3: Secondary cluster re-authentication

$ vault operator unseal
Unseal Key (will be hidden): <primary_cluster_unseal_key>

The initial root token on the secondary no longer works; therefore, perform one of the following:

  • Option 1: Use the auth methods configured on the primary cluster to log into the secondary
  • Option 2: Generate a new root token using the primary's unseal key

Option 1

Enable and configure the userpass auth method on the primary cluster and create a new username and password.

$ vault auth enable userpass

Create a user with admin policy.

$ vault write auth/userpass/users/admin password="long-passw0rd" policy="admin"

Log into the secondary cluster using the enabled auth method.

$ vault login -method=userpass username=admin password="long-passw0rd"

Option 2

On the secondary cluster, generate a new root token using the primary cluster's unseal key.

First, generate and OTP.

$ vault operator generate-root -generate-otp
kqJzFJ5NqOWgjseqKnUZ2ZePCp

Initialize the root token generation using the OTP.

$ vault operator generate-root -init -otp=kqJzFJ5NqOWgjseqKnUZ2ZePCp
Nonce         35f246b1-0005-2702-05c2-37bdf7757a37
Started       true
Progress      0/1
Complete      false
OTP Length    26

Now, generate root. When prompted, enter the primary unseal key.

$ vault operator generate-root
Operation nonce: 35f246b1-0005-2702-05c2-37bdf7757a37
Unseal Key (will be hidden):

Nonce            35f246b1-0005-2702-05c2-37bdf7757a37
Started          true
Progress         1/1
Complete         true
Encoded Token    GF9+FTR5RToiF2QlAztQCA0GMhdmDFAFBEA

Finally, decode the encoded token using OTP.

$ vault operator generate-root \
        -decode=GF9+FTR5RToiF2QlAztQCA0GMhdmDFAFBEA \
        -otp=kqJzFJ5NqOWgjseqKnUZ2ZePCp

Log into the secondary cluster using the generated root token.

$ vault login <root_token>

Step 4: Verify the paths filter

Once the replication completes, verify that the secrets stored in the EU_GDPR_data never get replicated to the US cluster.

  1. On the EU (primary) cluster, write some secrets for testing.

    $ vault kv put EU_GDPR_data/secret pswd="password"
    Key              Value
    ---              -----
    created_time     2018-05-10T18:00:38.912587665Z
    deletion_time    n/a
    destroyed        false
    version          1
    

    Write some secret at US_NON_GDPR_data/secret.

    $ vault kv put US_NON_GDPR_data/secret apikey="my-api-key"
    Key              Value
    ---              -----
    created_time     2018-05-10T18:04:37.554665851Z
    deletion_time    n/a
    destroyed        false
    version          1
    
  2. List the existing namespaces.

    $ vault namespace list
    
    Keys
    ----
    office_FR/
    office_US/
    
  3. Now, from the US (secondary) cluster, read the secrets.

    Read the secrets at EU_GDPR_data/secret.

    $ vault kv get EU_GDPR_data/secret
    No value found at EU_GDPR_data/secret
    

    Read the secrets at US_NON_GDPR_data/secret.

    $ vault kv get US_NON_GDPR_data/secret
    ====== Metadata ======
    Key              Value
    ---              -----
    created_time     2018-05-10T18:09:07.717250408Z
    deletion_time    n/a
    destroyed        false
    version          1
    
    ===== Data =====
    Key       Value
    ---       -----
    apikey    my-api-key
    
  4. List the existing namespaces.

    $ vault namespace list
    
    Keys
    ----
    office_US/
    

    Notice that office_US is the only namespace listed.

Step 5: Enable a local secrets engine

When replication is enabled, you can mark the secrets engine local only. Local secrets engines are not replicated or removed by replication.

Login to the secondary cluster and enable key/value secrets engine at US_ONLY_data to store secrets only valid for the US region.

Pass the -local flag.

$ vault secrets enable -local -path=US_ONLY_data kv-v2

Help and Reference