Skip to content

Deep clean: stop reading password hash, fail-fast config, dependency hygiene - #4

Merged
Isma-L154 merged 5 commits into
refactor/english-rewrite-v2from
chore/deep-clean
Sep 22, 2026
Merged

Isma-L154 merged 5 commits into
refactor/english-rewrite-v2from
chore/deep-clean

Conversation

@Isma-L154

Copy link
Copy Markdown
Owner

Closes #3

Stacked on refactor/english-rewrite-v2; retarget to main once that branch lands.

Changes (one commit each)

  1. Security: the reflection mapper copied PasswordHash from the database entity into the public User model. Removed Authorization.Common (Mapper/Converter), moved the entities into DataAccess as internal types without a password hash property (Dapper ignores the unmatched column), and replaced the mapper with explicit mapping. PasswordHash is removed from the public model.
  2. Dependencies: Authorization.Middleware now uses the Microsoft.AspNetCore.App framework reference instead of the legacy Microsoft.AspNetCore.Http.Abstractions 2.3.0 package and five redundant Microsoft.Extensions.* references. Dropped the unused Authorization.Common reference.
  3. Resilience: options and connection string presence are validated with ValidateOnStart. Previously a missing connection string threw while resolving the middleware's scoped dependencies (outside its graceful degradation), which returned 500 on every authenticated request.
  4. Quality: added ClaimsEnrichmentMiddleware.UserIdClaimType, removed historical comments, updated the README, deduplicated test setup, and covered the aborted-request path.
  5. CI: simplified the push trigger and set contents: read on the CI token.

Breaking changes (v2.0.0, unreleased)

  • The Authorization.Common package no longer exists.
  • Authorization.Abstractions.Entities.* is no longer public.
  • Models.User.PasswordHash was removed.
  • The host now fails at startup when the connection string or settings are missing.

Validation

  • dotnet build -c Release: 0 warnings, 0 errors (warnings are treated as errors).
  • dotnet test: 12/12 passed.
  • dotnet pack: 4 packages created.
  • dotnet list package --vulnerable --include-transitive: no vulnerable packages.

…icit mapping

The reflection-based mapper in Authorization.Common copied every matching
property from the database entity into the domain model, which carried the
user's password hash into the business and middleware layers even though
nothing there needs it. The package only ever mapped two trivial types.

- Remove Authorization.Common (Mapper, Converter) and their tests.
- Move persistence entities into DataAccess as internal types without a
  password hash property; Dapper ignores the unmatched column.
- Remove PasswordHash from the public User model.
- Map entities to models explicitly in SecurityRepository.

Refs #3
Microsoft.AspNetCore.Http.Abstractions 2.3.0 is the legacy ASP.NET Core 2.x
package; on net8.0 it ships its own copies of types that the host already
provides through the shared framework. Reference Microsoft.AspNetCore.App
instead, which also covers the Microsoft.Extensions.* packages that were
listed explicitly (Configuration.Abstractions was unused).

Refs #3
SqlConnectionFactory throws when the connection string is missing, but it is
resolved while binding the middleware's scoped dependencies, outside the
middleware's graceful-degradation block. A misconfigured host therefore
returned 500 on every authenticated request. Validate the options and the
connection string presence with ValidateOnStart so the host fails fast.

Refs #3
- Add ClaimsEnrichmentMiddleware.UserIdClaimType so consumers and tests stop
  repeating the "IdUsuario" literal.
- Make AddProfileClaimsAsync static; it uses no instance state.
- Drop historical wording from option docs and package descriptions.
- Update the README for the removed Common package and startup validation.
- Share middleware construction in tests and cover the aborted-request path.

Refs #3
An empty branches-ignore list is equivalent to an unfiltered push trigger.
The CI job only needs to read the repository, so grant contents: read.

Refs #3
@Isma-L154
Isma-L154 merged commit c5a190e into refactor/english-rewrite-v2 Sep 22, 2026
2 checks passed
@Isma-L154
Isma-L154 deleted the chore/deep-clean branch September 22, 2026 04:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant