rokku 0.5.0 → 0.5.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e35f55f5d2b9be912f462bbd1abda316f5abe55c9e58d5dc27e99c7933004427
4
- data.tar.gz: 1f16e58528cec63db8e6903761256df1ae19149a96610ea49cb201e5d4605dcd
3
+ metadata.gz: fa884cd59034be5f8dfdd5bb0edcb17855b8bc895db41904ace461e56516d762
4
+ data.tar.gz: 1f45e1c95f9400de4667113b2069c2a42f453bf620ef089684fdeef4ff7ea5ec
5
5
  SHA512:
6
- metadata.gz: 6dbd48399c45dc6dd02c679a3f3a529bcd1ac84e165efb2379397646c92e4b30c8091ae8dd7ed2c03bd29c73377b4b6a5587ebef1b12950a6893dbe23e54f7da
7
- data.tar.gz: 5c898ad4c83a58a253056f3612c041c45b3ab9f6242c2e5da144602ef6ff3536487ef5b09997db7fcd0d8afa597112723b08ef1c0c1b2d3361ac835c34d8177f
6
+ metadata.gz: 01b0f07606231dc015998b92c5b44b9f4a64b7e8d676e8e9e41c2511701cd0168078912729118ca1d0af83897f1f053e311919cec39894f29280ace71277121a
7
+ data.tar.gz: 7425475d5a25bc25a9ea05187e3d5dc32e19b601e25d91ce235aeb26ed4d7344331fa14847d2a29f98b0041eeb817e15eac89831ec3ae3f2d828bb99a8356289
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rokku (0.5.0)
4
+ rokku (0.5.1)
5
5
  hanami-controller (~> 1.0)
6
6
  hanami-router (~> 1.0)
7
7
 
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
- authorized?(controller, role, action)
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
- ### ToDo
65
+ ```ruby
66
+ authorized?("post", "update")
67
+ ```
58
68
 
59
- - Add support for author/owner authorizations.
60
- - Add generators for adding authorization rules to existing policies.
69
+ ### Changelog
61
70
 
71
+ #### 0.5.1
62
72
 
63
- ### Changelog
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
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative "../lib/rokku/commands/commands.rb"
@@ -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?("PostController", "admin", "create")
13
+ # Example: redirect_to "/" unless authorized?("post", "admin", "create")
14
14
 
15
- def authorized?(controller, role, action)
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
 
@@ -1,3 +1,3 @@
1
1
  module Rokku
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
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.0
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: 2020-11-22 00:00:00.000000000 Z
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