Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### :magic_wand: Added
- [Federated Authentication Plugin](https://aws.github.io/aws-advanced-wrapper-docs/ruby/using-plugins/federated-auth), which authenticates with Active Directory Federation Services (AD FS), exchanges the resulting SAML assertion for temporary AWS credentials via STS, and connects to the database with an RDS IAM authentication token. Enabled with the `federated_auth` plugin code ([PR #207](https://github.com/aws/aws-advanced-ruby-driver-wrapper/pull/207)).

### :crab: Changed
- Simplified the KMS Encryption Plugin's PostgreSQL trigger SQL to read the column's HMAC key from `key_storage` for every row. Re-run the trigger SQL from the [documentation](https://aws.github.io/aws-advanced-wrapper-docs/ruby/using-plugins/kms-encryption#postgresql-1) to update existing deployments ([PR #216](https://github.com/aws/aws-advanced-ruby-driver-wrapper/pull/216)).

## [1.0.1] - 2026-10-07

### :bug: Fixed
Expand Down
2 changes: 0 additions & 2 deletions spec/integration/container/kms_encryption_triggers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@
end
end

# The trigger caches the column's HMAC key for the length of a transaction. A later transaction on
# the same connection must look it up again rather than reading back the expired cache entry.
shared_examples 'a trigger across transactions on one connection' do
it 'accepts a valid value in each of several transactions on the same connection' do
3.times do |i|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ 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
Expand All @@ -31,20 +30,14 @@ BEGIN
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;
-- Read the column's current HMAC key from key_storage.
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;

PERFORM set_config(cache_key, encode(hmac_key, 'hex'), true);
IF hmac_key IS NULL THEN
RAISE EXCEPTION 'No HMAC key is configured for %.%', TG_TABLE_NAME, col_name;
END IF;

IF length(col_value) < 65
Expand Down
Loading