ConfigurationKeyGuard
AgentPrism.Core.dllVerifies that a configuration key name a stored record points at sits under an allowed prefix.
public static class ConfigurationKeyGuardInheritance
Section titled “Inheritance”object ← ConfigurationKeyGuard
Inherited Members
Section titled “Inherited Members”object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Remarks
Section titled “Remarks”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 AgentPrism 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.
Methods
Section titled “Methods”RequirePrefix(string?, string, string)
Section titled “ RequirePrefix(string?, string, string)”Throws unless a configuration key name sits under the allowed prefix.
public static void RequirePrefix(string? configurationKeyName, string allowedPrefix, string fieldName)Parameters
Section titled “Parameters”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.
Exceptions
Section titled “Exceptions”allowedPrefix is empty.
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.