authentasaurus 0.5.14 → 0.6.0
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/app/views/authentasaurus_emailer/invitation_mail.html.erb +2 -2
- data/app/views/authentasaurus_emailer/recovery_mail.html.erb +2 -2
- data/app/views/authentasaurus_emailer/validation_mail.html.erb +2 -2
- data/generators/authentasaurus/templates/defaults.yml +4 -0
- data/generators/authentasaurus_views/USAGE +3 -3
- data/generators/authentasaurus_views/authentasaurus_views_generator.rb +1 -0
- data/generators/authentasaurus_views/templates/views/authentasaurus_emailer/invitation_mail.html.erb +2 -2
- data/generators/authentasaurus_views/templates/views/authentasaurus_emailer/recovery_mail.html.erb +2 -2
- data/generators/authentasaurus_views/templates/views/authentasaurus_emailer/validation_mail.html.erb +2 -2
- data/lib/active_record/acts_as_authenticatable.rb +25 -2
- data/lib/active_resource/acts_as_authenticatable.rb +10 -4
- data/lib/active_resource/authenticatable.rb +2 -0
- data/lib/authentasaurus/models/recovery.rb +2 -0
- data/lib/authentasaurus/models/user_invitation.rb +2 -2
- metadata +4 -4
@@ -1,4 +1,4 @@
|
|
1
|
-
<p>You've been invited to create an account at
|
1
|
+
<p>You've been invited to create an account at <%= AUTHENTASAURUS[:mail][:host] %> follow this <%= link_to "link", new_registrations_url(:host => AUTHENTASAURUS[:mail][:host], :token => @token) %> to respond to the invitation.</p>
|
2
2
|
|
3
3
|
<p>Best Regards,</p>
|
4
|
-
<p
|
4
|
+
<p><%= AUTHENTASAURUS[:mail][:host] %> Team</p>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<p>Dear <%= @name %>,</p>
|
2
2
|
|
3
3
|
<p>A request has been made to recover your account's password.</p>
|
4
|
-
<p>Please visit this <%= link_to "link", recover_password_url(@token) %> and follow the instructions.</p>
|
4
|
+
<p>Please visit this <%= link_to "link", recover_password_url(:host => AUTHENTASAURUS[:mail][:host], @token) %> and follow the instructions.</p>
|
5
5
|
|
6
6
|
<p>Best Regards,</p>
|
7
|
-
<p
|
7
|
+
<p><%= AUTHENTASAURUS[:mail][:host] %> Team</p>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<p>Dear <%= @name %>,</p>
|
2
2
|
|
3
|
-
<p>Please validate your account at
|
3
|
+
<p>Please validate your account at <%= AUTHENTASAURUS[:mail][:host] %> by visiting this <%= link_to "link", validate_url(:host => AUTHENTASAURUS[:mail][:host] , :code => @vcode) %>.</p>
|
4
4
|
|
5
5
|
<p>Best Regards,</p>
|
6
|
-
<p
|
6
|
+
<p><%= AUTHENTASAURUS[:mail][:host] %> Team</p>
|
@@ -1,7 +1,9 @@
|
|
1
1
|
## Authentasaurus configuration
|
2
2
|
development: &non_production_settings
|
3
|
+
:hashing: "SHA2" # MD5 - SHA1 - SHA2
|
3
4
|
:mail:
|
4
5
|
:email: &development_email "foo_bar@your-domain.com"
|
6
|
+
:host: "http://localhost:3000/"
|
5
7
|
:modules:
|
6
8
|
:remote:
|
7
9
|
:user:
|
@@ -27,8 +29,10 @@ test:
|
|
27
29
|
<<: *non_production_settings
|
28
30
|
|
29
31
|
production:
|
32
|
+
:hashing: "SHA2" # MD5 - SHA1 - SHA2
|
30
33
|
:mail:
|
31
34
|
:email: &production_email "foo_bar@your-domain.com"
|
35
|
+
:host: "http://your_website.com/"
|
32
36
|
:modules:
|
33
37
|
:remote:
|
34
38
|
:user:
|
@@ -4,9 +4,9 @@ Description:
|
|
4
4
|
Examples:
|
5
5
|
`./script/generate authentasaurus_views users`
|
6
6
|
|
7
|
-
creates views for Authentasaurus with main user model named "user"
|
7
|
+
creates views for Authentasaurus with main user model named "user" and controller named "users"
|
8
8
|
|
9
|
-
`./script/generate authentasaurus_views users --authorizable --validatable
|
9
|
+
`./script/generate authentasaurus_views users --authorizable --validatable --invitable
|
10
10
|
|
11
11
|
creates views for Authentasaurus with main user model named "user" and also creates views
|
12
|
-
for authorization (--authorizable) and validation (--validatable)
|
12
|
+
for authorization (--authorizable), invitation (--invitable) and validation (--validatable)
|
@@ -23,6 +23,7 @@ class AuthentasaurusViewsGenerator < Rails::Generator::NamedBase
|
|
23
23
|
## recoverable
|
24
24
|
m.file 'views/recoveries/new.html.erb', File.join("app/views", class_path, "recoveries", "new.html.erb")
|
25
25
|
m.file 'views/recoveries/edit.html.erb', File.join("app/views", class_path, "recoveries", "edit.html.erb")
|
26
|
+
m.file 'views/authentasaurus_emailer/recovery_mail.html.erb', File.join("app/views", class_path, "authentasaurus_emailer", "recovery_mail.html.erb")
|
26
27
|
|
27
28
|
|
28
29
|
if options[:authorizable]
|
data/generators/authentasaurus_views/templates/views/authentasaurus_emailer/invitation_mail.html.erb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
<p>You've been invited to create an account at
|
1
|
+
<p>You've been invited to create an account at <%= AUTHENTASAURUS[:mail][:host] %> follow this <%= link_to "link", new_registrations_url(:host => AUTHENTASAURUS[:mail][:host], :token => @token) %> to respond to the invitation.</p>
|
2
2
|
|
3
3
|
<p>Best Regards,</p>
|
4
|
-
<p
|
4
|
+
<p><%= AUTHENTASAURUS[:mail][:host] %> Team</p>
|
data/generators/authentasaurus_views/templates/views/authentasaurus_emailer/recovery_mail.html.erb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
<p>Dear <%= @name %>,</p>
|
2
2
|
|
3
3
|
<p>A request has been made to recover your account's password.</p>
|
4
|
-
<p>Please visit this <%= link_to "link", recover_password_url(@token) %> and follow the instructions.</p>
|
4
|
+
<p>Please visit this <%= link_to "link", recover_password_url(:host => AUTHENTASAURUS[:mail][:host], @token) %> and follow the instructions.</p>
|
5
5
|
|
6
6
|
<p>Best Regards,</p>
|
7
|
-
<p
|
7
|
+
<p><%= AUTHENTASAURUS[:mail][:host] %> Team</p>
|
data/generators/authentasaurus_views/templates/views/authentasaurus_emailer/validation_mail.html.erb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
<p>Dear <%= @name %>,</p>
|
2
2
|
|
3
|
-
<p>Please validate your account at
|
3
|
+
<p>Please validate your account at <%= AUTHENTASAURUS[:mail][:host] %> by visiting this <%= link_to "link", validate_url(:host => AUTHENTASAURUS[:mail][:host] , :code => @vcode) %>.</p>
|
4
4
|
|
5
5
|
<p>Best Regards,</p>
|
6
|
-
<p
|
6
|
+
<p><%= AUTHENTASAURUS[:mail][:host] %> Team</p>
|
@@ -5,7 +5,19 @@ module ActiveRecord::ActsAsAuthenticatable
|
|
5
5
|
end
|
6
6
|
|
7
7
|
module ClassMethods
|
8
|
-
|
8
|
+
|
9
|
+
case AUTHENTASAURUS[:hashing]
|
10
|
+
when "SHA2"
|
11
|
+
require 'digest/sha2'
|
12
|
+
when "SHA1"
|
13
|
+
require 'digest/sha1'
|
14
|
+
when "MD5"
|
15
|
+
require 'digest/md5'
|
16
|
+
else
|
17
|
+
require 'digest/sha2'
|
18
|
+
end
|
19
|
+
|
20
|
+
|
9
21
|
## Authenticates the username and password
|
10
22
|
def authenticate(username, password)
|
11
23
|
user=self.find_by_username username
|
@@ -19,7 +31,18 @@ module ActiveRecord::ActsAsAuthenticatable
|
|
19
31
|
## Encrypts the password using the given seed
|
20
32
|
def encrypt_password(password, password_seed)
|
21
33
|
pass_to_hash=password + "Securasaurus" + password_seed
|
22
|
-
|
34
|
+
|
35
|
+
case AUTHENTASAURUS[:hashing]
|
36
|
+
when "SHA2"
|
37
|
+
Digest::SHA2.hexdigest(pass_to_hash)
|
38
|
+
when "SHA1"
|
39
|
+
Digest::SHA1.hexdigest(pass_to_hash)
|
40
|
+
when "MD5"
|
41
|
+
Digest::MD5.hexdigest(pass_to_hash)
|
42
|
+
else
|
43
|
+
Digest::SHA2.hexdigest(pass_to_hash)
|
44
|
+
end
|
45
|
+
|
23
46
|
end
|
24
47
|
end
|
25
48
|
|
@@ -21,11 +21,17 @@ module ActiveResource::ActsAsAuthenticatable
|
|
21
21
|
last_update = user.attributes.delete "updated_at"
|
22
22
|
local_user = self.sync_to.find_or_initialize_by_username user.username, user.attributes
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
local_user.
|
24
|
+
unless local_user.new_record?
|
25
|
+
last_update_datetime = (last_update.kind_of?(String)) ? (DateTime.parse(last_update)) : (last_update)
|
26
|
+
|
27
|
+
if local_user.updated_at < last_update_datetime
|
28
|
+
local_user.update_attributes user.attributes
|
29
|
+
end
|
30
|
+
else
|
31
|
+
local_user.save
|
28
32
|
end
|
33
|
+
|
34
|
+
user = local_user
|
29
35
|
end
|
30
36
|
end
|
31
37
|
return user
|
@@ -3,7 +3,7 @@ module Authentasaurus::Models::UserInvitation
|
|
3
3
|
base.send :extend, ClassMethods
|
4
4
|
base.send :include, InstanceMethods
|
5
5
|
|
6
|
-
base.send :require, 'digest/
|
6
|
+
base.send :require, 'digest/sha2'
|
7
7
|
base.send :validates_presence_of, :email
|
8
8
|
base.send :validates_uniqueness_of, :email, :scope => :token
|
9
9
|
base.send :validates_format_of, :email, :with => %r{[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}}
|
@@ -25,7 +25,7 @@ module Authentasaurus::Models::UserInvitation
|
|
25
25
|
def create_token
|
26
26
|
return if self.email.nil? || self.email.blank?
|
27
27
|
string_to_hash=self.email + "invitable.olation" + self.email.hash.to_s
|
28
|
-
self.token = Digest::
|
28
|
+
self.token = Digest::SHA2.hexdigest(string_to_hash)
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: authentasaurus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 6
|
9
|
+
- 0
|
10
|
+
version: 0.6.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Omar Mekky
|