Repository navigation
fix!: harden dapper providers and skip keys with null xml - #53
Merged
Merged
Conversation
InitializeDb checks pg_tables and pg_indexes before creating the table and
the friendly-name index: PostgreSQL checks privileges before IF NOT EXISTS,
so a role without CREATE on the schema failed on every start even when the
table existed.
The validator limits the schema and table names to 45 characters together,
so that the derived index name fits the 63-character identifier limit
instead of being silently truncated.
BREAKING CHANGE: PostgreSQL schema and table names longer than 45 characters
together are rejected at startup. Rename the table and its
ix_{schema}_{table}_friendly_name index, then update the configuration.
The provider registered the public SqlConnectionFactory as an unkeyed singleton, so a factory registered by the application either replaced the keys connection or received it, depending on the registration order. It is now registered under an internal service key, as the PostgreSQL data source. BREAKING CHANGE: SqlConnectionFactory is no longer resolvable without a key. Applications that resolved it must register their own; applications that register SQLServerDataProtectionRepository themselves must call PersistKeysWithDapperInSqlServer() or pass the connection factory explicitly.
DataProtectionKey.Xml is required but not enforced at runtime. A null value made XElement.Parse throw ArgumentNullException, which failed the whole key ring instead of skipping the row. It is now handled as an empty, malformed document: logged as SkippingMalformedKey and skipped.
Owner
Author
|
Rebased and merged to have the commits in history instead of using the usual squash |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes found in a code review of
src. One commit per area; the squash commit should use the message below.InitializeDb()creates the table and the friendly-name index only when they are missing. PostgreSQL checks privileges beforeIF NOT EXISTS, so a role withoutCREATEon the schema (the default onpublicsince PostgreSQL 15) failed on every start even when the table existed. Covered by a new test that runsInitializeDb()as a restricted role.ix_{schema}_{table}_friendly_namefits the 63-character identifier limit instead of being silently truncated (two tables could get the same index name).SqlConnectionFactoryis registered as a keyed service, as the PostgreSQL data source since fix(postgresql): register NpgsqlDataSource as a keyed service #48, so it no longer collides with a factory registered by the application.nullXML is logged (SkippingMalformedKey) and skipped instead of failing the whole key ring.README (name limits, initialization privileges, v2 migration notes) and AGENTS.md are updated.
BREAKING CHANGE: PostgreSQL schema and table names longer than 45 characters together are rejected at startup. Rename the table and its ix_{schema}_{table}_friendly_name index, then update the configuration.
BREAKING CHANGE: SqlConnectionFactory is no longer resolvable without a key. Applications that resolved it must register their own; applications that register SQLServerDataProtectionRepository themselves must call PersistKeysWithDapperInSqlServer() or pass the connection factory explicitly.