From: Sergio de Carvalho Date: Thu, 15 Aug 2019 14:09:08 +0000 (+0100) Subject: rgw: add SSE-KMS with Vault using token auth X-Git-Tag: v15.1.0~1322^2~3 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=1e5b58ad50eae9b6df7f28baf511f4902cfbae4c;p=ceph-ci.git rgw: add SSE-KMS with Vault using token auth Extend server-side encryption functionality in Rados Gateway to support HashiCorp Vault as a Key Management System in addition to existing support for OpenStack Barbican. This is the first part of this change, supporting Vault's token-based authentication only. Agent-based authentication as well as other features such as Vault namespaces will be added in subsequent commits. Note that Barbican remains the default backend for SSE-KMS (rgw crypt s3 kms backend) to avoid breaking existing deployments. Feature: https://tracker.ceph.com/issues/41062 Notes: https://pad.ceph.com/p/rgw_sse-kms Implemented so far: * Move existing SSE-KMS functions from rgw_crypt.cc to rgw_kms.cc * Vault authentication with a token read from file * Add new ceph.conf settings for Vault * Document new ceph.conf settings * Update main encryption documentation page * Add documentation page for SSE-KMS using Vault Signed-off-by: Andrea Baglioni Signed-off-by: Sergio de Carvalho --- diff --git a/doc/radosgw/barbican.rst b/doc/radosgw/barbican.rst index 3a7fe6e5c18..62055670763 100644 --- a/doc/radosgw/barbican.rst +++ b/doc/radosgw/barbican.rst @@ -94,9 +94,10 @@ Response:: Configure the Ceph Object Gateway ================================= -Edit the Ceph configuration file to add information about the Barbican server -and Keystone user:: +Edit the Ceph configuration file to enable Barbican as a KMS and add information +about the Barbican server and Keystone user:: + rgw crypt s3 kms backend = barbican rgw barbican url = http://barbican.example.com:9311 rgw keystone barbican user = rgwcrypt-user rgw keystone barbican password = rgwcrypt-password diff --git a/doc/radosgw/config-ref.rst b/doc/radosgw/config-ref.rst index 3ed09def9f3..c21ddba4d31 100644 --- a/doc/radosgw/config-ref.rst +++ b/doc/radosgw/config-ref.rst @@ -893,6 +893,19 @@ Keystone Settings :Type: Boolean :Default: ``true`` + +Server-side encryption Settings +=============================== + +``rgw crypt s3 kms backend`` + +:Description: Where the SSE-KMS encryption keys are stored. Supported KMS + systems are OpenStack Barbican (``barbican``, the default) and + HashiCorp Vault (``vault``). +:Type: String +:Default: None + + Barbican Settings ================= @@ -937,6 +950,29 @@ Barbican Settings :Default: None +HashiCorp Vault Settings +======================== + +``rgw crypt vault auth``` + +:Description: Type of authentication method to be used. The only method + currently supported is ``token``. +:Type: String +:Default: ``token`` + +``rgw crypt vault token file`` + +:Description: If authentication method is ``token``, provide a path to the token + file, which should be readable only by Rados Gateway. +:Type: String +:Default: None + +``rgw crypt vault addr`` + +:Description: Provide a URL to the Vault server secret path. +:Type: String +:Default: None + QoS settings ------------ diff --git a/doc/radosgw/encryption.rst b/doc/radosgw/encryption.rst index ea89e502ab0..151f3b5efe5 100644 --- a/doc/radosgw/encryption.rst +++ b/doc/radosgw/encryption.rst @@ -36,9 +36,9 @@ or decrypt data. This is implemented in S3 according to the `Amazon SSE-KMS`_ specification. In principle, any key management service could be used here, but currently -only integration with `Barbican`_ is implemented. +only integration with `Barbican`_ and `Vault`_ are implemented. -See `OpenStack Barbican Integration`_. +See `OpenStack Barbican Integration`_ and `HashiCorp Vault Integration`_. Automatic Encryption (for testing only) ======================================= @@ -58,4 +58,6 @@ The configuration expects a base64-encoded 256 bit key. For example:: .. _Amazon SSE-C: https://docs.aws.amazon.com/AmazonS3/latest/dev/ServerSideEncryptionCustomerKeys.html .. _Amazon SSE-KMS: http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingKMSEncryption.html .. _Barbican: https://wiki.openstack.org/wiki/Barbican +.. _Vault: https://www.vaultproject.io/docs/ .. _OpenStack Barbican Integration: ../barbican +.. _HashiCorp Vault Integration: ../vault diff --git a/doc/radosgw/index.rst b/doc/radosgw/index.rst index 898421a1ebc..22b882f3ed0 100644 --- a/doc/radosgw/index.rst +++ b/doc/radosgw/index.rst @@ -52,6 +52,7 @@ you may write data with one API and retrieve it with the other. Export over NFS OpenStack Keystone Integration OpenStack Barbican Integration + HashiCorp Vault Integration Open Policy Agent Integration Multi-tenancy Compression diff --git a/doc/radosgw/vault.rst b/doc/radosgw/vault.rst new file mode 100644 index 00000000000..0cbae340775 --- /dev/null +++ b/doc/radosgw/vault.rst @@ -0,0 +1,79 @@ +=========================== +HashiCorp Vault Integration +=========================== + +HashiCorp `Vault`_ can be used as a secure key management service for +`Server-Side Encryption`_ (SSE-KMS). + +#. `Vault authentication`_ +#. `Create a key in Vault`_ +#. `Configure the Ceph Object Gateway`_ +#. `Upload object`_ + +Vault authentication +==================== + +Vault provides several authentication mechanisms. Currently, the Object Gateway +supports the `token authentication method`_ only. + +When authenticating with Vault using the token method, save the token in a +plain-text file. The path to this file must be provided in the Gateway +configuration file (see below). For security reasons, ensure the file is +readable by the Object Gateway only. + +Create a key in Vault +===================== + +Generate and save a 256-bit key in Vault. Vault provides several Secret +Engines, which store, generate, and encrypt data. For instance, create a key +in the `KV Secrets engine`_ using Vault's command line client:: + + export VAULT_ADDR='http://vaultserver:8200' + vault kv put secret/myproject/mybucketkey key=$(dd bs=32 count=1 if=/dev/urandom of=/dev/stdout 2>/dev/null | base64) + +Output:: + + ====== Metadata ====== + Key Value + --- ----- + created_time 2019-08-29T17:01:09.095824999Z + deletion_time n/a + destroyed false + version 1 + + === Data === + Key Value + --- ----- + key Ak5dRyLQjwX/wb7vo6Fq1qjsfk1dh2CiSicX+gLAhwk= + +The URL to the secret in Vault must be provided in the Gateway configuration +file (see below). + +Configure the Ceph Object Gateway +================================= + +Edit the Ceph configuration file to enable Vault as a KMS for server-side +encryption:: + + rgw crypt s3 kms backend = vault + rgw crypt vault auth = token + rgw crypt vault addr = http://vaultserver:8200 + rgw crypt vault token file = /path/to/token.file + +Upload object +============= + +When uploading an object, provide the SSE key ID in the request. As an example, +using the AWS command-line client:: + + aws --endpoint=http://radosgw:8000 s3 cp plaintext.txt s3://mybucket/encrypted.txt --sse=aws:kms --sse-kms-key-id /v1/secret/data/myproject/mybucketkey + +The object gateway will fetch the key from Vault (using the token for +authentication), encrypt the object and store it in the bucket. Any request to +downlod the object will require the correct key ID for the Gateway to +successfully the decrypt it. + +.. _Server-Side Encryption: ../encryption +.. _Vault: https://www.vaultproject.io/docs/ +.. _token authentication method: https://www.vaultproject.io/docs/auth/token.html +.. _KV Secrets engine: https://www.vaultproject.io/docs/secrets/kv/ diff --git a/src/common/legacy_config_opts.h b/src/common/legacy_config_opts.h index b095624e410..f385e28eba2 100644 --- a/src/common/legacy_config_opts.h +++ b/src/common/legacy_config_opts.h @@ -1525,6 +1525,12 @@ OPTION(rgw_swift_versioning_enabled, OPT_BOOL) // whether swift object versionin OPTION(rgw_trust_forwarded_https, OPT_BOOL) // trust Forwarded and X-Forwarded-Proto headers for ssl termination OPTION(rgw_crypt_require_ssl, OPT_BOOL) // requests including encryption key headers must be sent over ssl OPTION(rgw_crypt_default_encryption_key, OPT_STR) // base64 encoded key for encryption of rgw objects + +OPTION(rgw_crypt_s3_kms_backend, OPT_STR) // Where SSE-KMS encryption keys are stored +OPTION(rgw_crypt_vault_auth, OPT_STR) // Type of authentication method to be used with Vault +OPTION(rgw_crypt_vault_token_file, OPT_STR) // Path to the token file for Vault authentication +OPTION(rgw_crypt_vault_addr, OPT_STR) // URL to Vault server endpoint + OPTION(rgw_crypt_s3_kms_encryption_keys, OPT_STR) // extra keys that may be used for aws:kms // defined as map "key1=YmluCmJvb3N0CmJvb3N0LQ== key2=b3V0CnNyYwpUZXN0aW5nCg==" OPTION(rgw_crypt_suppress_logs, OPT_BOOL) // suppress logs that might print customer key diff --git a/src/common/options.cc b/src/common/options.cc index 0b329761177..55b6f5a4371 100644 --- a/src/common/options.cc +++ b/src/common/options.cc @@ -6938,10 +6938,48 @@ std::vector