mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 11:04:25 +00:00
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:
parent
dae1911d43
commit
1adfca9d28
@ -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 {
|
func (c *HasherConfig) decodeParams(dst any) error {
|
||||||
decoder, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{
|
decoder, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{
|
||||||
ErrorUnused: false,
|
ErrorUnused: false,
|
||||||
ErrorUnset: true,
|
ErrorUnset: true,
|
||||||
|
WeaklyTypedInput: true,
|
||||||
Result: dst,
|
Result: dst,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -397,7 +397,11 @@ func TestHasherConfig_decodeParams(t *testing.T) {
|
|||||||
"a": 1,
|
"a": 1,
|
||||||
"b": "2",
|
"b": "2",
|
||||||
},
|
},
|
||||||
wantErr: true,
|
want: dst{
|
||||||
|
A: 1,
|
||||||
|
B: 2,
|
||||||
|
},
|
||||||
|
wantErr: false, // https://github.com/zitadel/zitadel/issues/6913
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "ok",
|
name: "ok",
|
||||||
|
Loading…
Reference in New Issue
Block a user