mistiq 0.0.86 → 0.0.87
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/mistiq.rb +1 -0
- data/lib/mistiq/base.rb +5 -18
- data/lib/mistiq/defaults.rb +31 -17
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NTNiMWMxZWQxNmViNzAwOTc0OTc1NjMzNDAyMmM5ZWQzOWNjMTgzMQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OGNmZGJkZjg0NDg3N2U4MDYwNmVhYjI5NzFhODkyYmIzZWU2NDhlZA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MWVmNGM1ZDZlMDdhNzU5NmU1MzNiNGYyNTEwMzk2ODc5N2JkMTU5MDk4OTAw
|
10
|
+
YzQzNzA4NTIzYzcwMTBjNDE4MGUyZWNjYmZjNWM4ZTI1NjkwY2UyMzQ3YzZk
|
11
|
+
MzAzYzc5ZmQyNjA5NzM1NmI1YTM2YThhYTkyYWNhNzQxMDU4MDI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZjRkZGJhMTA0Y2UyYTdjNmM3MzA1NTMyNWI0ZGM0NDEwNTQ3OTc4ZDUyOTQ0
|
14
|
+
NTMwMTM1MTExMDRmY2RkYmViMWY4MWY0MjI5MTM1ODlkZjk4MGVhZDFiN2Uz
|
15
|
+
YmY5N2I1YmY5ZDE1ZjI4MTJkNzM1MDZjMzI0MjM0NGIyNmJkYzk=
|
data/lib/mistiq.rb
CHANGED
data/lib/mistiq/base.rb
CHANGED
@@ -1,8 +1,4 @@
|
|
1
1
|
module Mistiq
|
2
|
-
def self.included(base)
|
3
|
-
#base.send(:before_filter, :set_guard_on)
|
4
|
-
end
|
5
|
-
|
6
2
|
def initialize
|
7
3
|
super
|
8
4
|
@mode_class = self.class
|
@@ -41,7 +37,7 @@ module Mistiq
|
|
41
37
|
#only disable view if the current controller
|
42
38
|
#and view are the ones that need to be disabled
|
43
39
|
if(current_controller == pair_array[0] && current_action == pair_array[1])
|
44
|
-
disable(pair_array[0],pair_array[1]
|
40
|
+
disable(pair_array[0],pair_array[1])
|
45
41
|
else
|
46
42
|
remove_links(pair_array[0],pair_array[1])
|
47
43
|
end
|
@@ -50,29 +46,20 @@ module Mistiq
|
|
50
46
|
end
|
51
47
|
|
52
48
|
#add a new rule to look out for
|
53
|
-
|
54
|
-
|
55
|
-
def set_guard_rule(condition, consequence, alternate_view='denied')
|
56
|
-
pair = [condition,consequence,alternate_view]
|
49
|
+
def set_guard_rule(condition, consequence)
|
50
|
+
pair = [condition,consequence]
|
57
51
|
@@rules["#{@@count+=1}"] = pair
|
58
52
|
|
59
|
-
puts "New rule has been added: #{consequence}
|
53
|
+
puts "New rule has been added: #{consequence}"
|
60
54
|
end
|
61
55
|
|
62
56
|
private
|
63
57
|
|
64
58
|
#disable both the view and the action (links for the action in other views)
|
65
|
-
def disable(controller,action
|
66
|
-
#disable_view(controller,action,alternate_view)
|
59
|
+
def disable(controller,action)
|
67
60
|
disable_action(controller,action)
|
68
61
|
remove_links(controller,action)
|
69
62
|
end
|
70
|
-
|
71
|
-
#disable the view when url is requested
|
72
|
-
def disable_view(controller,action,alternate_view)
|
73
|
-
render :text => action, :layout => alternate_view
|
74
|
-
puts "Disabled view for action #{action}, controller #{controller}"
|
75
|
-
end
|
76
63
|
|
77
64
|
#disable access to the action/controller by rerouting
|
78
65
|
def disable_action(controller,action)
|
data/lib/mistiq/defaults.rb
CHANGED
@@ -1,24 +1,38 @@
|
|
1
1
|
module Mistiq
|
2
|
-
|
3
|
-
|
2
|
+
#disable all 'action' operations across
|
3
|
+
#the rails application
|
4
|
+
def disable_action_ops(action)
|
5
|
+
Railtie.get_regex_hash.each {
|
6
|
+
|r,p|
|
7
|
+
set_guard_rule(true,r) if r.match(/.*#{action}/)
|
8
|
+
}
|
4
9
|
end
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
+
|
11
|
+
#disable all destroy operations across
|
12
|
+
#the rails application
|
13
|
+
def disable_create_ops()
|
14
|
+
Railtie.get_regex_hash.each {
|
15
|
+
|r,p|
|
16
|
+
set_guard_rule(true,r) if r.match(/.*#add/) || r.match(/.*#create/) || r.match(/.*#new/)
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
#disable all edit operations across
|
21
|
+
#the rails application
|
22
|
+
def disable_update_ops()
|
23
|
+
Railtie.get_regex_hash.each {
|
24
|
+
|r,p|
|
25
|
+
set_guard_rule(true,r) if r.match(/.*#edit/) || r.match(/.*#update/)
|
26
|
+
puts p
|
27
|
+
}
|
10
28
|
end
|
11
|
-
|
12
|
-
#
|
13
|
-
#
|
14
|
-
|
15
|
-
def disable_edit_ops()
|
29
|
+
|
30
|
+
#disable all destroy operations across
|
31
|
+
#the rails application
|
32
|
+
def disable_destroy_ops()
|
16
33
|
Railtie.get_regex_hash.each {
|
17
|
-
|r|
|
18
|
-
if(r.match(/.*#
|
19
|
-
ENV['REGEX'] += Railtie.get_regex_hash[to_disable]+"@@@"
|
34
|
+
|r,p|
|
35
|
+
set_guard_rule(true,r) if r.match(/.*#destroy/) || r.match(/.*#delete/) || r.match(/.*#remove/)
|
20
36
|
}
|
21
|
-
#ENV['REGEX'] += Railtie.get_regex_hash[to_disable]+"@@@"
|
22
|
-
puts "All edit operations have been disabled."
|
23
37
|
end
|
24
38
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mistiq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.87
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrei Papancea
|
@@ -45,5 +45,6 @@ rubyforge_project:
|
|
45
45
|
rubygems_version: 2.1.5
|
46
46
|
signing_key:
|
47
47
|
specification_version: 3
|
48
|
-
summary: Dynamically restrict access to your Rails application
|
48
|
+
summary: Dynamically restrict access to your Rails application and while automatically
|
49
|
+
adjusting the view of your application.
|
49
50
|
test_files: []
|