auth_activity 0.1.1 → 0.1.2
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 +5 -5
- data/app/controllers/auth_activity/auth_events_controller.rb +9 -0
- data/app/controllers/concerns/auth_activity/auth_logger.rb +4 -4
- data/app/models/auth_activity/auth_event.rb +2 -2
- data/app/models/concerns/auth_activity/user.rb +3 -3
- data/app/views/auth_activity/auth_events/_auth_event.html.erb +9 -0
- data/app/views/auth_activity/auth_events/index.html.erb +10 -0
- data/config/routes.rb +1 -0
- data/db/migrate/20180914211658_make_trackable_polymorphic.rb +7 -0
- data/lib/auth_activity/version.rb +1 -1
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 660f5c0c43b067a4b75e18faf11829380074d497
|
4
|
+
data.tar.gz: eb93b6e935017788878059383988d348e0b6fb83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54ddc717fda8d91076fa343e21c5a7e41870fb3bce377bdb7546955fc8569b498a136b352b78e27cb0d9b2c0f036c0190441cb144085b7953868bbdbfff297b8
|
7
|
+
data.tar.gz: ada5300a388250a37c36428f44ef1e494d467ef37e71f084359ea5a8bda24929faa6fcb9bc796b686a1734197df8568b25710b27c43086893545491fff767a74
|
@@ -37,9 +37,9 @@ module AuthActivity
|
|
37
37
|
return unless login_attempt?
|
38
38
|
|
39
39
|
if signed_in?
|
40
|
-
AuthEvent.succesful_login.create(
|
40
|
+
AuthEvent.succesful_login.create(trackable: user, metadata: { email: email })
|
41
41
|
else
|
42
|
-
AuthEvent.failed_login.create(
|
42
|
+
AuthEvent.failed_login.create(trackable: user, metadata: { email: email })
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
@@ -47,7 +47,7 @@ module AuthActivity
|
|
47
47
|
return unless password_request_attempt?
|
48
48
|
|
49
49
|
if user.present?
|
50
|
-
AuthEvent.succesful_password_request.create(
|
50
|
+
AuthEvent.succesful_password_request.create(trackable: user, metadata: { email: email })
|
51
51
|
else
|
52
52
|
AuthEvent.failed_password_request.create(metadata: { email: email })
|
53
53
|
end
|
@@ -57,7 +57,7 @@ module AuthActivity
|
|
57
57
|
if user.present? && logout_action?
|
58
58
|
user = current_user
|
59
59
|
yield
|
60
|
-
AuthEvent.logout.create(
|
60
|
+
AuthEvent.logout.create(trackable: user, metadata: { email: user.email })
|
61
61
|
else
|
62
62
|
yield
|
63
63
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module AuthActivity
|
2
2
|
class AuthEvent < ApplicationRecord
|
3
|
-
belongs_to :
|
3
|
+
belongs_to :trackable, optional: true, polymorphic: true
|
4
4
|
|
5
5
|
enum action_type: {
|
6
6
|
failed_login: 0,
|
@@ -10,7 +10,7 @@ module AuthActivity
|
|
10
10
|
succesful_password_request: 4,
|
11
11
|
user_created: 5,
|
12
12
|
user_destroyed: 6,
|
13
|
-
logout: 7
|
13
|
+
logout: 7
|
14
14
|
}
|
15
15
|
end
|
16
16
|
end
|
@@ -12,16 +12,16 @@ module AuthActivity::User
|
|
12
12
|
private
|
13
13
|
|
14
14
|
def log_created
|
15
|
-
AuthActivity::AuthEvent.user_created.create!(
|
15
|
+
AuthActivity::AuthEvent.user_created.create!(trackable: self)
|
16
16
|
end
|
17
17
|
|
18
18
|
def log_changed
|
19
19
|
return unless changed_auth_attributes.any?
|
20
|
-
AuthActivity::AuthEvent.attributes_changed.create!(
|
20
|
+
AuthActivity::AuthEvent.attributes_changed.create!(trackable: self, metadata: { attributes_changed: filtered_auth_changes } )
|
21
21
|
end
|
22
22
|
|
23
23
|
def log_destroyed
|
24
|
-
AuthActivity::AuthEvent.user_destroyed.create!(
|
24
|
+
AuthActivity::AuthEvent.user_destroyed.create!(trackable: self)
|
25
25
|
end
|
26
26
|
|
27
27
|
def changed_auth_attributes
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<tr id="<%= dom_id(auth_event) %>">
|
2
|
+
<td>
|
3
|
+
<% if auth_event.trackable.present? %>
|
4
|
+
<%= auth_event.trackable.try(:full_name) || auth_event.trackable.id %>
|
5
|
+
<% end %>
|
6
|
+
</td>
|
7
|
+
<td><%= auth_event.action_type %></td>
|
8
|
+
<td><%= l auth_event.created_at %></td>
|
9
|
+
</tr>
|
data/config/routes.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: auth_activity
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michiel Sikkes
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-09-
|
12
|
+
date: 2018-09-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -68,13 +68,17 @@ files:
|
|
68
68
|
- app/assets/javascripts/auth_activity/application.js
|
69
69
|
- app/assets/stylesheets/auth_activity/application.css
|
70
70
|
- app/controllers/auth_activity/application_controller.rb
|
71
|
+
- app/controllers/auth_activity/auth_events_controller.rb
|
71
72
|
- app/controllers/concerns/auth_activity/auth_logger.rb
|
72
73
|
- app/models/auth_activity/application_record.rb
|
73
74
|
- app/models/auth_activity/auth_event.rb
|
74
75
|
- app/models/concerns/auth_activity/user.rb
|
76
|
+
- app/views/auth_activity/auth_events/_auth_event.html.erb
|
77
|
+
- app/views/auth_activity/auth_events/index.html.erb
|
75
78
|
- app/views/layouts/auth_activity/application.html.erb
|
76
79
|
- config/routes.rb
|
77
80
|
- db/migrate/20180914084603_create_auth_activity_auth_events.rb
|
81
|
+
- db/migrate/20180914211658_make_trackable_polymorphic.rb
|
78
82
|
- lib/auth_activity.rb
|
79
83
|
- lib/auth_activity/engine.rb
|
80
84
|
- lib/auth_activity/version.rb
|
@@ -99,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
99
103
|
version: '0'
|
100
104
|
requirements: []
|
101
105
|
rubyforge_project:
|
102
|
-
rubygems_version: 2.
|
106
|
+
rubygems_version: 2.5.2.3
|
103
107
|
signing_key:
|
104
108
|
specification_version: 4
|
105
109
|
summary: Authorisation auditing
|