PowerShell / SecretManagement

PowerShell module to consistent usage of secrets through different extension vaults
MIT License
328 stars 46 forks source link

Consider read-only OrderedDictionary rather than ReadOnlyDictionary for metadata type #110

Closed JustinGrote closed 3 years ago

JustinGrote commented 3 years ago

ReadOnlyDictionary is difficult to construct in Powershell and may be an intimidating barrier to extension authors not fluent with C# (see https://github.com/PowerShell/SecretManagement/issues/108 for potential remediation on this point)

Further, ReadOnlyDictionary is case sensitive by default, which powershell users are normally not used to for property names. They would expect $secret.metadata.test and $secret.metadata.Test to return the same data, whereas currently only one will and one won't with ReadOnlyDictionary unless it was constructed with the correct stringcomparer

However, accepting an ordered in the secretinformation constructor makes it easy on extension authors who can just supply a hashtable or an ordered hashtable, and then secretmanagement can store/present with the AsReadOnly() method to get the same effect as a readonlydictionary using a non-generic type but one that is effectively string,object anyways.

Alternatively, the dictionary can be instantiated with StringComparer.OrdinalIgnoreCase, but this would require the extension author to implement correctly when supplying it to secretmanagement, leading to inconsistent user experience.

JustinGrote commented 3 years ago

Evidence right here of this problem: https://github.com/PowerShell/SecretManagement/issues/116

JustinGrote commented 3 years ago

Closing in favor of #108 approach.