Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/watzon/lucky_have_i_been_pwned_validator
Have I Been Pwned password validator for LuckyFramework
https://github.com/watzon/lucky_have_i_been_pwned_validator
Last synced: about 2 months ago
JSON representation
Have I Been Pwned password validator for LuckyFramework
- Host: GitHub
- URL: https://github.com/watzon/lucky_have_i_been_pwned_validator
- Owner: watzon
- License: mit
- Created: 2019-06-14T19:22:01.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-08-15T16:08:19.000Z (about 3 years ago)
- Last Synced: 2024-05-08T23:09:12.718Z (5 months ago)
- Language: Crystal
- Size: 63.5 KB
- Stars: 9
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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](https://haveibeenpwned.com/) database.
![In Action](https://raw.githubusercontent.com/watzon/lucky_have_i_been_pwned_validator/master/img/in-action.gif)
## Installation
1. Add the dependency to your `shard.yml`:
```yaml
dependencies:
lucky_have_i_been_pwned_validator:
github: watzon/lucky_have_i_been_pwned_validator
```2. Run `shards install`
## Usage
First require the shard:
```crystal
# in your app's src/shards.cr
require "lucky_have_i_been_pwned_validator"
```Then perform the call in your operation(s):
```crystal
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:
```crystal
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:```crystal
begin
HaveIBeenPwned.validate_not_pwned(password, raise_exception: true)
rescue e : HaveIBeenPwned::ApiError
# report this to an error monitoring service for example...
end
```## Contributing
1. Fork it ()
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request## Contributors
- [Chris Watson](https://github.com/watzon) - creator and maintainer