diff --git a/internal/crypto/passwap.go b/internal/crypto/passwap.go index 1d9fb6752a..280fbe4d86 100644 --- a/internal/crypto/passwap.go +++ b/internal/crypto/passwap.go @@ -145,11 +145,15 @@ 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, - Result: dst, + ErrorUnused: false, + ErrorUnset: true, + WeaklyTypedInput: true, + Result: dst, }) if err != nil { return err diff --git a/internal/crypto/passwap_test.go b/internal/crypto/passwap_test.go index 0538ac631a..38ca0d5d3d 100644 --- a/internal/crypto/passwap_test.go +++ b/internal/crypto/passwap_test.go @@ -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",