firebase / firebase-admin-go

Firebase Admin Go SDK
Apache License 2.0
1.13k stars 244 forks source link

feat(auth): Hash Order Fix #392

Closed Galadros closed 4 years ago

Galadros commented 4 years ago

Allow users to specify inputHashOrder (salt first or password first) for hmac{md5, sha1, sha256, sha512} and {sha1, sha256, sha512}, persuant to an internal API proposal (similar features are being introduced for each Firebase Admin language). Also updated CONTRIBUTING.md to explain why some tests will fail for a non-GCIP Firebase project.

RELEASE NOTE: Implemented support for specifying password-salt order in hash configurations used when importing users.

hiranya911 commented 4 years ago

Is there a Go API proposal for the changes made here? I feel like instead of introducing a new InputOrder type and adding new fields to all hash types, we should just introduce 2 new functions:

func WithPasswordFirstHash(h UserImportHash) UserImportOption
func WithSaltFirstHash(h UserImportHash) UserImportOption

Usage example:

h := &hash.SHA512{
  Rounds: 1024,
}
result, err := client.ImportUsers(ctx, users, auth.WithPasswordFirstHash(h))
if err != nil {
  log.Fatalln(err)
}

This way the only new additions are the 2 helper functions, and we can handle the input order parameter in just one place instead of many.