entrance 0.4.0 → 0.4.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.
- data/README.md +45 -17
- data/lib/entrance/addons/omniauth.rb +3 -1
- data/lib/entrance/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
|
@@ -13,10 +13,9 @@ Clean, adaptable authentication library for Rails and Sinatra.
|
|
|
13
13
|
require 'entrance'
|
|
14
14
|
|
|
15
15
|
Entrance.configure do |config|
|
|
16
|
-
config.
|
|
17
|
-
config.password_attr = 'password_hash' # make sure you map the right attribute name
|
|
18
|
-
config.access_denied_message_key = 'messages.access_denied'
|
|
16
|
+
config.access_denied_redirect_to = '/login'
|
|
19
17
|
config.remember_for = 1.month
|
|
18
|
+
config.reset_password_window = 2.hours
|
|
20
19
|
config.cookie_secure = Rails.env.production?
|
|
21
20
|
end
|
|
22
21
|
|
|
@@ -37,7 +36,10 @@ class User
|
|
|
37
36
|
|
|
38
37
|
... (setup fields)
|
|
39
38
|
|
|
40
|
-
|
|
39
|
+
provides_entrance do |fields|
|
|
40
|
+
fields.username = :email
|
|
41
|
+
fields.password = :password
|
|
42
|
+
end
|
|
41
43
|
end
|
|
42
44
|
```
|
|
43
45
|
|
|
@@ -84,23 +86,22 @@ All available options, along with their defaults.
|
|
|
84
86
|
|
|
85
87
|
``` rb
|
|
86
88
|
Entrance.configure do |config|
|
|
87
|
-
|
|
89
|
+
# strategies
|
|
88
90
|
config.cipher = Entrance::Ciphers::BCrypt # can also be Entrance::Ciphers::SHA1
|
|
89
91
|
config.secret = nil
|
|
90
92
|
config.stretches = 10
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
config.
|
|
94
|
-
config.
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
config.reset_until_attr = 'reset_token_expires_at'
|
|
98
|
-
config.access_denied_redirect_to = '/'
|
|
99
|
-
config.access_denied_message_key = nil
|
|
93
|
+
|
|
94
|
+
# access denied
|
|
95
|
+
config.access_denied_redirect_to = '/login'
|
|
96
|
+
config.access_denied_message_key = nil # e.g. 'messages.access_denied'
|
|
97
|
+
|
|
98
|
+
# reset password
|
|
100
99
|
config.reset_password_mailer = 'UserMailer'
|
|
101
100
|
config.reset_password_method = 'reset_password_request'
|
|
102
|
-
config.reset_password_window = 1.hour
|
|
103
|
-
|
|
101
|
+
config.reset_password_window = 60 * 60 # 1.hour
|
|
102
|
+
|
|
103
|
+
# remember me & cookies
|
|
104
|
+
config.remember_for = 60 * 24 * 14 # 2.weeks
|
|
104
105
|
config.cookie_domain = nil
|
|
105
106
|
config.cookie_secure = true
|
|
106
107
|
config.cookie_path = '/'
|
|
@@ -108,6 +109,33 @@ Entrance.configure do |config|
|
|
|
108
109
|
end
|
|
109
110
|
```
|
|
110
111
|
|
|
112
|
+
## Entrance::Fields
|
|
113
|
+
|
|
114
|
+
As declared in your model. Options and their defaults are:
|
|
115
|
+
|
|
116
|
+
``` rb
|
|
117
|
+
provides_entrance do |fields|
|
|
118
|
+
# base
|
|
119
|
+
fields.unique_key = 'id'
|
|
120
|
+
fields.salt = nil # only required for SHA1 strategy
|
|
121
|
+
|
|
122
|
+
# username & password
|
|
123
|
+
fields.name = 'name' # only used by omniauth addon
|
|
124
|
+
fields.username = 'email'
|
|
125
|
+
fields.password = 'password_hash'
|
|
126
|
+
|
|
127
|
+
# remember and reset
|
|
128
|
+
fields.remember_token = 'remember_token'
|
|
129
|
+
fields.remember_until = 'remember_token_expires_at'
|
|
130
|
+
fields.reset_token = 'reset_token'
|
|
131
|
+
fields.reset_until = 'reset_token_expires_at'
|
|
132
|
+
|
|
133
|
+
# omniauth
|
|
134
|
+
fields.auth_provider = 'auth_provider'
|
|
135
|
+
fields.auth_uid = 'auth_uid'
|
|
136
|
+
end
|
|
137
|
+
```
|
|
138
|
+
|
|
111
139
|
## Entrance::Controller
|
|
112
140
|
|
|
113
141
|
When including it into your controller, this module will provide the following methods:
|
|
@@ -127,7 +155,7 @@ And the following helpers:
|
|
|
127
155
|
|
|
128
156
|
Provides:
|
|
129
157
|
|
|
130
|
-
- .
|
|
158
|
+
- .provides_entrance(&block)
|
|
131
159
|
- .authenticate(username, password)
|
|
132
160
|
- .with_password_reset_token(token)
|
|
133
161
|
- #password and #password=(value)
|
|
@@ -51,7 +51,9 @@ module Entrance
|
|
|
51
51
|
|
|
52
52
|
app.settings.auth_providers.each do |name, options|
|
|
53
53
|
# puts "Initializing #{name} provider: #{options.inspect}"
|
|
54
|
-
provider(name,
|
|
54
|
+
# omniauth expects provider(:name, arg1, arg2, arg3), so we need to map only the values
|
|
55
|
+
opts = options && options.any? ? options.values : []
|
|
56
|
+
provider(name, *opts)
|
|
55
57
|
end
|
|
56
58
|
end
|
|
57
59
|
|
data/lib/entrance/version.rb
CHANGED