lesli_shield 1.1.0 → 1.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 +4 -4
- data/Rakefile +3 -1
- data/app/assets/stylesheets/lesli_shield/confirmations.css +1 -1
- data/app/assets/stylesheets/lesli_shield/passwords.css +1 -1
- data/app/controllers/lesli_shield/roles_controller.rb +2 -8
- data/app/controllers/lesli_shield/sessions_controller.rb +35 -61
- data/app/models/concerns/lesli_shield/user_security.rb +1 -1
- data/app/services/lesli_shield/role_action_service.rb +9 -12
- data/app/services/lesli_shield/role_privilege_service.rb +1 -1
- data/app/views/lesli_shield/role/actions/_form.html.erb +0 -4
- data/lib/lesli_shield/version.rb +2 -2
- data/lib/tasks/lesli_shield_tasks.rake +1 -2
- data/readme.md +11 -11
- metadata +1 -1
|
@@ -32,16 +32,10 @@ Building a better future, one line of code at a time.
|
|
|
32
32
|
|
|
33
33
|
module LesliShield
|
|
34
34
|
class RolesController < ApplicationController
|
|
35
|
-
before_action :set_role, only: %i[ show update destroy ]
|
|
35
|
+
before_action :set_role, only: %i[ show update destroy deploy ]
|
|
36
36
|
|
|
37
37
|
def deploy
|
|
38
|
-
|
|
39
|
-
pp params[:id]
|
|
40
|
-
pp params[:id]
|
|
41
|
-
pp params[:id]
|
|
42
|
-
|
|
43
|
-
RolePrivilegeService.new.synchronize(Lesli::Role.first)
|
|
44
|
-
|
|
38
|
+
RolePrivilegeService.new.synchronize(@role.result)
|
|
45
39
|
respond_with_lesli(
|
|
46
40
|
:turbo => stream_notification_success("success")
|
|
47
41
|
)
|
|
@@ -1,64 +1,38 @@
|
|
|
1
1
|
module LesliShield
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
# PATCH/PUT /sessions/1
|
|
39
|
-
def update
|
|
40
|
-
if @session.update(session_params)
|
|
41
|
-
redirect_to @session, notice: "Session was successfully updated.", status: :see_other
|
|
42
|
-
else
|
|
43
|
-
render :edit, status: :unprocessable_entity
|
|
44
|
-
end
|
|
2
|
+
class SessionsController < ApplicationController
|
|
3
|
+
before_action :set_session, only: %i[ show edit update destroy ]
|
|
4
|
+
|
|
5
|
+
# GET /sessions
|
|
6
|
+
def index
|
|
7
|
+
@sessions = respond_with_pagination(UserSessionService.new(current_user, query).index())
|
|
8
|
+
respond_with_lesli(
|
|
9
|
+
:html => @sessions,
|
|
10
|
+
:json => @sessions
|
|
11
|
+
)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# GET /sessions/1
|
|
15
|
+
def show
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# PATCH/PUT /sessions/1
|
|
19
|
+
def update
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# DELETE /sessions/1
|
|
23
|
+
def destroy
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
# Use callbacks to share common setup or constraints between actions.
|
|
29
|
+
def set_session
|
|
30
|
+
@session = Session.find(params.expect(:id))
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Only allow a list of trusted parameters through.
|
|
34
|
+
def session_params
|
|
35
|
+
params.fetch(:session, {})
|
|
36
|
+
end
|
|
45
37
|
end
|
|
46
|
-
|
|
47
|
-
# DELETE /sessions/1
|
|
48
|
-
def destroy
|
|
49
|
-
@session.destroy!
|
|
50
|
-
redirect_to sessions_path, notice: "Session was successfully destroyed.", status: :see_other
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
private
|
|
54
|
-
# Use callbacks to share common setup or constraints between actions.
|
|
55
|
-
def set_session
|
|
56
|
-
@session = Session.find(params.expect(:id))
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
# Only allow a list of trusted parameters through.
|
|
60
|
-
def session_params
|
|
61
|
-
params.fetch(:session, {})
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
38
|
end
|
|
@@ -21,20 +21,21 @@ module LesliShield
|
|
|
21
21
|
|
|
22
22
|
Role::Action.with_deleted.joins(action: :parent)
|
|
23
23
|
.where(:role_id => role_id)
|
|
24
|
+
.order('parents_lesli_resources.route')
|
|
24
25
|
.select(
|
|
25
26
|
:id,
|
|
26
27
|
:role_id,
|
|
27
28
|
:deleted_at,
|
|
28
29
|
"parents_lesli_resources.id as controller_id",
|
|
29
30
|
"parents_lesli_resources.label as controller_name",
|
|
31
|
+
"parents_lesli_resources.route as controller_route",
|
|
30
32
|
"lesli_resources.action as action_name",
|
|
31
33
|
"lesli_resources.id as action_id",
|
|
32
34
|
"case when lesli_shield_role_actions.deleted_at is null then TRUE else FALSE end active"
|
|
33
35
|
).each do |action|
|
|
34
36
|
|
|
35
|
-
unless role_actions.has_key?(action[:
|
|
36
|
-
role_actions[action[:
|
|
37
|
-
list:nil,
|
|
37
|
+
unless role_actions.has_key?(action[:controller_route])
|
|
38
|
+
role_actions[action[:controller_route]] = {
|
|
38
39
|
index: nil,
|
|
39
40
|
show:nil,
|
|
40
41
|
create:nil,
|
|
@@ -43,28 +44,24 @@ module LesliShield
|
|
|
43
44
|
}
|
|
44
45
|
end
|
|
45
46
|
|
|
46
|
-
if action[:action_name] == "list"
|
|
47
|
-
role_actions[action[:controller_name]][:list] = clean(action)
|
|
48
|
-
end
|
|
49
|
-
|
|
50
47
|
if action[:action_name] == "index"
|
|
51
|
-
role_actions[action[:
|
|
48
|
+
role_actions[action[:controller_route]][:index] = clean(action)
|
|
52
49
|
end
|
|
53
50
|
|
|
54
51
|
if action[:action_name] == "show"
|
|
55
|
-
role_actions[action[:
|
|
52
|
+
role_actions[action[:controller_route]][:show] = clean(action)
|
|
56
53
|
end
|
|
57
54
|
|
|
58
55
|
if action[:action_name] == "create"
|
|
59
|
-
role_actions[action[:
|
|
56
|
+
role_actions[action[:controller_route]][:create] = clean(action)
|
|
60
57
|
end
|
|
61
58
|
|
|
62
59
|
if action[:action_name] == "update"
|
|
63
|
-
role_actions[action[:
|
|
60
|
+
role_actions[action[:controller_route]][:update] = clean(action)
|
|
64
61
|
end
|
|
65
62
|
|
|
66
63
|
if action[:action_name] == "destroy"
|
|
67
|
-
role_actions[action[:
|
|
64
|
+
role_actions[action[:controller_route]][:destroy] = clean(action)
|
|
68
65
|
end
|
|
69
66
|
end
|
|
70
67
|
|
|
@@ -62,7 +62,7 @@ module LesliShield
|
|
|
62
62
|
lesli_shield_role_actions.role_id as role_id,
|
|
63
63
|
resource_controllers.route as controller,
|
|
64
64
|
resource_actions.action as action,
|
|
65
|
-
lesli_shield_role_actions.deleted_at
|
|
65
|
+
case when lesli_shield_role_actions.deleted_at is null then TRUE else FALSE end active
|
|
66
66
|
)).with_deleted
|
|
67
67
|
|
|
68
68
|
# get privileges only for the given role, this is needed to sync only modified roles
|
data/lib/lesli_shield/version.rb
CHANGED
|
@@ -39,10 +39,9 @@ namespace :lesli_shield do
|
|
|
39
39
|
|
|
40
40
|
# Drop, build, migrate & seed database (development only)
|
|
41
41
|
def lesli_shield_privileges
|
|
42
|
-
|
|
43
42
|
Lesli::Role.all.each do |role|
|
|
44
|
-
L2.info("LesliShield: Syncing privileges for #{role.name} role.")
|
|
45
43
|
LesliShield::RolePrivilegeService.new(nil).synchronize(role)
|
|
44
|
+
Termline.success("LesliShield: Syncing privileges for #{role.name} role.")
|
|
46
45
|
end
|
|
47
46
|
end
|
|
48
47
|
end
|
data/readme.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
<img width="100" alt="LesliShield logo" src="./app/assets/images/lesli_shield/shield-logo.svg" />
|
|
3
|
-
<h3 align="center">
|
|
3
|
+
<h3 align="center">Users & Security Management for the Lesli Framework.</h3>
|
|
4
4
|
</div>
|
|
5
5
|
|
|
6
6
|
<br />
|
|
@@ -33,15 +33,16 @@
|
|
|
33
33
|
|
|
34
34
|
### Installation
|
|
35
35
|
|
|
36
|
-
```
|
|
36
|
+
```ruby
|
|
37
|
+
|
|
37
38
|
# Add LesliShield engine gem
|
|
38
39
|
bundle add lesli_shield
|
|
39
40
|
|
|
41
|
+
|
|
40
42
|
# Setup & initialize the database
|
|
41
43
|
rake lesli:db:setup
|
|
42
|
-
```
|
|
43
44
|
|
|
44
|
-
|
|
45
|
+
|
|
45
46
|
# Load LesliShield engine
|
|
46
47
|
Rails.application.routes.draw do
|
|
47
48
|
mount LesliShield::Engine => "/shield"
|
|
@@ -49,12 +50,12 @@ end
|
|
|
49
50
|
```
|
|
50
51
|
|
|
51
52
|
<br />
|
|
52
|
-
<hr/>
|
|
53
|
+
<hr />
|
|
53
54
|
<br />
|
|
54
55
|
|
|
55
56
|
### Development
|
|
56
57
|
|
|
57
|
-
```
|
|
58
|
+
```ruby
|
|
58
59
|
# clone the lesli repo inside your engine folder: RailsApp/engines
|
|
59
60
|
git clone https://github.com/LesliTech/LesliShield.git
|
|
60
61
|
|
|
@@ -70,7 +71,7 @@ rake lesli:db:setup
|
|
|
70
71
|
```
|
|
71
72
|
|
|
72
73
|
<br />
|
|
73
|
-
<hr/>
|
|
74
|
+
<hr />
|
|
74
75
|
<br />
|
|
75
76
|
|
|
76
77
|
### Demo
|
|
@@ -86,9 +87,9 @@ rake lesli:db:setup
|
|
|
86
87
|
|
|
87
88
|
### Connect with Lesli
|
|
88
89
|
|
|
89
|
-
* [
|
|
90
|
-
* [
|
|
91
|
-
* [
|
|
90
|
+
* [@LesliTech](https://x.com/LesliTech)
|
|
91
|
+
* [hello@lesli.tech](hello@lesli.tech)
|
|
92
|
+
* [https://www.lesli.tech](https://www.lesli.tech)
|
|
92
93
|
|
|
93
94
|
|
|
94
95
|
### License
|
|
@@ -108,7 +109,6 @@ GNU General Public License for more details.
|
|
|
108
109
|
You should have received a copy of the GNU General Public License
|
|
109
110
|
along with this program. If not, see http://www.gnu.org/licenses/.
|
|
110
111
|
|
|
111
|
-
<br />
|
|
112
112
|
<hr />
|
|
113
113
|
<br />
|
|
114
114
|
<br />
|