fix(crypto): allow parsing of cost int from env string (#7061)

fic(crypto): allow parsing of cost int from env string
This commit is contained in:
Tim Möhlmann 2023-12-15 13:16:05 +02:00 committed by GitHub
parent dae1911d43
commit 1adfca9d28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions

View File

@ -145,10 +145,14 @@ func (c *HasherConfig) buildHasher() (hasher passwap.Hasher, prefixes []string,
}
}
// decodeParams uses a mapstructure decoder from the Params map to dst.
// The decoder fails when there are unused fields in dst.
// It uses weak input typing, to allow conversion of env strings to ints.
func (c *HasherConfig) decodeParams(dst any) error {
decoder, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{
ErrorUnused: false,
ErrorUnset: true,
WeaklyTypedInput: true,
Result: dst,
})
if err != nil {

View File

@ -397,7 +397,11 @@ func TestHasherConfig_decodeParams(t *testing.T) {
"a": 1,
"b": "2",
},
wantErr: true,
want: dst{
A: 1,
B: 2,
},
wantErr: false, // https://github.com/zitadel/zitadel/issues/6913
},
{
name: "ok",