rokku 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +19 -8
- data/bin/rokku +2 -0
- data/lib/rokku.rb +4 -2
- data/lib/rokku/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa884cd59034be5f8dfdd5bb0edcb17855b8bc895db41904ace461e56516d762
|
4
|
+
data.tar.gz: 1f45e1c95f9400de4667113b2069c2a42f453bf620ef089684fdeef4ff7ea5ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01b0f07606231dc015998b92c5b44b9f4a64b7e8d676e8e9e41c2511701cd0168078912729118ca1d0af83897f1f053e311919cec39894f29280ace71277121a
|
7
|
+
data.tar.gz: 7425475d5a25bc25a9ea05187e3d5dc32e19b601e25d91ce235aeb26ed4d7344331fa14847d2a29f98b0041eeb817e15eac89831ec3ae3f2d828bb99a8356289
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -36,6 +36,11 @@ end
|
|
36
36
|
|
37
37
|
## Usage
|
38
38
|
|
39
|
+
### Role based authorization
|
40
|
+
|
41
|
+
#### Prerequisites
|
42
|
+
The current user must be stored in the `@user` variable.
|
43
|
+
|
39
44
|
```ruby
|
40
45
|
rokku -n mightyPoster -p post
|
41
46
|
```
|
@@ -46,25 +51,31 @@ Each application will have its own `app/policies` folders.
|
|
46
51
|
**The command must be run in the project root folder.**
|
47
52
|
|
48
53
|
Once the file is generated, the authorized roles variables in the initialize block for required actions need to be uncommented and supplied with specific roles.
|
49
|
-
|
50
|
-
Then we can check if a user is authorized:
|
54
|
+
For example:
|
51
55
|
|
52
56
|
```ruby
|
53
|
-
|
57
|
+
# @authorized_roles_for_show = []
|
58
|
+
# @authorized_roles_for_index = []
|
59
|
+
# @authorized_roles_for_edit = []
|
60
|
+
@authorized_roles_for_update = ['admin']
|
54
61
|
```
|
55
62
|
|
63
|
+
Then we can check if a user is authorized:
|
56
64
|
|
57
|
-
|
65
|
+
```ruby
|
66
|
+
authorized?("post", "update")
|
67
|
+
```
|
58
68
|
|
59
|
-
|
60
|
-
- Add generators for adding authorization rules to existing policies.
|
69
|
+
### Changelog
|
61
70
|
|
71
|
+
#### 0.5.1
|
62
72
|
|
63
|
-
|
73
|
+
* Readme update
|
74
|
+
* Refactored tests
|
64
75
|
|
65
76
|
#### 0.5.0
|
66
77
|
|
67
|
-
Move from Tachiban
|
78
|
+
* Move from Tachiban
|
68
79
|
|
69
80
|
|
70
81
|
## Development
|
data/bin/rokku
ADDED
data/lib/rokku.rb
CHANGED
@@ -10,11 +10,13 @@ module Hanami
|
|
10
10
|
# and permission to access the action. It returns true or false and
|
11
11
|
# provides the basis for further actions in either case.
|
12
12
|
#
|
13
|
-
# Example: redirect_to "/" unless authorized?("
|
13
|
+
# Example: redirect_to "/" unless authorized?("post", "admin", "create")
|
14
14
|
|
15
|
-
def authorized?(controller,
|
15
|
+
def authorized?(controller, action)
|
16
|
+
role = @user.role
|
16
17
|
Object.const_get(controller.downcase.capitalize + "Policy").new(role).send("#{action.downcase}?")
|
17
18
|
end
|
19
|
+
|
18
20
|
end
|
19
21
|
end
|
20
22
|
|
data/lib/rokku/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rokku
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastjan Hribar
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -138,6 +138,7 @@ files:
|
|
138
138
|
- README.md
|
139
139
|
- Rakefile
|
140
140
|
- bin/console
|
141
|
+
- bin/rokku
|
141
142
|
- bin/setup
|
142
143
|
- lib/rokku.rb
|
143
144
|
- lib/rokku/commands/commands.rb
|