[Auth] Typed exception for a missing API-key pepper in ZB.MOM.WW.Auth.ApiKeys (mxaccessgw#195 residual) #23

Closed
opened 2026-11-09 12:24:28 -05:00 by dohertj2 · 1 comment
Owner

Follow-up from mxaccessgw#195 (8ba5667b).

ZB.MOM.WW.Auth.ApiKeys 0.3.0 reports a missing pepper as a plain InvalidOperationException("pepper unavailable"). Consumers can't catch that by type, so mxaccessgw now checks IApiKeyPepperProvider itself before create and rotate, instead of matching the exception message.

Do:

  • Add a typed exception to ZB.MOM.WW.Auth.ApiKeys (for example ApiKeyPepperUnavailableException : InvalidOperationException, so existing catches keep working), or a TryGetPepper on the provider.
  • Publish it in the next Auth release.
  • Note in the release notes that consumers can drop their own pre-checks: mxaccessgw's DashboardApiKeyManagementService, and any similar code in the other apps.
Follow-up from mxaccessgw#195 (8ba5667b). `ZB.MOM.WW.Auth.ApiKeys` 0.3.0 reports a missing pepper as a plain `InvalidOperationException("pepper unavailable")`. Consumers can't catch that by type, so mxaccessgw now checks `IApiKeyPepperProvider` itself before create and rotate, instead of matching the exception message. **Do:** - Add a typed exception to `ZB.MOM.WW.Auth.ApiKeys` (for example `ApiKeyPepperUnavailableException : InvalidOperationException`, so existing catches keep working), or a `TryGetPepper` on the provider. - Publish it in the next Auth release. - Note in the release notes that consumers can drop their own pre-checks: mxaccessgw's `DashboardApiKeyManagementService`, and any similar code in the other apps.
dohertj2 added the type:featurepriority:p3 labels 2026-11-09 12:24:28 -05:00
Author
Owner

Fixed on main 243c3fa — new ZB.MOM.WW.Auth.ApiKeys.ApiKeyPepperUnavailableException : InvalidOperationException (message unchanged, pepper unavailable) thrown by ApiKeyAdminCommands.RequirePepper() on create/rotate; existing catch (InvalidOperationException) keeps working. Verifier unchanged (still ApiKeyFailure.PepperUnavailable). Auth version 0.4.1 → 0.4.2 in Directory.Build.props — not yet published to the feed; mxaccessgw can drop its pre-check once it pins 0.4.2.

Evidence: ApiKeys.Tests 153 passed / 0 failed (new tests: catch-as-base, null/empty/whitespace pepper, ctors).

Fixed on main 243c3fa — new `ZB.MOM.WW.Auth.ApiKeys.ApiKeyPepperUnavailableException : InvalidOperationException` (message unchanged, `pepper unavailable`) thrown by `ApiKeyAdminCommands.RequirePepper()` on create/rotate; existing `catch (InvalidOperationException)` keeps working. Verifier unchanged (still `ApiKeyFailure.PepperUnavailable`). Auth version 0.4.1 → **0.4.2** in Directory.Build.props — **not yet published to the feed**; mxaccessgw can drop its pre-check once it pins 0.4.2. Evidence: ApiKeys.Tests 153 passed / 0 failed (new tests: catch-as-base, null/empty/whitespace pepper, ctors).
Sign in to join this conversation.