Skip to content
Tracon

ConfigurationKeyGuard

Namespace Tracon · Assembly Tracon.Core.dll

Verifies that a configuration key name a stored record points at sits under an allowed prefix.

public static class ConfigurationKeyGuard

objectConfigurationKeyGuard

object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

A record never holds a secret value; it holds the name of the configuration key the value is read from. That alone is not enough. Without a prefix restriction, an administrator could bind a record to an unrelated key such as ConnectionStrings:Default — unable to read its value, but able to make Tracon send it somewhere.

The rule is enforced twice on every surface: once where the record is saved, and again where the value is resolved. A record written before the prefix was configured must not silently read an out-of-prefix key.

Throws unless a configuration key name sits under the allowed prefix.

public static void RequirePrefix(string? configurationKeyName, string allowedPrefix, string fieldName)

configurationKeyName string?

The configuration key name the record carries.

allowedPrefix string

The only prefix a key name may start with.

fieldName string

The name of the field being checked, as it appears to the caller.

ArgumentException

allowedPrefix is empty.

TraconException

configurationKeyName is empty, or does not start with allowedPrefix. The message names both the field and the prefix, so the operator can see which field to correct.