lucky_have_i_been_pwned_validator
Have I Been Pwned Lucky Validator
This is a simple password validator for Lucky that ensures the password isn't in the Have I Been Pwned database.

Installation
-
Add the dependency to your
shard.yml:dependencies: lucky_have_i_been_pwned_validator: github: watzon/lucky_have_i_been_pwned_validator -
Run
shards install
Usage
First require the shard:
# in your app's src/shards.cr
require "lucky_have_i_been_pwned_validator"
Then perform the call in your operation(s):
class SignUpUser < User::SaveOperation
...
before_save do
...
HaveIBeenPwned.validate_not_pwned(password)
...
end
end
The validate_not_pwned method accepts a second argument for a custom message:
HaveIBeenPwned.validate_not_pwned(password, "is PWNED %s times!")
And you can also choose to catch API errors from the pwned API to make your app more resilient:
begin
HaveIBeenPwned.validate_not_pwned(password, raise_exception: true)
rescue e : HaveIBeenPwned::ApiError
# report this to an error monitoring service for example...
end
Contributing
- Fork it (https://github.com/watzon/lucky_have_i_been_pwned_validator/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- Chris Watson - creator and maintainer
Repository
lucky_have_i_been_pwned_validator
Owner
Statistic
- 9
- 1
- 0
- 0
- 2
- about 4 years ago
- June 14, 2019
License
MIT License
Links
Synced at
Tue, 28 Oct 2025 16:57:48 GMT
Languages