README.md in seraph-0.0.3 vs README.md in seraph-0.0.4
- old
+ new
@@ -9,53 +9,64 @@
Enter in your terminal
```
gem install seraph
```
or put
-```
+``` ruby
gem 'seraph'
```
inside your `Gemfile`
-### What do you get?
+## Configuration
-seraph offers two basic functionalities:
+You can set the pepper that will be used when encrypting the password.
-* encrypting the password (registration)
-* checking if provided password matches the encrypted password (authentication)
+Pepper strenghtens the security of your encrypted passwords, because even if you have an SQL Injection vulnerability in your code, the attacker won't be able to get the passwords, because the pepper will be added to each password before encryption. This is ofcourse true only if the attacker doesn't have access to your application code!
-#### Encrypting the password
-
-seraph uses [BCrypt](https://github.com/codahale/bcrypt-ruby) to hash the password. Additionally a pepper can be provided:
-
To get a random, high-entropy pepper, you can use `/dev/urandom`:
```
-⇒ xxd -l 32 -p /dev/urandom
-435a501746f35834862e49fd6654680803bc37a2a83bc67318342603b7176aaa
+xxd -l 32 -p /dev/urandom
```
-Save this value as a constant in you application code, so even if you have an SQL Injection vulnerability in your code, the attacker won't be able to get the passwords, because the pepper will be added to each password without encryption. This is of course true only if the attacker doesn't have access to your application code!
+Then use in the configuration block
-So with that out of the way, to encrypt a password, run the following code:
+``` ruby
+Seraph.configure do |config|
+ config.pepper = 'GENERATED-PEPPER'
+end
+```
+But remember to save the pepper, because if you lose it, none of your users will be able to login!
+
+## What do you get?
+
+Seraph offers two basic functionalities:
+
+* encrypting the password (registration)
+* checking if provided password matches the encrypted password (authentication)
+
+### Encrypting the password
+
+Seraph uses [BCrypt](https://github.com/codahale/bcrypt-ruby) to hash the password. If you configure Seraph and set the pepper, it will be used in the encryption process.
+
+To encrypt a password simply run:
+
``` ruby
-PEPPER = '435a501746f35834862e49fd6654680803bc37a2a83bc67318342603b7176aaa'
-seraph::PasswordEncryptor.call('foobar12')
-# => "$2a$10$MvzzJOcgCbxmVAUqwq7Zye.3Hn9L0ahB4M8riQTK6cPUfJCR6x3ZW"
+Seraph::PasswordEncryptor.call('foobar12')
+# => "$2a$10$f1PWs.Qi3mtcL/fMaypEJu9HI0SchWLhsMd9kRhHEjP4v/3oqnB5G"
```
-As a result you get the encrypted password, which you can persist in the database alongside other user data (e-mail, login, etc.)
+As a result you get the encrypted password, which you can be persisted in the database, alongside other user data (e-mail, login, etc.)
-#### Comparing a provided password with the encrypted one
+### WIP - Comparing a provided password with the encrypted one
Comparison is done using a constant-time secure comparison method, from the gem (fast_secure_compare)[https://github.com/daxtens/fast_secure_compare]
To do it simply run:
``` ruby
-PEPPER = '435a501746f35834862e49fd6654680803bc37a2a83bc67318342603b7176aaa'
-seraph::Authenticator.call(encrypted_password, plaintext_password)
+Seraph::Authenticator.call(encrypted_password, plaintext_password)
# => true or false
```
## Copyright