EmailIdpUtils constructor
EmailIdpUtils({
- required EmailIdpConfig config,
- AuthUsers authUsers = const AuthUsers(),
Creates a new instance of EmailIdpUtils.
Implementation
EmailIdpUtils({
required EmailIdpConfig config,
AuthUsers authUsers = const AuthUsers(),
}) : hashUtil = Argon2HashUtil(
hashPepper: config.secretHashPepper,
fallbackHashPeppers: config.fallbackSecretHashPeppers,
hashSaltLength: config.secretHashSaltLength,
// Cost as recommended by OWASP: https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html
parameters: Argon2HashParameters(
memory: 19456,
iterations: 2,
lanes: 1,
),
),
account = EmailIdpAccountUtils() {
// Verification codes expire and allow few attempts, so they use the
// default Argon2 cost and not the password one.
final verificationCodeHash = Argon2HashUtil(
hashPepper: config.secretHashPepper,
fallbackHashPeppers: config.fallbackSecretHashPeppers,
hashSaltLength: config.secretHashSaltLength,
);
final completionTokenHash = Argon2HashUtil.forRandomSecrets(
hashPepper: config.secretHashPepper,
fallbackHashPeppers: config.fallbackSecretHashPeppers,
hashSaltLength: config.secretHashSaltLength,
);
accountCreation = EmailIdpAccountCreationUtil(
config: EmailIdpAccountCreationUtilsConfig.fromEmailIdpConfig(config),
passwordHashUtils: hashUtil,
authUsers: authUsers,
verificationCodeHash: verificationCodeHash,
completionTokenHash: completionTokenHash,
);
passwordReset = EmailIdpPasswordResetUtil(
config: EmailIdpPasswordResetUtilsConfig.fromEmailIdpConfig(config),
passwordHashUtils: hashUtil,
verificationCodeHash: verificationCodeHash,
completionTokenHash: completionTokenHash,
);
authentication = EmailIdpAuthenticationUtil(
hashUtil: hashUtil,
failedLoginRateLimit: config.failedLoginRateLimit,
);
otpLogin = EmailIdpOtpLoginUtil(
config: EmailIdpOtpLoginUtilsConfig.fromEmailIdpConfig(config),
passwordHashUtils: hashUtil,
authUsers: authUsers,
verificationCodeHash: verificationCodeHash,
completionTokenHash: completionTokenHash,
);
}