has_secure_attribute 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +46 -2
- data/lib/has_secure_attribute/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 407ec97a134d4ff2d2ecc448a0c2b538b51945f9
|
4
|
+
data.tar.gz: 26c2a1fef2541a2954e468714effe93cf6fbe8cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3851f367a95043922611cf6f73589e1ddcb5f0e14c4eefe64425ed243ebea0633af5571ce6d830862032746daef3352812a36a20818bd917cf694b1ae0448aab
|
7
|
+
data.tar.gz: e22119c5300c2128acaa8dc803dec34e0f0b417770d595d89087ea83fbebed59d4a71a999fb15da96f48a55f073475c1e3badd57d611ee0ac45726df373a89e1
|
data/README.md
CHANGED
@@ -1,2 +1,46 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
`has_secure_attribute`
|
2
|
+
======================
|
3
|
+
|
4
|
+
Why have `has_secure_password` and not any attribute that you want. I believe that, quite often, we want to one-way encrypt one attribute and authenticate against its value, and this is not only the `password` case.
|
5
|
+
|
6
|
+
Requires
|
7
|
+
--------
|
8
|
+
|
9
|
+
`ActiveRecord` and `BCrypt`
|
10
|
+
|
11
|
+
Install
|
12
|
+
-------
|
13
|
+
|
14
|
+
`gem install 'has_secure_attribute'`
|
15
|
+
|
16
|
+
or in your `Gemfile`
|
17
|
+
|
18
|
+
`gem 'has_secure_attribute'` and then `bundle`
|
19
|
+
|
20
|
+
Use it
|
21
|
+
------
|
22
|
+
|
23
|
+
class User < ActiveRecord::Base
|
24
|
+
has_secure_security_answer
|
25
|
+
end
|
26
|
+
|
27
|
+
In the above example:
|
28
|
+
|
29
|
+
* Your should have a `users` table that has one column: `security_answer_digest`.
|
30
|
+
* It creates a reader: `security_answer`.
|
31
|
+
* It creates a writer: `security_answer=(value)` which basically saves the security answer given into the database on column `security_answer_digest` but is saves it encrypted.
|
32
|
+
* It adds some validations (if you want to avoid having these validations: `has_secure_security_answer :validations => false`).
|
33
|
+
* It creates a confirmation validation on `security_answer` but only if `security_answer` is given (for confirmation validations see [this](http://http://guides.rubyonrails.org/active_record_validations.html#confirmation)).
|
34
|
+
* It creates a presence validation on `security_answer` but only on create.
|
35
|
+
* It creates a presence validation on `security_answer_confirmation` but only if `security_answer` has been given.
|
36
|
+
* It raises an exception if `security_answer_digest` is empty on create.
|
37
|
+
* It defines the method `authenticate_security_answer(answer_to_authenticate)` which returns `false` if the answer given does not correspond to the saved digest, or returns the object instance itself if it does.
|
38
|
+
|
39
|
+
Do you want to test it?
|
40
|
+
------------------------
|
41
|
+
|
42
|
+
`bundle exec rake`
|
43
|
+
|
44
|
+
__Note:__ Testing works with a MySQL database. So, you need to have MySQL installed. Other than that, everything else needed to run the tests is done automatically. (db create, db migrate e.t.c.)
|
45
|
+
|
46
|
+
|