diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 507cdbd..9744ac8 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -8,6 +8,15 @@ updates: labels: - "dependencies" - "javascript" + ignore: + # @mermaid-js/layout-elk is a dependency of @docusaurus/theme-mermaid, which + # requires ^0.1.9. A previous Dependabot PR bumped it which breaks `npm install` + # (ERESOLVE) and the Docusaurus build. Block major and minor bumps until + # theme-mermaid declares support for them. Remove this entry when that happens. + - dependency-name: "@mermaid-js/layout-elk" + update-types: + - "version-update:semver-major" + - "version-update:semver-minor" groups: site-minor-and-patch: patterns: diff --git a/.github/workflows/deploy-pages.yml b/.github/workflows/deploy-pages.yml index 92c8e8c..5f77805 100644 --- a/.github/workflows/deploy-pages.yml +++ b/.github/workflows/deploy-pages.yml @@ -45,7 +45,7 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Set up Python - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 + uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0 with: python-version: '3.11' cache: pip @@ -57,7 +57,7 @@ jobs: run: python generate.py - name: Set up Node.js - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 + uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: '20' cache: npm diff --git a/.github/workflows/verify-docs.yml b/.github/workflows/verify-docs.yml index d23ebe5..50bc277 100644 --- a/.github/workflows/verify-docs.yml +++ b/.github/workflows/verify-docs.yml @@ -43,7 +43,7 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Set up Python - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 + uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0 with: python-version: '3.11' cache: pip @@ -75,7 +75,7 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Set up Node.js - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 + uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: '20' cache: npm diff --git a/README.md b/README.md index 3a80450..1c9226b 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Each wrapper's documentation is grouped into the same sections: | Section | What's in it | |--------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| **Overview** | What the wrapper is and how to install it. | +| **Overview** | What the wrapper is, how to install it, and one complete program that connects and runs a query. The page to read first. | | **Set up by Scenario** | An interactive builder — answer a few questions about your application and get a working configuration. | | **Using Plugins** | One page per feature plugin (Failover, IAM Authentication, AWS Secrets Manager, Blue/Green, KMS Encryption, and so on), describing what the plugin does and every parameter it accepts. | | **Shared Configuration** | Cross-cutting settings — TLS/SSL, AWS credentials resolution, host selection strategies — that more than one plugin relies on. | diff --git a/content/failover.yaml b/content/failover.yaml index 4800894..cb4637d 100644 --- a/content/failover.yaml +++ b/content/failover.yaml @@ -70,11 +70,22 @@ wrappers: # optional heading and an ordered list of blocks; a block is either prose # (`text`) or a fenced code sample (`code` + `lang`). # - # Active Record comes first because the adapters are the wrapper's primary - # integration: changing the adapter name is the whole change. The gem name - # matches its entry point file, so Bundler's default require loads it. + # Active Record leads because most Ruby users arrive through it: the adapters + # are the wrapper's primary integration and changing the adapter name is the + # whole change. The driver-direct path follows under an unnumbered "Or ..." + # heading, which is where an alternative goes in this style. + # + # The driver-direct block is a whole working program, not a fragment. A + # reader who copies it has a process that connects, queries and exits, with + # no gaps to fill from elsewhere on the site: the exact gem name, the exact + # require path, the constructor, the query call, and the teardown are all + # present. Fragments cost a reader (and an agent reading on their behalf) an + # edit-and-rerun loop per gap, which is the most expensive thing a + # getting-started page can do. The Active Record path cannot be shown that + # way because it needs a Rails application around it, so the two paths are + # ordered by who the reader is, not by what fits in one file. gettingStarted: - note: "Requires Ruby 3.3 or later. Tested with Active Record 7.2, 8.0, and 8.1, `pg` 1.6.3 or later, and `mysql2` 0.5.7 or later." + note: "Requires Ruby 3.3 or later. The gem is `aws_advanced_ruby_driver_wrapper` on RubyGems. Tested with Active Record 7.2, 8.0, and 8.1, `pg` 1.6.3 or later, and `mysql2` 0.5.7 or later." steps: - title: "1. Add the gem" blocks: @@ -87,17 +98,71 @@ wrappers: code: | bundle install - text: >- - Bundler requires the gem for you (in a plain Ruby script, add - `require 'aws_advanced_ruby_driver_wrapper'`). That single require - registers the Active Record adapters and makes the connection classes, - error classes, and other public API available for direct use. + Without Bundler, `gem install aws_advanced_ruby_driver_wrapper pg` + does the same thing. + # The house pattern for "this needs another gem" is a warning with + # its own snippet, as on the IAM and Secrets Manager pages, rather + # than commented lines inside the main Gemfile. The wrapper itself + # declares every gem it requires, so this warning is only for a gem + # `mysql2` requires on Windows without declaring it. + - text: | + :::warning + If you are using `mysql2` on Windows with Ruby 4.0 or later, you may also need to add `fiddle` to your Gemfile: + + ```ruby + gem 'fiddle' + ``` + + On Windows, `mysql2` uses `fiddle` to load `libmysql.dll` when you set + `RUBY_MYSQL2_LIBMYSQL_DLL`, when the gem ships its own `libmysql.dll`, or + when Ruby was not installed with RubyInstaller, but it does not declare + `fiddle` as a dependency. Ruby 4.0 removed `fiddle` from the default gems, + so in those cases a bundle without it raises `LoadError` when `mysql2` is + required. + ::: - title: "2. Point Active Record at your cluster" blocks: - text: >- The wrapper registers two adapters, `aws_postgresql` and `aws_mysql2`, - which are drop-in replacements for `postgresql` and `mysql2`. Change the - adapter name and point the host at your cluster endpoint: + which are drop-in replacements for `postgresql` and `mysql2`. + # Without this, Active Record raises AdapterNotFound and names only + # its own built-in adapters, which does not hint that a require is + # missing. Bundler covers the Rails case; a plain script does not. + - text: >- + Bundler requires the gem for you. In a plain Ruby script, add + `require 'aws_advanced_ruby_driver_wrapper'` first: that single require + is what registers both adapters, and without it Active Record reports + `aws_postgresql` as a nonexistent adapter. + - text: >- + If you are starting without a Rails application, add + `gem 'activerecord'` to the Gemfile from step 1 (outside Rails, nothing + else installs it), run `bundle install`, and this is a complete program. + Save it as `main.rb` and run it: + - lang: ruby + code: | + # main.rb + require 'active_record' + require 'aws_advanced_ruby_driver_wrapper' + + ActiveRecord::Base.establish_connection( + adapter: 'aws_postgresql', + host: 'my-cluster.cluster-xyz.us-east-1.rds.amazonaws.com', + database: 'mydb', + username: '', + password: '', + wrapper_plugins: 'failover' + ) + + puts ActiveRecord::Base.connection.select_value('SELECT version()') + - lang: bash + code: | + bundle exec ruby main.rb + - text: >- + In a Rails application the same keys go in `config/database.yml` + instead, and Bundler has already done the require. The adapter name + is the only key that changes; leave the host as whichever endpoint + you already connect to: - lang: yaml code: | # config/database.yml @@ -108,13 +173,10 @@ wrappers: username: password: - text: >- - That is the whole change — no application code moves. When - `wrapper_plugins` is not set, the wrapper loads `failover` and - `initial_connection`, so connections made through this adapter already - recover when the cluster promotes a new writer. Enable more by adding - wrapper properties alongside the Active Record keys. Setting - `wrapper_plugins` replaces the default list rather than adding to it, so - list the defaults you want to keep: + That is the whole change — no application code moves, and + connections made through this adapter already recover when the + cluster promotes a new writer. Wrapper properties go alongside the + Active Record keys, under the same connection: - lang: yaml code: | production: @@ -123,6 +185,10 @@ wrappers: wrapper_plugins: failover,initial_connection,iam iam_region: us-east-1 failover_timeout_sec: 300.0 # seconds + - text: >- + `wrapper_plugins` is optional — leaving it out loads + `failover,initial_connection`. Setting it replaces the default list + rather than adding to it, so list the defaults you want to keep. - text: >- Active Record keeps its own connection pool and its reading and writing roles; the wrapper's plugins run underneath both. @@ -134,16 +200,28 @@ wrappers: (`aws_postgresql`/`aws_mysql2`), a custom type registered for one is shared with the other, because both resolve under the same underlying adapter key. ::: + - text: | + :::note Keeping the password out of your source + Read it from the environment with `ENV.fetch('PGPASSWORD')` in Ruby, or + `<%= ENV.fetch('PGPASSWORD') %>` in `config/database.yml`, or have + AWS manage it: add `secrets_manager` to `wrapper_plugins` and drop the + `password:` key, as described on + [AWS Secrets Manager Plugin](using-plugins/aws-secrets-manager). For a + database user with no password at all, consider using `iam` instead; see + [IAM Authentication Plugin](using-plugins/iam-authentication). + ::: - title: "Or connect with the driver directly" blocks: - text: >- - If you use the `pg` or `mysql2` gem without Active Record, the wrapper - provides connection classes that stand in for `PG::Connection` and - `Mysql2::Client`: + Without Active Record, the wrapper provides connection classes that + stand in for `PG::Connection` and `Mysql2::Client`. This is a complete + program; save it as `main.rb` and run it: - lang: ruby code: | - # PostgreSQL (pg) + # main.rb + require 'aws_advanced_ruby_driver_wrapper/postgresql' + conn = AwsAdvancedRubyDriverWrapper::WrapperPgConnection.new( host: 'my-cluster.cluster-xyz.us-east-1.rds.amazonaws.com', dbname: 'mydb', @@ -152,27 +230,37 @@ wrappers: wrapper_plugins: 'failover', failover_timeout_sec: 300.0 ) - - lang: ruby + + begin + result = conn.exec('SELECT version()') + puts result.first['version'] + ensure + conn.close + end + - lang: bash code: | - # MySQL (mysql2) - conn = AwsAdvancedRubyDriverWrapper::WrapperMysql2Client.new( - host: 'my-cluster.cluster-xyz.us-east-1.rds.amazonaws.com', - database: 'mydb', - username: '', - password: '', - wrapper_plugins: 'failover', - failover_timeout_sec: 300.0 - ) + bundle exec ruby main.rb - text: >- - The calls your code already makes on the driver connection keep working, - and the plugins act on each one. - + For PostgreSQL, `require 'aws_advanced_ruby_driver_wrapper/postgresql'` + and use `AwsAdvancedRubyDriverWrapper::WrapperPgConnection`, which + stands in for `PG::Connection` and takes `dbname:` and `user:`. + For MySQL, `require 'aws_advanced_ruby_driver_wrapper/mysql'` and use + `AwsAdvancedRubyDriverWrapper::WrapperMysql2Client`, which stands in + for `Mysql2::Client` and takes `database:` and `username:`. Either + way the calls your code already makes keep working, and the plugins + act on each one. - title: "Next" blocks: + - text: >- + The wrapper supports other plugins and wrapper properties. For + further information see the plugin pages, starting with + [Enhanced Failover Plugin](enhanced-failover). Every wrapper property + the examples did not use is listed with its type, default and unit on + the plugin page that reads it. To check a combination before shipping, + see [Plugin Compatibility](compatibility). - text: >- Not sure which plugins you need? [Set up by Scenario](setup) builds a - configuration from a few questions about your application. To check a - combination before shipping, see [Plugin Compatibility](compatibility). + configuration from a few questions about your application. parameters: - concept: failoverMode diff --git a/content/plugins.yaml b/content/plugins.yaml index aa2478e..4525b29 100644 --- a/content/plugins.yaml +++ b/content/plugins.yaml @@ -131,7 +131,7 @@ plugins: ruby: { name: iam_region, required: "No", defaultNote: "parsed from host", example: "us-east-1" } - concept: iamExpiration type: integer - description: "Fallback cache lifetime, in seconds, for a generated IAM token. A cached token normally lives for the lifetime signed into the token itself (15 minutes) minus a 60-second safety margin; this value is used only when that lifetime cannot be read from the token. It is capped at a maximum of `870.0` — the default — so a cached token is never used after it expires. A value greater than `870.0` or less than or equal to `0` is rejected." + description: "Number of seconds a generated IAM token is kept in the cache before a new one is generated. The token itself is valid for 15 minutes, and a cached token is never used within 60 seconds of that expiry, so values of `840.0` and above will all have their tokens refetched at the `840` mark. The token cache is shared by every connection in the process that uses the `iam`, `federated_auth`, or `okta` plugin, and its lifetime is set by the first such connection; later connections that set a different value use the first connection's value. A value greater than `870.0` or less than or equal to `0` is rejected." spellings: ruby: { name: iam_expiration_sec, type: float, required: "No", default: "870.0", unit: s, example: "600.0 (maximum 870.0)" } - concept: iamTokenProperty @@ -271,11 +271,19 @@ plugins: refreshes to a new access key gets a new token. When the credentials provider resolves to no credentials, the token is not cached. - A cached token is reused until 60 seconds before the expiry signed into it - (`iam_expiration_sec` applies only when that expiry cannot be read). If a + A cached token is reused until `iam_expiration_sec` elapses or until 60 + seconds before the token's own 15-minute expiry, whichever comes first. If a login error occurs with a cached token, the plugin automatically fetches a fresh token and retries the connection once. + :::note + The token cache is shared by every connection in the process that uses the + `iam`, `federated_auth`, or `okta` plugin, and the first such connection sets + its `iam_expiration_sec`. Connections opened later with a different value still + use the first connection's value, so set `iam_expiration_sec` to the same value + on every connection. + ::: + ## Related - [AWS Credentials](../aws-credentials) — the plugin calls RDS to generate each @@ -375,7 +383,7 @@ plugins: ruby: { name: iam_port, required: "No", defaultNote: "dialect default", example: "5432" } - concept: iamExpiration type: float - description: "Fallback cache lifetime, in seconds, for a generated IAM token. A cached token normally lives for the lifetime signed into the token itself (15 minutes) minus a 60-second safety margin; this value is used only when that lifetime cannot be read from the token. It is capped at a maximum of `870.0` — the default — so a cached token is never used after it expires. A value greater than `870.0` or less than or equal to `0` is rejected. The token cache is shared with the `iam` and `okta` plugins." + description: "Number of seconds a generated IAM token is kept in the cache before a new one is generated. The token itself is valid for 15 minutes, and a cached token is never used within 60 seconds of that expiry, so values of `840.0` and above will all have their tokens refetched at the `840` mark. The token cache is shared by every connection in the process that uses the `iam`, `federated_auth`, or `okta` plugin, and its lifetime is set by the first such connection; later connections that set a different value use the first connection's value. A value greater than `870.0` or less than or equal to `0` is rejected." spellings: ruby: { name: iam_expiration_sec, required: "No", default: "870.0", unit: s, example: "600.0 (maximum 870.0)" } - concept: sslInsecure @@ -561,7 +569,7 @@ plugins: ruby: { name: iam_port, required: "No", defaultNote: "dialect default", example: "5432" } - concept: iamExpiration type: float - description: "Fallback cache lifetime, in seconds, for a generated IAM token. A cached token normally lives for the lifetime signed into the token itself (15 minutes) minus a 60-second safety margin; this value is used only when that lifetime cannot be read from the token. It is capped at a maximum of `870.0` — the default — so a cached token is never used after it expires. A value greater than `870.0` or less than or equal to `0` is rejected. The token cache is shared with the `iam` and `federated_auth` plugins." + description: "Number of seconds a generated IAM token is kept in the cache before a new one is generated. The token itself is valid for 15 minutes, and a cached token is never used within 60 seconds of that expiry, so values of `840.0` and above will all have their tokens refetched at the `840` mark. The token cache is shared by every connection in the process that uses the `iam`, `federated_auth`, or `okta` plugin, and its lifetime is set by the first such connection; later connections that set a different value use the first connection's value. A value greater than `870.0` or less than or equal to `0` is rejected." spellings: ruby: { name: iam_expiration_sec, required: "No", default: "870.0", unit: s, example: "600.0 (maximum 870.0)" } - concept: sslInsecure @@ -930,9 +938,10 @@ plugins: ruby: { name: encryption_return_unverified_data, required: "No", default: "false", example: "false" } adminUtility: ruby: "Plugins::Encryption::KeyManagementUtility" - # The trigger SQL below is a copy of the files in the Ruby wrapper repo, which its integration - # tests install: spec/integration/host/src/test/resources/sql/kms_encryption_trigger_pg.sql and - # kms_encryption_trigger_mysql.sql. Keep the two identical; change the files first. + # The trigger SQL lives in the Ruby wrapper repo, which installs it in its integration tests: + # lib/aws_advanced_ruby_driver_wrapper/plugins/kms_encryption/sql/trigger_pg.sql and + # trigger_mysql.sql. This page links to those files rather than copying them. When a file + # changes, bump the version in its database comment and add a row to "Updating the trigger SQL". serverSideEnforcement: | ## Enforce encryption in the database @@ -942,67 +951,24 @@ plugins: verify that a value carries a valid integrity tag without holding the data key. + The trigger SQL is maintained in the wrapper repository: + + - PostgreSQL: [`trigger_pg.sql`](https://github.com/aws/aws-advanced-ruby-driver-wrapper/blob/main/lib/aws_advanced_ruby_driver_wrapper/plugins/kms_encryption/sql/trigger_pg.sql) + - MySQL: [`trigger_mysql.sql`](https://github.com/aws/aws-advanced-ruby-driver-wrapper/blob/main/lib/aws_advanced_ruby_driver_wrapper/plugins/kms_encryption/sql/trigger_mysql.sql) + + Run the file for your engine once per database, then add a trigger for every + encrypted column as shown below. The SQL is updated from time to time; see + [Updating the trigger SQL](#updating-the-trigger-sql). + ### PostgreSQL - ```sql - -- pgcrypto provides hmac(). If it is already installed in a schema other than public, - -- replace public in public.hmac below with that schema. - CREATE EXTENSION IF NOT EXISTS pgcrypto WITH SCHEMA public; - - -- Replace 'encrypt' below if encryption_metadata_schema is set to something else. - -- A trigger runs with the search_path of the session that fires it. Pinning it to pg_catalog - -- stops a session from putting its own functions or operators, such as hmac() or <>, ahead of - -- the built-in ones to get a plaintext value past this check. - CREATE OR REPLACE FUNCTION enforce_encrypted_column() RETURNS trigger - SET search_path = pg_catalog, pg_temp - AS $$ - DECLARE - col_name text := TG_ARGV[0]; - col_value bytea; - hmac_key bytea; - cache_key text := 'hmac_key.' || TG_TABLE_NAME || '.' || col_name; - unchanged boolean; - BEGIN - -- An UPDATE that leaves the encrypted value as it was is not re-checked; see - -- "Updates after a key rotation". - IF TG_OP = 'UPDATE' THEN - EXECUTE format('SELECT ($1).%I IS NOT DISTINCT FROM ($2).%I', col_name, col_name) - INTO unchanged USING NEW, OLD; - IF unchanged THEN - RETURN NEW; - END IF; - END IF; - - EXECUTE format('SELECT ($1).%I', col_name) INTO col_value USING NEW; - IF col_value IS NULL THEN - RETURN NEW; - END IF; - - -- A setting cached by an earlier transaction reads back as '' rather than being - -- undefined, so an empty value is treated as not cached. - hmac_key := decode(NULLIF(current_setting(cache_key, true), ''), 'hex'); - IF hmac_key IS NULL THEN - SELECT ks.hmac_key INTO hmac_key - FROM encrypt.encryption_metadata em - JOIN encrypt.key_storage ks ON em.key_id = ks.id - WHERE em.table_name = TG_TABLE_NAME AND em.column_name = col_name; - - IF hmac_key IS NULL THEN - RAISE EXCEPTION 'No HMAC key is configured for %.%', TG_TABLE_NAME, col_name; - END IF; - - PERFORM set_config(cache_key, encode(hmac_key, 'hex'), true); - END IF; - - IF length(col_value) < 65 - OR substring(col_value from 1 for 32) <> public.hmac(substring(col_value from 33), hmac_key, 'sha256'::text) THEN - RAISE EXCEPTION 'Column %.% does not carry a valid HMAC tag (plaintext or tampered value)', TG_TABLE_NAME, col_name; - END IF; - - RETURN NEW; - END; - $$ LANGUAGE plpgsql; - ``` + Run [`trigger_pg.sql`](https://github.com/aws/aws-advanced-ruby-driver-wrapper/blob/main/lib/aws_advanced_ruby_driver_wrapper/plugins/kms_encryption/sql/trigger_pg.sql). It installs the `pgcrypto` + extension if it is not already installed, and creates the + `enforce_encrypted_column()` trigger function. The function reads the + metadata tables as `encrypt.encryption_metadata` and `encrypt.key_storage`: + replace `encrypt` if `encryption_metadata_schema` is set to something else. If + `pgcrypto` is already installed in a schema other than `public`, replace + `public` in `public.hmac` with that schema. Then create a trigger for every column that you want to encrypt: @@ -1018,136 +984,27 @@ plugins: FOR EACH ROW EXECUTE FUNCTION enforce_encrypted_column('dob'); ``` - The HMAC key is cached for the length of the transaction rather than the - session, so that a key rotation takes effect immediately. Widen it to the - session with `set_config(..., false)` if the per-transaction metadata lookup - costs more than the rotation delay is worth. - ### MySQL - MySQL has no built-in HMAC function, so the equivalent builds HMAC-SHA256 out - of `SHA2()`. Create the two functions and the two validation procedures once per - schema, then add a `BEFORE INSERT` and a `BEFORE UPDATE` trigger per encrypted - column. Replace `SCHEMA_NAME` with the value of `encryption_metadata_schema` - (`encrypt` by default). Requires MySQL 5.7+ / MariaDB 10.2+ for `SHA2()`. On - Aurora/RDS MySQL, creating the functions may require the cluster parameter - `log_bin_trust_function_creators` to be set to `1`. + MySQL has no built-in HMAC function, so + [`trigger_mysql.sql`](https://github.com/aws/aws-advanced-ruby-driver-wrapper/blob/main/lib/aws_advanced_ruby_driver_wrapper/plugins/kms_encryption/sql/trigger_mysql.sql) builds HMAC-SHA256 out of + `SHA2()`. Run it once per schema to create the two functions and the two + validation procedures, then add a `BEFORE INSERT` and a `BEFORE UPDATE` + trigger per encrypted column. Replace `SCHEMA_NAME` in the file with the value + of `encryption_metadata_schema` (`encrypt` by default). Requires MySQL 5.7+ / + MariaDB 10.2+ for `SHA2()`. On Aurora/RDS MySQL, creating the functions may + require the cluster parameter `log_bin_trust_function_creators` to be set to + `1`. :::note - The SQL below uses `DELIMITER`, which is a command of the `mysql` command-line - client rather than SQL. To run it through a driver, a Rails migration, or any - other tool that sends one statement at a time, leave out the `DELIMITER` - lines and send each `DROP`, `CREATE FUNCTION`, `CREATE PROCEDURE` and - `CREATE TRIGGER` statement on its own, without its trailing `$$`. + The file and the trigger SQL below use `DELIMITER`, which is a command of the + `mysql` command-line client rather than SQL. To run them through a driver, a + Rails migration, or any other tool that sends one statement at a time, leave + out the `DELIMITER` lines and send each `DROP`, `CREATE FUNCTION`, + `CREATE PROCEDURE` and `CREATE TRIGGER` statement on its own, without its + trailing `$$`. ::: - ```sql - DELIMITER $$ - - -- HMAC-SHA256 built from SHA2(), which MySQL has no native HMAC for. - DROP FUNCTION IF EXISTS hmac_sha256$$ - CREATE FUNCTION hmac_sha256( - message VARBINARY(65535), - key_data VARBINARY(64) - ) - RETURNS VARBINARY(32) - DETERMINISTIC - NO SQL - BEGIN - DECLARE block_size INT DEFAULT 64; -- SHA-256 block size - DECLARE key_padded VARBINARY(64); - DECLARE ipad VARBINARY(64); - DECLARE opad VARBINARY(64); - DECLARE i INT DEFAULT 1; - DECLARE key_byte INT; - - -- Reduce an over-long key to its hash, then zero-pad the key to the block size. - IF LENGTH(key_data) > block_size THEN - SET key_padded = CONCAT(UNHEX(SHA2(key_data, 256)), REPEAT(X'00', block_size - 32)); - ELSE - SET key_padded = CONCAT(key_data, REPEAT(X'00', block_size - LENGTH(key_data))); - END IF; - - -- ipad = key XOR 0x36 per byte, opad = key XOR 0x5C per byte, one raw byte at a time. - SET ipad = X''; - SET opad = X''; - WHILE i <= block_size DO - SET key_byte = ASCII(SUBSTRING(key_padded, i, 1)); - SET ipad = CONCAT(ipad, UNHEX(LPAD(HEX(key_byte ^ 0x36), 2, '0'))); - SET opad = CONCAT(opad, UNHEX(LPAD(HEX(key_byte ^ 0x5C), 2, '0'))); - SET i = i + 1; - END WHILE; - - RETURN UNHEX(SHA2(CONCAT(opad, UNHEX(SHA2(CONCAT(ipad, message), 256))), 256)); - END$$ - - -- Verifies that a stored value carries a valid HMAC for the given HMAC key. - DROP FUNCTION IF EXISTS verify_encrypted_data_hmac$$ - CREATE FUNCTION verify_encrypted_data_hmac( - data VARBINARY(65535), - hmac_key VARBINARY(32) - ) - RETURNS BOOLEAN - DETERMINISTIC - NO SQL - BEGIN - -- Minimum payload: 32 (HMAC) + 4 (key id) + 1 (type) + 12 (IV) + 0 (ciphertext) + 16 (GCM tag) = 65. - IF data IS NULL OR LENGTH(data) < 65 THEN - RETURN FALSE; - END IF; - - RETURN SUBSTRING(data, 1, 32) = hmac_sha256(SUBSTRING(data, 33), hmac_key); - END$$ - - -- Called from a BEFORE INSERT trigger (and by the BEFORE UPDATE procedure) to reject a value that is - -- not a valid kms_encryption payload. Replace SCHEMA_NAME with encryption_metadata_schema. - DROP PROCEDURE IF EXISTS validate_encrypted_data_hmac_before_insert$$ - CREATE PROCEDURE validate_encrypted_data_hmac_before_insert( - IN p_table_name VARCHAR(64), - IN p_column_name VARCHAR(64), - IN column_value VARBINARY(65535) - ) - BEGIN - DECLARE v_hmac_key VARBINARY(32); - - IF column_value IS NOT NULL THEN - SELECT ks.hmac_key INTO v_hmac_key - FROM SCHEMA_NAME.encryption_metadata em - JOIN SCHEMA_NAME.key_storage ks ON em.key_id = ks.id - WHERE em.table_name = p_table_name - AND em.column_name = p_column_name - LIMIT 1; - - IF v_hmac_key IS NULL THEN - SIGNAL SQLSTATE '45000' - SET MESSAGE_TEXT = 'No HMAC key is configured for the encrypted column'; - END IF; - - IF NOT verify_encrypted_data_hmac(column_value, v_hmac_key) THEN - SIGNAL SQLSTATE '45000' - SET MESSAGE_TEXT = 'Column does not carry a valid HMAC tag (plaintext or tampered value)'; - END IF; - END IF; - END$$ - - -- Called from a BEFORE UPDATE trigger. An UPDATE that leaves the value as it was is not - -- re-checked; see "Updates after a key rotation". - DROP PROCEDURE IF EXISTS validate_encrypted_data_hmac_before_update$$ - CREATE PROCEDURE validate_encrypted_data_hmac_before_update( - IN p_table_name VARCHAR(64), - IN p_column_name VARCHAR(64), - IN new_value VARBINARY(65535), - IN old_value VARBINARY(65535) - ) - BEGIN - IF NOT (new_value <=> old_value) THEN - CALL validate_encrypted_data_hmac_before_insert(p_table_name, p_column_name, new_value); - END IF; - END$$ - - DELIMITER ; - ``` - Then create a pair of triggers for every column that you want to encrypt. For example, on `users.ssn`: @@ -1199,6 +1056,39 @@ plugins: `INSERT`, or an `UPDATE` that changes the encrypted column - is still checked, and must carry the current key's tag. The plugin always writes new values with the current key, so its writes pass. + + ### Updating the trigger SQL + + The trigger SQL changes from time to time, independently of the wrapper + version. A database keeps the version it was set up with until the file is + run again, so re-run the file for your engine when a newer version is listed + below. Re-running it replaces the functions and procedures without changing + any data, and the per-column triggers keep working without being re-created. + On MySQL the file drops and re-creates each routine, so a write to an + encrypted column can fail in the moment between the two: re-run it while + writes are quiet. + + Each file records its version in a database comment. To check the version a + database has: + + ```sql + -- PostgreSQL + SELECT obj_description('enforce_encrypted_column'::regproc, 'pg_proc'); + ``` + + ```sql + -- MySQL, in the schema the procedures were created in + SELECT ROUTINE_COMMENT FROM information_schema.ROUTINES + WHERE ROUTINE_SCHEMA = DATABASE() + AND ROUTINE_NAME = 'validate_encrypted_data_hmac_before_insert'; + ``` + + An empty result means the SQL was installed before versions were recorded. + + | Engine | Version | Change | If your database has an earlier version | + |---|---|---|---| + | PostgreSQL | v2 | Reads the column's HMAC key from `key_storage` for every row. | Re-run `trigger_pg.sql`. An empty result is an earlier version. | + | MySQL | v1 | Records the version. The SQL is otherwise unchanged. | No action needed. An empty result is equivalent to v1. | hardening: | ## Hardening the deployment diff --git a/content/scenarios.yaml b/content/scenarios.yaml index 62541a7..55e0b8f 100644 --- a/content/scenarios.yaml +++ b/content/scenarios.yaml @@ -462,7 +462,7 @@ addons: plugins: [iam] params: { iam_region: "" } notes: - - "Tokens are cached for `iam_expiration_sec` seconds (default `870.0`), which sits just under the 15-minute token lifetime." + - "Tokens are cached for up to `iam_expiration_sec` seconds, and never past 60 seconds before the 15-minute token lifetime ends, so with the default of `870.0` a token is reused for about 14 minutes." assumes: - "IAM authentication is enabled on the cluster and the database user is mapped to an IAM role." links: [rds_iam, rds_ca_bundle] diff --git a/site/docs-ruby/overview.md b/site/docs-ruby/overview.md index 13c7535..54527ef 100644 --- a/site/docs-ruby/overview.md +++ b/site/docs-ruby/overview.md @@ -21,7 +21,7 @@ will follow your choice where an equivalent page exists. ## Getting started -Requires Ruby 3.3 or later. Tested with Active Record 7.2, 8.0, and 8.1, `pg` 1.6.3 or later, and `mysql2` 0.5.7 or later. +Requires Ruby 3.3 or later. The gem is `aws_advanced_ruby_driver_wrapper` on RubyGems. Tested with Active Record 7.2, 8.0, and 8.1, `pg` 1.6.3 or later, and `mysql2` 0.5.7 or later. ### 1. Add the gem @@ -35,11 +35,54 @@ gem 'pg' # or: gem 'mysql2' bundle install ``` -Bundler requires the gem for you (in a plain Ruby script, add `require 'aws_advanced_ruby_driver_wrapper'`). That single require registers the Active Record adapters and makes the connection classes, error classes, and other public API available for direct use. +Without Bundler, `gem install aws_advanced_ruby_driver_wrapper pg` does the same thing. + +:::warning +If you are using `mysql2` on Windows with Ruby 4.0 or later, you may also need to add `fiddle` to your Gemfile: + +```ruby +gem 'fiddle' +``` + +On Windows, `mysql2` uses `fiddle` to load `libmysql.dll` when you set +`RUBY_MYSQL2_LIBMYSQL_DLL`, when the gem ships its own `libmysql.dll`, or +when Ruby was not installed with RubyInstaller, but it does not declare +`fiddle` as a dependency. Ruby 4.0 removed `fiddle` from the default gems, +so in those cases a bundle without it raises `LoadError` when `mysql2` is +required. +::: + ### 2. Point Active Record at your cluster -The wrapper registers two adapters, `aws_postgresql` and `aws_mysql2`, which are drop-in replacements for `postgresql` and `mysql2`. Change the adapter name and point the host at your cluster endpoint: +The wrapper registers two adapters, `aws_postgresql` and `aws_mysql2`, which are drop-in replacements for `postgresql` and `mysql2`. + +Bundler requires the gem for you. In a plain Ruby script, add `require 'aws_advanced_ruby_driver_wrapper'` first: that single require is what registers both adapters, and without it Active Record reports `aws_postgresql` as a nonexistent adapter. + +If you are starting without a Rails application, add `gem 'activerecord'` to the Gemfile from step 1 (outside Rails, nothing else installs it), run `bundle install`, and this is a complete program. Save it as `main.rb` and run it: + +```ruby +# main.rb +require 'active_record' +require 'aws_advanced_ruby_driver_wrapper' + +ActiveRecord::Base.establish_connection( + adapter: 'aws_postgresql', + host: 'my-cluster.cluster-xyz.us-east-1.rds.amazonaws.com', + database: 'mydb', + username: '', + password: '', + wrapper_plugins: 'failover' +) + +puts ActiveRecord::Base.connection.select_value('SELECT version()') +``` + +```bash +bundle exec ruby main.rb +``` + +In a Rails application the same keys go in `config/database.yml` instead, and Bundler has already done the require. The adapter name is the only key that changes; leave the host as whichever endpoint you already connect to: ```yaml # config/database.yml @@ -51,7 +94,7 @@ production: password: ``` -That is the whole change — no application code moves. When `wrapper_plugins` is not set, the wrapper loads `failover` and `initial_connection`, so connections made through this adapter already recover when the cluster promotes a new writer. Enable more by adding wrapper properties alongside the Active Record keys. Setting `wrapper_plugins` replaces the default list rather than adding to it, so list the defaults you want to keep: +That is the whole change — no application code moves, and connections made through this adapter already recover when the cluster promotes a new writer. Wrapper properties go alongside the Active Record keys, under the same connection: ```yaml production: @@ -62,6 +105,8 @@ production: failover_timeout_sec: 300.0 # seconds ``` +`wrapper_plugins` is optional — leaving it out loads `failover,initial_connection`. Setting it replaces the default list rather than adding to it, so list the defaults you want to keep. + Active Record keeps its own connection pool and its reading and writing roles; the wrapper's plugins run underneath both. :::note Mixing wrapped and standard adapters in one application @@ -73,12 +118,25 @@ with the other, because both resolve under the same underlying adapter key. ::: +:::note Keeping the password out of your source +Read it from the environment with `ENV.fetch('PGPASSWORD')` in Ruby, or +`<%= ENV.fetch('PGPASSWORD') %>` in `config/database.yml`, or have +AWS manage it: add `secrets_manager` to `wrapper_plugins` and drop the +`password:` key, as described on +[AWS Secrets Manager Plugin](using-plugins/aws-secrets-manager). For a +database user with no password at all, consider using `iam` instead; see +[IAM Authentication Plugin](using-plugins/iam-authentication). +::: + + ### Or connect with the driver directly -If you use the `pg` or `mysql2` gem without Active Record, the wrapper provides connection classes that stand in for `PG::Connection` and `Mysql2::Client`: +Without Active Record, the wrapper provides connection classes that stand in for `PG::Connection` and `Mysql2::Client`. This is a complete program; save it as `main.rb` and run it: ```ruby -# PostgreSQL (pg) +# main.rb +require 'aws_advanced_ruby_driver_wrapper/postgresql' + conn = AwsAdvancedRubyDriverWrapper::WrapperPgConnection.new( host: 'my-cluster.cluster-xyz.us-east-1.rds.amazonaws.com', dbname: 'mydb', @@ -87,23 +145,24 @@ conn = AwsAdvancedRubyDriverWrapper::WrapperPgConnection.new( wrapper_plugins: 'failover', failover_timeout_sec: 300.0 ) + +begin + result = conn.exec('SELECT version()') + puts result.first['version'] +ensure + conn.close +end ``` -```ruby -# MySQL (mysql2) -conn = AwsAdvancedRubyDriverWrapper::WrapperMysql2Client.new( - host: 'my-cluster.cluster-xyz.us-east-1.rds.amazonaws.com', - database: 'mydb', - username: '', - password: '', - wrapper_plugins: 'failover', - failover_timeout_sec: 300.0 -) +```bash +bundle exec ruby main.rb ``` -The calls your code already makes on the driver connection keep working, and the plugins act on each one. +For PostgreSQL, `require 'aws_advanced_ruby_driver_wrapper/postgresql'` and use `AwsAdvancedRubyDriverWrapper::WrapperPgConnection`, which stands in for `PG::Connection` and takes `dbname:` and `user:`. For MySQL, `require 'aws_advanced_ruby_driver_wrapper/mysql'` and use `AwsAdvancedRubyDriverWrapper::WrapperMysql2Client`, which stands in for `Mysql2::Client` and takes `database:` and `username:`. Either way the calls your code already makes keep working, and the plugins act on each one. ### Next -Not sure which plugins you need? [Set up by Scenario](setup) builds a configuration from a few questions about your application. To check a combination before shipping, see [Plugin Compatibility](compatibility). +The wrapper supports other plugins and wrapper properties. For further information see the plugin pages, starting with [Enhanced Failover Plugin](enhanced-failover). Every wrapper property the examples did not use is listed with its type, default and unit on the plugin page that reads it. To check a combination before shipping, see [Plugin Compatibility](compatibility). + +Not sure which plugins you need? [Set up by Scenario](setup) builds a configuration from a few questions about your application. diff --git a/site/docs-ruby/using-plugins/federated-auth.md b/site/docs-ruby/using-plugins/federated-auth.md index 2c0c0b9..d88d84c 100644 --- a/site/docs-ruby/using-plugins/federated-auth.md +++ b/site/docs-ruby/using-plugins/federated-auth.md @@ -94,7 +94,7 @@ Verify plugin compatibility within your Ruby configuration using the [compatibil | `iam_region` | String | No | parsed from host | Overrides the AWS region used to generate the IAM token. By default it is parsed from the connection host.

Example: `us-east-1` | | `iam_host` | String | No | derived from host | Overrides the host used to generate the IAM token. By default it is derived from the connection host.

Example: `my-cluster.cluster-xyz.us-east-1.rds.amazonaws.com` | | `iam_port` | Integer | No | dialect default | Overrides the port used to generate the IAM token. By default it is taken from the connection, or the dialect's default port.

Example: `5432` | -| `iam_expiration_sec` | Float | No | `870.0` | Fallback cache lifetime, in seconds, for a generated IAM token. A cached token normally lives for the lifetime signed into the token itself (15 minutes) minus a 60-second safety margin; this value is used only when that lifetime cannot be read from the token. It is capped at a maximum of `870.0` — the default — so a cached token is never used after it expires. A value greater than `870.0` or less than or equal to `0` is rejected. The token cache is shared with the `iam` and `okta` plugins. *(sec)*

Example: `600.0 (maximum 870.0)` | +| `iam_expiration_sec` | Float | No | `870.0` | Number of seconds a generated IAM token is kept in the cache before a new one is generated. The token itself is valid for 15 minutes, and a cached token is never used within 60 seconds of that expiry, so values of `840.0` and above will all have their tokens refetched at the `840` mark. The token cache is shared by every connection in the process that uses the `iam`, `federated_auth`, or `okta` plugin, and its lifetime is set by the first such connection; later connections that set a different value use the first connection's value. A value greater than `870.0` or less than or equal to `0` is rejected. *(sec)*

Example: `600.0 (maximum 870.0)` | | `ssl_insecure` | Boolean | No | `false` | When `true`, disables TLS certificate verification on the HTTPS requests the plugin makes to the identity provider. Intended for development only.

Example: `true` | | `http_client_socket_timeout_sec` | Float | No | `60.0` | Read (socket) timeout for the HTTPS requests the plugin makes to the identity provider. *(sec)*

Example: `60.0` | | `http_client_connect_timeout_sec` | Float | No | `60.0` | Connect timeout for the HTTPS requests the plugin makes to the identity provider. *(sec)*

Example: `60.0` | diff --git a/site/docs-ruby/using-plugins/iam-authentication.md b/site/docs-ruby/using-plugins/iam-authentication.md index 91740ea..a5f7576 100644 --- a/site/docs-ruby/using-plugins/iam-authentication.md +++ b/site/docs-ruby/using-plugins/iam-authentication.md @@ -140,7 +140,7 @@ Verify plugin compatibility within your Ruby configuration using the [compatibil | `iam_host` | String | No | derived from host | Overrides the hostname used to generate the IAM token. Required when connecting through a custom endpoint. The default is derived from the connection host.

Example: `my-cluster.cluster-xyz.us-east-1.rds.amazonaws.com` | | `iam_port` | Integer | No | dialect default | Overrides the port used to generate the IAM token. The default is determined from the underlying driver protocol or the dialect default.

Example: `5432` | | `iam_region` | String | No | parsed from host | Overrides the AWS region used to generate the IAM token. The default is parsed from the connection string.

Example: `us-east-1` | -| `iam_expiration_sec` | Float | No | `870.0` | Fallback cache lifetime, in seconds, for a generated IAM token. A cached token normally lives for the lifetime signed into the token itself (15 minutes) minus a 60-second safety margin; this value is used only when that lifetime cannot be read from the token. It is capped at a maximum of `870.0` — the default — so a cached token is never used after it expires. A value greater than `870.0` or less than or equal to `0` is rejected. *(sec)*

Example: `600.0 (maximum 870.0)` | +| `iam_expiration_sec` | Float | No | `870.0` | Number of seconds a generated IAM token is kept in the cache before a new one is generated. The token itself is valid for 15 minutes, and a cached token is never used within 60 seconds of that expiry, so values of `840.0` and above will all have their tokens refetched at the `840` mark. The token cache is shared by every connection in the process that uses the `iam`, `federated_auth`, or `okta` plugin, and its lifetime is set by the first such connection; later connections that set a different value use the first connection's value. A value greater than `870.0` or less than or equal to `0` is rejected. *(sec)*

Example: `600.0 (maximum 870.0)` | | `iam_access_token_property_name` | Symbol | No | `:password` | The connection property name the generated token is injected into. Some underlying drivers require a specific property name for the token.

Example: `:password` | | `aws_credentials_provider` | Object | No | SDK default chain | A custom AWS credentials provider instance. One property is read by every plugin that calls AWS — IAM authentication, Secrets Manager, KMS encryption and custom endpoint — so setting it once covers all of them. When unset, each falls back to the AWS SDK default credential provider chain.

Example: `Aws::AssumeRoleCredentials.new(...)` | @@ -185,11 +185,19 @@ different credentials never share a token, and a credentials provider that refreshes to a new access key gets a new token. When the credentials provider resolves to no credentials, the token is not cached. -A cached token is reused until 60 seconds before the expiry signed into it -(`iam_expiration_sec` applies only when that expiry cannot be read). If a +A cached token is reused until `iam_expiration_sec` elapses or until 60 +seconds before the token's own 15-minute expiry, whichever comes first. If a login error occurs with a cached token, the plugin automatically fetches a fresh token and retries the connection once. +:::note +The token cache is shared by every connection in the process that uses the +`iam`, `federated_auth`, or `okta` plugin, and the first such connection sets +its `iam_expiration_sec`. Connections opened later with a different value still +use the first connection's value, so set `iam_expiration_sec` to the same value +on every connection. +::: + ## Related - [AWS Credentials](../aws-credentials) — the plugin calls RDS to generate each diff --git a/site/docs-ruby/using-plugins/kms-encryption.md b/site/docs-ruby/using-plugins/kms-encryption.md index 4927f06..7c0afa6 100644 --- a/site/docs-ruby/using-plugins/kms-encryption.md +++ b/site/docs-ruby/using-plugins/kms-encryption.md @@ -530,67 +530,24 @@ that signs each value is stored unencrypted in `key_storage`: the server can verify that a value carries a valid integrity tag without holding the data key. +The trigger SQL is maintained in the wrapper repository: + +- PostgreSQL: [`trigger_pg.sql`](https://github.com/aws/aws-advanced-ruby-driver-wrapper/blob/main/lib/aws_advanced_ruby_driver_wrapper/plugins/kms_encryption/sql/trigger_pg.sql) +- MySQL: [`trigger_mysql.sql`](https://github.com/aws/aws-advanced-ruby-driver-wrapper/blob/main/lib/aws_advanced_ruby_driver_wrapper/plugins/kms_encryption/sql/trigger_mysql.sql) + +Run the file for your engine once per database, then add a trigger for every +encrypted column as shown below. The SQL is updated from time to time; see +[Updating the trigger SQL](#updating-the-trigger-sql). + ### PostgreSQL -```sql --- pgcrypto provides hmac(). If it is already installed in a schema other than public, --- replace public in public.hmac below with that schema. -CREATE EXTENSION IF NOT EXISTS pgcrypto WITH SCHEMA public; - --- Replace 'encrypt' below if encryption_metadata_schema is set to something else. --- A trigger runs with the search_path of the session that fires it. Pinning it to pg_catalog --- stops a session from putting its own functions or operators, such as hmac() or <>, ahead of --- the built-in ones to get a plaintext value past this check. -CREATE OR REPLACE FUNCTION enforce_encrypted_column() RETURNS trigger -SET search_path = pg_catalog, pg_temp -AS $$ -DECLARE - col_name text := TG_ARGV[0]; - col_value bytea; - hmac_key bytea; - cache_key text := 'hmac_key.' || TG_TABLE_NAME || '.' || col_name; - unchanged boolean; -BEGIN - -- An UPDATE that leaves the encrypted value as it was is not re-checked; see - -- "Updates after a key rotation". - IF TG_OP = 'UPDATE' THEN - EXECUTE format('SELECT ($1).%I IS NOT DISTINCT FROM ($2).%I', col_name, col_name) - INTO unchanged USING NEW, OLD; - IF unchanged THEN - RETURN NEW; - END IF; - END IF; - - EXECUTE format('SELECT ($1).%I', col_name) INTO col_value USING NEW; - IF col_value IS NULL THEN - RETURN NEW; - END IF; - - -- A setting cached by an earlier transaction reads back as '' rather than being - -- undefined, so an empty value is treated as not cached. - hmac_key := decode(NULLIF(current_setting(cache_key, true), ''), 'hex'); - IF hmac_key IS NULL THEN - SELECT ks.hmac_key INTO hmac_key - FROM encrypt.encryption_metadata em - JOIN encrypt.key_storage ks ON em.key_id = ks.id - WHERE em.table_name = TG_TABLE_NAME AND em.column_name = col_name; - - IF hmac_key IS NULL THEN - RAISE EXCEPTION 'No HMAC key is configured for %.%', TG_TABLE_NAME, col_name; - END IF; - - PERFORM set_config(cache_key, encode(hmac_key, 'hex'), true); - END IF; - - IF length(col_value) < 65 - OR substring(col_value from 1 for 32) <> public.hmac(substring(col_value from 33), hmac_key, 'sha256'::text) THEN - RAISE EXCEPTION 'Column %.% does not carry a valid HMAC tag (plaintext or tampered value)', TG_TABLE_NAME, col_name; - END IF; - - RETURN NEW; -END; -$$ LANGUAGE plpgsql; -``` +Run [`trigger_pg.sql`](https://github.com/aws/aws-advanced-ruby-driver-wrapper/blob/main/lib/aws_advanced_ruby_driver_wrapper/plugins/kms_encryption/sql/trigger_pg.sql). It installs the `pgcrypto` +extension if it is not already installed, and creates the +`enforce_encrypted_column()` trigger function. The function reads the +metadata tables as `encrypt.encryption_metadata` and `encrypt.key_storage`: +replace `encrypt` if `encryption_metadata_schema` is set to something else. If +`pgcrypto` is already installed in a schema other than `public`, replace +`public` in `public.hmac` with that schema. Then create a trigger for every column that you want to encrypt: @@ -606,136 +563,27 @@ BEFORE INSERT OR UPDATE ON users FOR EACH ROW EXECUTE FUNCTION enforce_encrypted_column('dob'); ``` -The HMAC key is cached for the length of the transaction rather than the -session, so that a key rotation takes effect immediately. Widen it to the -session with `set_config(..., false)` if the per-transaction metadata lookup -costs more than the rotation delay is worth. - ### MySQL -MySQL has no built-in HMAC function, so the equivalent builds HMAC-SHA256 out -of `SHA2()`. Create the two functions and the two validation procedures once per -schema, then add a `BEFORE INSERT` and a `BEFORE UPDATE` trigger per encrypted -column. Replace `SCHEMA_NAME` with the value of `encryption_metadata_schema` -(`encrypt` by default). Requires MySQL 5.7+ / MariaDB 10.2+ for `SHA2()`. On -Aurora/RDS MySQL, creating the functions may require the cluster parameter -`log_bin_trust_function_creators` to be set to `1`. +MySQL has no built-in HMAC function, so +[`trigger_mysql.sql`](https://github.com/aws/aws-advanced-ruby-driver-wrapper/blob/main/lib/aws_advanced_ruby_driver_wrapper/plugins/kms_encryption/sql/trigger_mysql.sql) builds HMAC-SHA256 out of +`SHA2()`. Run it once per schema to create the two functions and the two +validation procedures, then add a `BEFORE INSERT` and a `BEFORE UPDATE` +trigger per encrypted column. Replace `SCHEMA_NAME` in the file with the value +of `encryption_metadata_schema` (`encrypt` by default). Requires MySQL 5.7+ / +MariaDB 10.2+ for `SHA2()`. On Aurora/RDS MySQL, creating the functions may +require the cluster parameter `log_bin_trust_function_creators` to be set to +`1`. :::note -The SQL below uses `DELIMITER`, which is a command of the `mysql` command-line -client rather than SQL. To run it through a driver, a Rails migration, or any -other tool that sends one statement at a time, leave out the `DELIMITER` -lines and send each `DROP`, `CREATE FUNCTION`, `CREATE PROCEDURE` and -`CREATE TRIGGER` statement on its own, without its trailing `$$`. +The file and the trigger SQL below use `DELIMITER`, which is a command of the +`mysql` command-line client rather than SQL. To run them through a driver, a +Rails migration, or any other tool that sends one statement at a time, leave +out the `DELIMITER` lines and send each `DROP`, `CREATE FUNCTION`, +`CREATE PROCEDURE` and `CREATE TRIGGER` statement on its own, without its +trailing `$$`. ::: -```sql -DELIMITER $$ - --- HMAC-SHA256 built from SHA2(), which MySQL has no native HMAC for. -DROP FUNCTION IF EXISTS hmac_sha256$$ -CREATE FUNCTION hmac_sha256( - message VARBINARY(65535), - key_data VARBINARY(64) -) -RETURNS VARBINARY(32) -DETERMINISTIC -NO SQL -BEGIN - DECLARE block_size INT DEFAULT 64; -- SHA-256 block size - DECLARE key_padded VARBINARY(64); - DECLARE ipad VARBINARY(64); - DECLARE opad VARBINARY(64); - DECLARE i INT DEFAULT 1; - DECLARE key_byte INT; - - -- Reduce an over-long key to its hash, then zero-pad the key to the block size. - IF LENGTH(key_data) > block_size THEN - SET key_padded = CONCAT(UNHEX(SHA2(key_data, 256)), REPEAT(X'00', block_size - 32)); - ELSE - SET key_padded = CONCAT(key_data, REPEAT(X'00', block_size - LENGTH(key_data))); - END IF; - - -- ipad = key XOR 0x36 per byte, opad = key XOR 0x5C per byte, one raw byte at a time. - SET ipad = X''; - SET opad = X''; - WHILE i <= block_size DO - SET key_byte = ASCII(SUBSTRING(key_padded, i, 1)); - SET ipad = CONCAT(ipad, UNHEX(LPAD(HEX(key_byte ^ 0x36), 2, '0'))); - SET opad = CONCAT(opad, UNHEX(LPAD(HEX(key_byte ^ 0x5C), 2, '0'))); - SET i = i + 1; - END WHILE; - - RETURN UNHEX(SHA2(CONCAT(opad, UNHEX(SHA2(CONCAT(ipad, message), 256))), 256)); -END$$ - --- Verifies that a stored value carries a valid HMAC for the given HMAC key. -DROP FUNCTION IF EXISTS verify_encrypted_data_hmac$$ -CREATE FUNCTION verify_encrypted_data_hmac( - data VARBINARY(65535), - hmac_key VARBINARY(32) -) -RETURNS BOOLEAN -DETERMINISTIC -NO SQL -BEGIN - -- Minimum payload: 32 (HMAC) + 4 (key id) + 1 (type) + 12 (IV) + 0 (ciphertext) + 16 (GCM tag) = 65. - IF data IS NULL OR LENGTH(data) < 65 THEN - RETURN FALSE; - END IF; - - RETURN SUBSTRING(data, 1, 32) = hmac_sha256(SUBSTRING(data, 33), hmac_key); -END$$ - --- Called from a BEFORE INSERT trigger (and by the BEFORE UPDATE procedure) to reject a value that is --- not a valid kms_encryption payload. Replace SCHEMA_NAME with encryption_metadata_schema. -DROP PROCEDURE IF EXISTS validate_encrypted_data_hmac_before_insert$$ -CREATE PROCEDURE validate_encrypted_data_hmac_before_insert( - IN p_table_name VARCHAR(64), - IN p_column_name VARCHAR(64), - IN column_value VARBINARY(65535) -) -BEGIN - DECLARE v_hmac_key VARBINARY(32); - - IF column_value IS NOT NULL THEN - SELECT ks.hmac_key INTO v_hmac_key - FROM SCHEMA_NAME.encryption_metadata em - JOIN SCHEMA_NAME.key_storage ks ON em.key_id = ks.id - WHERE em.table_name = p_table_name - AND em.column_name = p_column_name - LIMIT 1; - - IF v_hmac_key IS NULL THEN - SIGNAL SQLSTATE '45000' - SET MESSAGE_TEXT = 'No HMAC key is configured for the encrypted column'; - END IF; - - IF NOT verify_encrypted_data_hmac(column_value, v_hmac_key) THEN - SIGNAL SQLSTATE '45000' - SET MESSAGE_TEXT = 'Column does not carry a valid HMAC tag (plaintext or tampered value)'; - END IF; - END IF; -END$$ - --- Called from a BEFORE UPDATE trigger. An UPDATE that leaves the value as it was is not --- re-checked; see "Updates after a key rotation". -DROP PROCEDURE IF EXISTS validate_encrypted_data_hmac_before_update$$ -CREATE PROCEDURE validate_encrypted_data_hmac_before_update( - IN p_table_name VARCHAR(64), - IN p_column_name VARCHAR(64), - IN new_value VARBINARY(65535), - IN old_value VARBINARY(65535) -) -BEGIN - IF NOT (new_value <=> old_value) THEN - CALL validate_encrypted_data_hmac_before_insert(p_table_name, p_column_name, new_value); - END IF; -END$$ - -DELIMITER ; -``` - Then create a pair of triggers for every column that you want to encrypt. For example, on `users.ssn`: @@ -788,6 +636,39 @@ encrypted values were re-encrypted. A value that is new to the row - an checked, and must carry the current key's tag. The plugin always writes new values with the current key, so its writes pass. +### Updating the trigger SQL + +The trigger SQL changes from time to time, independently of the wrapper +version. A database keeps the version it was set up with until the file is +run again, so re-run the file for your engine when a newer version is listed +below. Re-running it replaces the functions and procedures without changing +any data, and the per-column triggers keep working without being re-created. +On MySQL the file drops and re-creates each routine, so a write to an +encrypted column can fail in the moment between the two: re-run it while +writes are quiet. + +Each file records its version in a database comment. To check the version a +database has: + +```sql +-- PostgreSQL +SELECT obj_description('enforce_encrypted_column'::regproc, 'pg_proc'); +``` + +```sql +-- MySQL, in the schema the procedures were created in +SELECT ROUTINE_COMMENT FROM information_schema.ROUTINES + WHERE ROUTINE_SCHEMA = DATABASE() + AND ROUTINE_NAME = 'validate_encrypted_data_hmac_before_insert'; +``` + +An empty result means the SQL was installed before versions were recorded. + +| Engine | Version | Change | If your database has an earlier version | +|---|---|---|---| +| PostgreSQL | v2 | Reads the column's HMAC key from `key_storage` for every row. | Re-run `trigger_pg.sql`. An empty result is an earlier version. | +| MySQL | v1 | Records the version. The SQL is otherwise unchanged. | No action needed. An empty result is equivalent to v1. | + ## Hardening the deployment diff --git a/site/docs-ruby/using-plugins/okta-auth.md b/site/docs-ruby/using-plugins/okta-auth.md index 9792979..69f1a4f 100644 --- a/site/docs-ruby/using-plugins/okta-auth.md +++ b/site/docs-ruby/using-plugins/okta-auth.md @@ -94,7 +94,7 @@ Verify plugin compatibility within your Ruby configuration using the [compatibil | `iam_region` | String | No | parsed from host | Overrides the AWS region used to generate the IAM token. By default it is parsed from the connection host.

Example: `us-east-1` | | `iam_host` | String | No | derived from host | Overrides the host used to generate the IAM token. By default it is derived from the connection host.

Example: `my-cluster.cluster-xyz.us-east-1.rds.amazonaws.com` | | `iam_port` | Integer | No | dialect default | Overrides the port used to generate the IAM token. By default it is taken from the connection, or the dialect's default port.

Example: `5432` | -| `iam_expiration_sec` | Float | No | `870.0` | Fallback cache lifetime, in seconds, for a generated IAM token. A cached token normally lives for the lifetime signed into the token itself (15 minutes) minus a 60-second safety margin; this value is used only when that lifetime cannot be read from the token. It is capped at a maximum of `870.0` — the default — so a cached token is never used after it expires. A value greater than `870.0` or less than or equal to `0` is rejected. The token cache is shared with the `iam` and `federated_auth` plugins. *(sec)*

Example: `600.0 (maximum 870.0)` | +| `iam_expiration_sec` | Float | No | `870.0` | Number of seconds a generated IAM token is kept in the cache before a new one is generated. The token itself is valid for 15 minutes, and a cached token is never used within 60 seconds of that expiry, so values of `840.0` and above will all have their tokens refetched at the `840` mark. The token cache is shared by every connection in the process that uses the `iam`, `federated_auth`, or `okta` plugin, and its lifetime is set by the first such connection; later connections that set a different value use the first connection's value. A value greater than `870.0` or less than or equal to `0` is rejected. *(sec)*

Example: `600.0 (maximum 870.0)` | | `ssl_insecure` | Boolean | No | `false` | When `true`, disables TLS certificate verification on the HTTPS requests the plugin makes to the identity provider. Intended for development only.

Example: `true` | | `http_client_socket_timeout_sec` | Float | No | `60.0` | Read (socket) timeout for the HTTPS requests the plugin makes to the identity provider. *(sec)*

Example: `60.0` | | `http_client_connect_timeout_sec` | Float | No | `60.0` | Connect timeout for the HTTPS requests the plugin makes to the identity provider. *(sec)*

Example: `60.0` | diff --git a/site/package-lock.json b/site/package-lock.json index 83ed11c..85d981f 100644 --- a/site/package-lock.json +++ b/site/package-lock.json @@ -15,8 +15,8 @@ "@mermaid-js/layout-elk": "0.1.9", "clsx": "2.1.1", "prism-react-renderer": "2.4.1", - "react": "19.3.0", - "react-dom": "19.3.0" + "react": "19.3.1", + "react-dom": "19.3.1" }, "engines": { "node": ">=18" @@ -2257,9 +2257,9 @@ } }, "node_modules/@csstools/postcss-cascade-layers/node_modules/postcss-selector-parser": { - "version": "7.1.6", - "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.6.tgz", - "integrity": "sha512-7qASPzhKF2l2KLboRZux8CCTRMdGiV08vWmyKzPz22qZ7ZjQBOeY7rNzNoCLSUiftJ7HUq0GERHmxw/t0dCdMw==", + "version": "7.1.7", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.7.tgz", + "integrity": "sha512-wWBro/7hJ40ye6TPiXkUQoXKCw23xSsjriUvqd7Uls9Sso3oLiON1flc18cCdnjgCRXw4fBVqUJJeOdDTh3P3g==", "license": "MIT", "dependencies": { "cssesc": "^3.0.0", @@ -2678,9 +2678,9 @@ } }, "node_modules/@csstools/postcss-is-pseudo-class/node_modules/postcss-selector-parser": { - "version": "7.1.6", - "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.6.tgz", - "integrity": "sha512-7qASPzhKF2l2KLboRZux8CCTRMdGiV08vWmyKzPz22qZ7ZjQBOeY7rNzNoCLSUiftJ7HUq0GERHmxw/t0dCdMw==", + "version": "7.1.7", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.7.tgz", + "integrity": "sha512-wWBro/7hJ40ye6TPiXkUQoXKCw23xSsjriUvqd7Uls9Sso3oLiON1flc18cCdnjgCRXw4fBVqUJJeOdDTh3P3g==", "license": "MIT", "dependencies": { "cssesc": "^3.0.0", @@ -3125,9 +3125,9 @@ } }, "node_modules/@csstools/postcss-scope-pseudo-class/node_modules/postcss-selector-parser": { - "version": "7.1.6", - "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.6.tgz", - "integrity": "sha512-7qASPzhKF2l2KLboRZux8CCTRMdGiV08vWmyKzPz22qZ7ZjQBOeY7rNzNoCLSUiftJ7HUq0GERHmxw/t0dCdMw==", + "version": "7.1.7", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.7.tgz", + "integrity": "sha512-wWBro/7hJ40ye6TPiXkUQoXKCw23xSsjriUvqd7Uls9Sso3oLiON1flc18cCdnjgCRXw4fBVqUJJeOdDTh3P3g==", "license": "MIT", "dependencies": { "cssesc": "^3.0.0", @@ -6661,9 +6661,9 @@ } }, "node_modules/body-parser": { - "version": "1.20.8", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.8.tgz", - "integrity": "sha512-JNcyFQ64OiijEkPzUBTCe+hyPXUD/3LEldGQ6iF5LR1w00mx9o7xtDWHXBY2iItjdCFGoilOLNQbH943ut7pHA==", + "version": "1.20.9", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.9.tgz", + "integrity": "sha512-FISIQxV5u91Y9gvuFq3q/tA/qTqLJn3AhRcEvyozyhJTh5OBFFtv827AdHU7Rbyct4r+Ba1/99oFa1Y3yuFsdw==", "license": "MIT", "dependencies": { "bytes": "~3.1.2", @@ -7707,9 +7707,9 @@ } }, "node_modules/css-blank-pseudo/node_modules/postcss-selector-parser": { - "version": "7.1.6", - "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.6.tgz", - "integrity": "sha512-7qASPzhKF2l2KLboRZux8CCTRMdGiV08vWmyKzPz22qZ7ZjQBOeY7rNzNoCLSUiftJ7HUq0GERHmxw/t0dCdMw==", + "version": "7.1.7", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.7.tgz", + "integrity": "sha512-wWBro/7hJ40ye6TPiXkUQoXKCw23xSsjriUvqd7Uls9Sso3oLiON1flc18cCdnjgCRXw4fBVqUJJeOdDTh3P3g==", "license": "MIT", "dependencies": { "cssesc": "^3.0.0", @@ -7781,9 +7781,9 @@ } }, "node_modules/css-has-pseudo/node_modules/postcss-selector-parser": { - "version": "7.1.6", - "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.6.tgz", - "integrity": "sha512-7qASPzhKF2l2KLboRZux8CCTRMdGiV08vWmyKzPz22qZ7ZjQBOeY7rNzNoCLSUiftJ7HUq0GERHmxw/t0dCdMw==", + "version": "7.1.7", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.7.tgz", + "integrity": "sha512-wWBro/7hJ40ye6TPiXkUQoXKCw23xSsjriUvqd7Uls9Sso3oLiON1flc18cCdnjgCRXw4fBVqUJJeOdDTh3P3g==", "license": "MIT", "dependencies": { "cssesc": "^3.0.0", @@ -8921,9 +8921,9 @@ } }, "node_modules/dompurify": { - "version": "3.4.16", - "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.4.16.tgz", - "integrity": "sha512-sqo+pNp3qRhCIpbgRi1y8Tgk27Bo2Ry7w0dC1NBeNTdZChWjz9Xb/KOoZbRP/R6pQZ80Qw8YhXw13hWWBbMRnQ==", + "version": "3.4.17", + "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.4.17.tgz", + "integrity": "sha512-B/pSlYVHQ58kqISD/yDjuJ1yfzI34m1gF4lAod2bwSRhiN4K5Cl3H8Af7hqB2PmTL911tdEudnnXn5FnhRoz0w==", "license": "(MPL-2.0 OR Apache-2.0)", "optionalDependencies": { "@types/trusted-types": "^2.0.7" @@ -9575,9 +9575,9 @@ "license": "MIT" }, "node_modules/fast-uri": { - "version": "3.1.8", - "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.8.tgz", - "integrity": "sha512-GZMtZUTNRpOVIECoXwLNZS5xUGE+mVNbTB8h/7Rwh2TFWcBQiPzTgyZi05BF9UMZKkLJv8XBRJTlU7zg8+ZfMg==", + "version": "3.1.9", + "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.9.tgz", + "integrity": "sha512-hS/0Wt3Ya043oKXs0sIxrMpKQITXhMLIrVAKKXi4gozGC9v7YRWVnXIZzjNPTO02M9BdxLCWqK1yRXgNziVyJQ==", "funding": [ { "type": "github", @@ -9801,9 +9801,9 @@ } }, "node_modules/follow-redirects": { - "version": "1.16.0", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.16.0.tgz", - "integrity": "sha512-y5rN/uOsadFT/JfYwhxRS5R7Qce+g3zG97+JrtFZlC9klX/W5hD7iiLzScI4nZqUS7DNUdhPgw4xI8W2LuXlUw==", + "version": "1.16.2", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.16.2.tgz", + "integrity": "sha512-/kVP2U8z596Ia0gwFrwyIeo74ta5aVmSeU1FfAUMAmcEP5EP7zydmag3SLiN64NaRKef3lxsq7i/g7ltJQDGow==", "funding": [ { "type": "individual", @@ -11231,9 +11231,9 @@ } }, "node_modules/joi": { - "version": "17.13.8", - "resolved": "https://registry.npmjs.org/joi/-/joi-17.13.8.tgz", - "integrity": "sha512-iPKOGmiRw1jxf/JOPwxmCcUQAOdF359mdzYiP2DJ+TMX0YK2zjK3D+zYOaGjpumWxOFF/l2xVWjRVK5bGSLdEw==", + "version": "17.13.9", + "resolved": "https://registry.npmjs.org/joi/-/joi-17.13.9.tgz", + "integrity": "sha512-llFCT2rVtfwgBCaIqxtjim+iHqrgss4ONiGSYiiGH9jnjWq90ppSRffqmqKvwpa8W+YfILyQV6XyGcegXX2T4g==", "license": "BSD-3-Clause", "dependencies": { "@hapi/hoek": "^9.3.0", @@ -11398,13 +11398,13 @@ } }, "node_modules/launch-editor": { - "version": "2.14.1", - "resolved": "https://registry.npmjs.org/launch-editor/-/launch-editor-2.14.1.tgz", - "integrity": "sha512-QWBrQsMpH7gPr965dsKD/3cKWiNoTjpATQf++Xq63N6sKRGMwlVXz41O1IZTMfZQgBctD/K5Zt06+/I6pP6+HA==", + "version": "2.14.2", + "resolved": "https://registry.npmjs.org/launch-editor/-/launch-editor-2.14.2.tgz", + "integrity": "sha512-NHJEb30MGBCkmZXLZwz25t37QR4aY03ZzPYUJXOJaOa92uWwExI9SBQUuIznBYc1xkD7cJNGX7oc3Nl3sq2kQQ==", "license": "MIT", "dependencies": { "picocolors": "^1.1.1", - "shell-quote": "^1.8.4" + "shell-quote": "^1.10.0" } }, "node_modules/layout-base": { @@ -14780,9 +14780,9 @@ } }, "node_modules/postcss-attribute-case-insensitive/node_modules/postcss-selector-parser": { - "version": "7.1.6", - "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.6.tgz", - "integrity": "sha512-7qASPzhKF2l2KLboRZux8CCTRMdGiV08vWmyKzPz22qZ7ZjQBOeY7rNzNoCLSUiftJ7HUq0GERHmxw/t0dCdMw==", + "version": "7.1.7", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.7.tgz", + "integrity": "sha512-wWBro/7hJ40ye6TPiXkUQoXKCw23xSsjriUvqd7Uls9Sso3oLiON1flc18cCdnjgCRXw4fBVqUJJeOdDTh3P3g==", "license": "MIT", "dependencies": { "cssesc": "^3.0.0", @@ -15024,9 +15024,9 @@ } }, "node_modules/postcss-custom-selectors/node_modules/postcss-selector-parser": { - "version": "7.1.6", - "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.6.tgz", - "integrity": "sha512-7qASPzhKF2l2KLboRZux8CCTRMdGiV08vWmyKzPz22qZ7ZjQBOeY7rNzNoCLSUiftJ7HUq0GERHmxw/t0dCdMw==", + "version": "7.1.7", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.7.tgz", + "integrity": "sha512-wWBro/7hJ40ye6TPiXkUQoXKCw23xSsjriUvqd7Uls9Sso3oLiON1flc18cCdnjgCRXw4fBVqUJJeOdDTh3P3g==", "license": "MIT", "dependencies": { "cssesc": "^3.0.0", @@ -15062,9 +15062,9 @@ } }, "node_modules/postcss-dir-pseudo-class/node_modules/postcss-selector-parser": { - "version": "7.1.6", - "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.6.tgz", - "integrity": "sha512-7qASPzhKF2l2KLboRZux8CCTRMdGiV08vWmyKzPz22qZ7ZjQBOeY7rNzNoCLSUiftJ7HUq0GERHmxw/t0dCdMw==", + "version": "7.1.7", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.7.tgz", + "integrity": "sha512-wWBro/7hJ40ye6TPiXkUQoXKCw23xSsjriUvqd7Uls9Sso3oLiON1flc18cCdnjgCRXw4fBVqUJJeOdDTh3P3g==", "license": "MIT", "dependencies": { "cssesc": "^3.0.0", @@ -15190,9 +15190,9 @@ } }, "node_modules/postcss-focus-visible/node_modules/postcss-selector-parser": { - "version": "7.1.6", - "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.6.tgz", - "integrity": "sha512-7qASPzhKF2l2KLboRZux8CCTRMdGiV08vWmyKzPz22qZ7ZjQBOeY7rNzNoCLSUiftJ7HUq0GERHmxw/t0dCdMw==", + "version": "7.1.7", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.7.tgz", + "integrity": "sha512-wWBro/7hJ40ye6TPiXkUQoXKCw23xSsjriUvqd7Uls9Sso3oLiON1flc18cCdnjgCRXw4fBVqUJJeOdDTh3P3g==", "license": "MIT", "dependencies": { "cssesc": "^3.0.0", @@ -15228,9 +15228,9 @@ } }, "node_modules/postcss-focus-within/node_modules/postcss-selector-parser": { - "version": "7.1.6", - "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.6.tgz", - "integrity": "sha512-7qASPzhKF2l2KLboRZux8CCTRMdGiV08vWmyKzPz22qZ7ZjQBOeY7rNzNoCLSUiftJ7HUq0GERHmxw/t0dCdMw==", + "version": "7.1.7", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.7.tgz", + "integrity": "sha512-wWBro/7hJ40ye6TPiXkUQoXKCw23xSsjriUvqd7Uls9Sso3oLiON1flc18cCdnjgCRXw4fBVqUJJeOdDTh3P3g==", "license": "MIT", "dependencies": { "cssesc": "^3.0.0", @@ -15517,9 +15517,9 @@ } }, "node_modules/postcss-modules-local-by-default/node_modules/postcss-selector-parser": { - "version": "7.1.6", - "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.6.tgz", - "integrity": "sha512-7qASPzhKF2l2KLboRZux8CCTRMdGiV08vWmyKzPz22qZ7ZjQBOeY7rNzNoCLSUiftJ7HUq0GERHmxw/t0dCdMw==", + "version": "7.1.7", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.7.tgz", + "integrity": "sha512-wWBro/7hJ40ye6TPiXkUQoXKCw23xSsjriUvqd7Uls9Sso3oLiON1flc18cCdnjgCRXw4fBVqUJJeOdDTh3P3g==", "license": "MIT", "dependencies": { "cssesc": "^3.0.0", @@ -15545,9 +15545,9 @@ } }, "node_modules/postcss-modules-scope/node_modules/postcss-selector-parser": { - "version": "7.1.6", - "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.6.tgz", - "integrity": "sha512-7qASPzhKF2l2KLboRZux8CCTRMdGiV08vWmyKzPz22qZ7ZjQBOeY7rNzNoCLSUiftJ7HUq0GERHmxw/t0dCdMw==", + "version": "7.1.7", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.7.tgz", + "integrity": "sha512-wWBro/7hJ40ye6TPiXkUQoXKCw23xSsjriUvqd7Uls9Sso3oLiON1flc18cCdnjgCRXw4fBVqUJJeOdDTh3P3g==", "license": "MIT", "dependencies": { "cssesc": "^3.0.0", @@ -15644,9 +15644,9 @@ } }, "node_modules/postcss-nesting/node_modules/postcss-selector-parser": { - "version": "7.1.6", - "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.6.tgz", - "integrity": "sha512-7qASPzhKF2l2KLboRZux8CCTRMdGiV08vWmyKzPz22qZ7ZjQBOeY7rNzNoCLSUiftJ7HUq0GERHmxw/t0dCdMw==", + "version": "7.1.7", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.7.tgz", + "integrity": "sha512-wWBro/7hJ40ye6TPiXkUQoXKCw23xSsjriUvqd7Uls9Sso3oLiON1flc18cCdnjgCRXw4fBVqUJJeOdDTh3P3g==", "license": "MIT", "dependencies": { "cssesc": "^3.0.0", @@ -16007,9 +16007,9 @@ } }, "node_modules/postcss-pseudo-class-any-link/node_modules/postcss-selector-parser": { - "version": "7.1.6", - "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.6.tgz", - "integrity": "sha512-7qASPzhKF2l2KLboRZux8CCTRMdGiV08vWmyKzPz22qZ7ZjQBOeY7rNzNoCLSUiftJ7HUq0GERHmxw/t0dCdMw==", + "version": "7.1.7", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.7.tgz", + "integrity": "sha512-wWBro/7hJ40ye6TPiXkUQoXKCw23xSsjriUvqd7Uls9Sso3oLiON1flc18cCdnjgCRXw4fBVqUJJeOdDTh3P3g==", "license": "MIT", "dependencies": { "cssesc": "^3.0.0", @@ -16100,9 +16100,9 @@ } }, "node_modules/postcss-selector-not/node_modules/postcss-selector-parser": { - "version": "7.1.6", - "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.6.tgz", - "integrity": "sha512-7qASPzhKF2l2KLboRZux8CCTRMdGiV08vWmyKzPz22qZ7ZjQBOeY7rNzNoCLSUiftJ7HUq0GERHmxw/t0dCdMw==", + "version": "7.1.7", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.7.tgz", + "integrity": "sha512-wWBro/7hJ40ye6TPiXkUQoXKCw23xSsjriUvqd7Uls9Sso3oLiON1flc18cCdnjgCRXw4fBVqUJJeOdDTh3P3g==", "license": "MIT", "dependencies": { "cssesc": "^3.0.0", @@ -16113,9 +16113,9 @@ } }, "node_modules/postcss-selector-parser": { - "version": "6.1.4", - "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.1.4.tgz", - "integrity": "sha512-bIoJLOmjCO1S9XdY/DcnR5hJxvrDir1PbGChrzXG3vw0/FOliy/fA3dmdhQ441kah4gKv+TwckGzex6wNS5cnQ==", + "version": "6.1.5", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.1.5.tgz", + "integrity": "sha512-TEHFzb5KRDKaOgJ4TYE+0jyJtFbjLvkdVOu0fZ2b6MTWzoqZd4Le+61aEppWkvTlYePgOX4ATL1wsAIPMLTw6Q==", "license": "MIT", "dependencies": { "cssesc": "^3.0.0", @@ -16345,9 +16345,9 @@ } }, "node_modules/qs": { - "version": "6.16.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.16.0.tgz", - "integrity": "sha512-h6fhOIaRrID2CbEY2fqs+7t+UXZo+MLAnU5gRIq85uFtdiUPCdsApMlHhXogKVM4HM2DVbIjGNTTYH2OcmP1vA==", + "version": "6.16.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.16.2.tgz", + "integrity": "sha512-VYdnB5S7/0IeXzBacUtwNAaM6d7Y/PgYnNC7bJCI6meqA/OgnsQbZMtVW8Dt2D1PHgbHGtYmhSoEIgvt7xZ2ZA==", "license": "BSD-3-Clause", "dependencies": { "es-define-property": "^1.0.1", @@ -16477,24 +16477,24 @@ } }, "node_modules/react": { - "version": "19.3.0", - "resolved": "https://registry.npmjs.org/react/-/react-19.3.0.tgz", - "integrity": "sha512-E8LUcbtBWt20bbl2YoHfx4ZDBdxVTfOKtCZn9cDSJ4l6/nuoApcpIBcj47t2wZoVX8g2ZHuMHbiShgCR1T5Sog==", + "version": "19.3.1", + "resolved": "https://registry.npmjs.org/react/-/react-19.3.1.tgz", + "integrity": "sha512-QNhWdt7nrgVWWQG58QuGsAR3jv3Hbe4mb4vz7w2csnHavciZJgda1CPNaldF6eVxv90ud3jUXpKlHL69gO38yw==", "license": "MIT", "engines": { "node": ">=0.10.0" } }, "node_modules/react-dom": { - "version": "19.3.0", - "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.3.0.tgz", - "integrity": "sha512-JDk8dgif51OjFoDE70+OT9ICyYr+69HlmihNwp1+Nsfbna3t5sIiCa9ZJktDmQ4/1b/rn26hIAR2uYXDMr5r0Q==", + "version": "19.3.1", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.3.1.tgz", + "integrity": "sha512-Y0bARz53lhEC1NMCASs0/j+faB/zqt3R8hpvg1e8+61ZVJ4UL0UdC4cBbXfZMcIuhrfgeILTLe+ZeBCavQPtKQ==", "license": "MIT", "dependencies": { "scheduler": "^0.28.0" }, "peerDependencies": { - "react": "^19.3.0" + "react": "^19.3.1" } }, "node_modules/react-fast-compare": { @@ -17621,9 +17621,9 @@ } }, "node_modules/shell-quote": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.10.0.tgz", - "integrity": "sha512-w1aiOKwKuRgtwAReIIj89puqg+I7GvX4IbLrvmhXbzQsj1+Zwi4VO3+fa6ZF91TWSjIxoEkKnMeHcLEODK5ZXA==", + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.12.0.tgz", + "integrity": "sha512-PcByqNyT/38F2kDNi006HAMRJaULuBzq/FOsw3qdZvX/GA9W/jamDaRskgHjubHiftXK5sIFxLNkvrXUwcof6Q==", "license": "MIT", "engines": { "node": ">= 0.4" @@ -17826,9 +17826,9 @@ } }, "node_modules/source-map-js": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", - "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.2.tgz", + "integrity": "sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==", "license": "BSD-3-Clause", "engines": { "node": ">=0.10.0" diff --git a/site/package.json b/site/package.json index 2e27d25..6fba621 100644 --- a/site/package.json +++ b/site/package.json @@ -17,8 +17,8 @@ "@mermaid-js/layout-elk": "0.1.9", "clsx": "2.1.1", "prism-react-renderer": "2.4.1", - "react": "19.3.0", - "react-dom": "19.3.0" + "react": "19.3.1", + "react-dom": "19.3.1" }, "overrides": { "webpack": "5.97.1" diff --git a/site/src/generated/scenarios-ruby.json b/site/src/generated/scenarios-ruby.json index fda81b5..461dd33 100644 --- a/site/src/generated/scenarios-ruby.json +++ b/site/src/generated/scenarios-ruby.json @@ -947,7 +947,7 @@ "iam_region": "" }, "notes": [ - "Tokens are cached for `iam_expiration_sec` seconds (default `870.0`), which sits just under the 15-minute token lifetime." + "Tokens are cached for up to `iam_expiration_sec` seconds, and never past 60 seconds before the 15-minute token lifetime ends, so with the default of `870.0` a token is reused for about 14 minutes." ], "assumes": [ "IAM authentication is enabled on the cluster and the database user is mapped to an IAM role."