rbacan 0.1.0 → 0.1.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 +4 -4
- data/Gemfile.lock +4 -5
- data/README.md +17 -2
- data/app/models/rbacan/role.rb +1 -1
- data/lib/generators/install/templates/rbacan.rb +3 -0
- data/lib/generators/rbacan/install_generator.rb +4 -0
- data/lib/rbacan/permittable.rb +1 -1
- data/lib/rbacan/version.rb +1 -1
- data/lib/rbacan.rb +5 -3
- data/rbacan.gemspec +3 -5
- metadata +7 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97b996450c3b0f0535a4c1a544c620171a3d1aed
|
4
|
+
data.tar.gz: b5902253a42b4a642a9ebfafbd71d656d9c066c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5fe1fd23031ca2b755a306b00402d343fb9663d5e624876ec58a6fcba3927521786c5e7dade0b69d533147ab4878e756f68af61846dd3bbda9a84e13628418bd
|
7
|
+
data.tar.gz: 0f02c3af5bdd077b457cc6c3fe9769b51b44a9d408c7e2751361243c8023629c04bbaa8b6526cf22c89abe371263595a3f6e26c8e3d30c75734a58443024c1eb
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rbacan (0.1.
|
5
|
-
activesupport (~> 5.2, >= 5.2.3)
|
4
|
+
rbacan (0.1.1)
|
6
5
|
rails (>= 4.2)
|
7
6
|
|
8
7
|
GEM
|
@@ -75,7 +74,7 @@ GEM
|
|
75
74
|
mini_portile2 (2.4.0)
|
76
75
|
minitest (5.11.3)
|
77
76
|
nio4r (2.4.0)
|
78
|
-
nokogiri (1.10.
|
77
|
+
nokogiri (1.10.4)
|
79
78
|
mini_portile2 (~> 2.4.0)
|
80
79
|
rack (2.0.7)
|
81
80
|
rack-test (1.1.0)
|
@@ -96,7 +95,7 @@ GEM
|
|
96
95
|
rails-dom-testing (2.0.3)
|
97
96
|
activesupport (>= 4.2.0)
|
98
97
|
nokogiri (>= 1.6)
|
99
|
-
rails-html-sanitizer (1.0
|
98
|
+
rails-html-sanitizer (1.2.0)
|
100
99
|
loofah (~> 2.2, >= 2.2.2)
|
101
100
|
railties (5.2.3)
|
102
101
|
actionpack (= 5.2.3)
|
@@ -145,4 +144,4 @@ DEPENDENCIES
|
|
145
144
|
rspec (~> 3.0)
|
146
145
|
|
147
146
|
BUNDLED WITH
|
148
|
-
2.0.
|
147
|
+
2.0.2
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Rbacan
|
2
2
|
|
3
|
-
a Role-based access control tool to
|
3
|
+
a Role-based access control tool to control user access to the functionnalities of your application
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -20,11 +20,21 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
+
```ruby
|
23
24
|
run rails generate rbacan:install
|
25
|
+
```
|
24
26
|
|
25
27
|
copy the content in the generated file db/copy_to_seed.rb in your seeds.rb file
|
26
28
|
you have there all the tools you need to create you roles and permissions
|
27
29
|
|
30
|
+
You might need to configure you user class_name if you're using a different class_name for the user, go to rbacan.rb in your initializers folder and make your change
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
Rbacan.configure do |config|
|
34
|
+
config.permittable_class = "YOUR USER CLASS_NAME"
|
35
|
+
end
|
36
|
+
```
|
37
|
+
|
28
38
|
if you want to assign a role to a user it is simple you just have to do so:
|
29
39
|
|
30
40
|
user = current_user
|
@@ -44,9 +54,14 @@ add this line to your user model:
|
|
44
54
|
include Rbacan::Permittable
|
45
55
|
|
46
56
|
run:
|
57
|
+
|
58
|
+
```ruby
|
47
59
|
rails db:migrate
|
60
|
+
rails db:seed
|
61
|
+
```
|
48
62
|
|
49
63
|
enjoy :D
|
64
|
+
|
50
65
|
## Development
|
51
66
|
|
52
67
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -55,7 +70,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
55
70
|
|
56
71
|
## Contributing
|
57
72
|
|
58
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/hamdi777/
|
73
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/hamdi777/RBACan. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
59
74
|
|
60
75
|
## License
|
61
76
|
|
data/app/models/rbacan/role.rb
CHANGED
@@ -8,6 +8,6 @@ module Rbacan
|
|
8
8
|
has_many :permissions, class_name: Rbacan.permission_class, through: :role_permissions
|
9
9
|
|
10
10
|
has_many :user_roles, class_name: Rbacan.user_role_class, dependent: :destroy
|
11
|
-
has_many :users, through: :user_roles
|
11
|
+
has_many :users, class_name: Rbacan.permittable_class, through: :user_roles
|
12
12
|
end
|
13
13
|
end
|
data/lib/rbacan/permittable.rb
CHANGED
@@ -9,7 +9,7 @@ module Rbacan
|
|
9
9
|
has_many :user_roles, class_name: Rbacan.user_role_class, dependent: :destroy
|
10
10
|
has_many :roles, class_name: Rbacan.role_class, through: :user_roles
|
11
11
|
|
12
|
-
def
|
12
|
+
def assign_role(role_name)
|
13
13
|
assigned_role = Rbacan::Role.find_by_name(role_name)
|
14
14
|
Rbacan::UserRole.create(user_id: self.id, role_id: assigned_role.id)
|
15
15
|
end
|
data/lib/rbacan/version.rb
CHANGED
data/lib/rbacan.rb
CHANGED
@@ -5,9 +5,7 @@ require "rbacan/roles_and_permissions"
|
|
5
5
|
|
6
6
|
module Rbacan
|
7
7
|
mattr_accessor :permittable_class
|
8
|
-
# mattr_accessor :permittable_table
|
9
8
|
@@permittable_class = 'User'
|
10
|
-
# @@permittable_table = @@permittable_class.tableize
|
11
9
|
|
12
10
|
mattr_accessor :role_class
|
13
11
|
mattr_accessor :role_table
|
@@ -43,7 +41,7 @@ module Rbacan
|
|
43
41
|
@@role_permission_class.create(role_id: chosen_role.id, perm_id: given_permission.id)
|
44
42
|
end
|
45
43
|
|
46
|
-
def
|
44
|
+
def assign_role(role_name)
|
47
45
|
assigned_role = Role.find_by_name(role_name)
|
48
46
|
@@user_role_class.create(user_id: self.id, role_id: assigned_role.id)
|
49
47
|
end
|
@@ -53,6 +51,10 @@ module Rbacan
|
|
53
51
|
@@user_role_class.where(user_id: self.id, role_id: removed_role.id).destroy_all
|
54
52
|
end
|
55
53
|
|
54
|
+
def self.configure(&block)
|
55
|
+
yield self
|
56
|
+
end
|
57
|
+
|
56
58
|
class Error < StandardError; end
|
57
59
|
# Your code goes here...
|
58
60
|
end
|
data/rbacan.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["hamdi_amiche@outlook.fr"]
|
11
11
|
|
12
12
|
spec.summary = %q{a gem to give permission access to users looknig back to their roles}
|
13
|
-
spec.description = %q{RBACan is a
|
13
|
+
spec.description = %q{RBACan is a Role-based access control tool to control user access to the functionnalities of your application}
|
14
14
|
spec.homepage = "https://github.com/hamdi777/RBACan"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
@@ -20,8 +20,8 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.metadata["allowed_push_host"] = "https://rubygems.org/profiles/hamdi777"
|
21
21
|
|
22
22
|
spec.metadata["homepage_uri"] = spec.homepage
|
23
|
-
spec.metadata["source_code_uri"] = "
|
24
|
-
spec.metadata["changelog_uri"] = "
|
23
|
+
spec.metadata["source_code_uri"] = "https://rubygems.org/profiles/hamdi777"
|
24
|
+
spec.metadata["changelog_uri"] = "https://rubygems.org/profiles/hamdi777/CHANGELOG.md"
|
25
25
|
else
|
26
26
|
raise "RubyGems 2.0 or newer is required to protect against " \
|
27
27
|
"public gem pushes."
|
@@ -42,6 +42,4 @@ Gem::Specification.new do |spec|
|
|
42
42
|
spec.add_development_dependency "rspec", "~> 3.0"
|
43
43
|
spec.add_development_dependency 'generator_spec', '~> 0.9.4'
|
44
44
|
spec.add_development_dependency 'railties', '~> 5.2', '>= 5.2.3'
|
45
|
-
|
46
|
-
spec.add_dependency 'activesupport', '~> 5.2', '>= 5.2.3'
|
47
45
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbacan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hamdi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-08-
|
11
|
+
date: 2019-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -100,28 +100,8 @@ dependencies:
|
|
100
100
|
- - ">="
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: 5.2.3
|
103
|
-
-
|
104
|
-
|
105
|
-
requirement: !ruby/object:Gem::Requirement
|
106
|
-
requirements:
|
107
|
-
- - "~>"
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: '5.2'
|
110
|
-
- - ">="
|
111
|
-
- !ruby/object:Gem::Version
|
112
|
-
version: 5.2.3
|
113
|
-
type: :runtime
|
114
|
-
prerelease: false
|
115
|
-
version_requirements: !ruby/object:Gem::Requirement
|
116
|
-
requirements:
|
117
|
-
- - "~>"
|
118
|
-
- !ruby/object:Gem::Version
|
119
|
-
version: '5.2'
|
120
|
-
- - ">="
|
121
|
-
- !ruby/object:Gem::Version
|
122
|
-
version: 5.2.3
|
123
|
-
description: RBACan is a gem that provides security to your application functionnalities
|
124
|
-
by a simple method can()
|
103
|
+
description: RBACan is a Role-based access control tool to control user access to
|
104
|
+
the functionnalities of your application
|
125
105
|
email:
|
126
106
|
- hamdi_amiche@outlook.fr
|
127
107
|
executables: []
|
@@ -149,6 +129,7 @@ files:
|
|
149
129
|
- lib/generators/install/templates/create_role_permissions.rb
|
150
130
|
- lib/generators/install/templates/create_roles.rb
|
151
131
|
- lib/generators/install/templates/create_user_roles.rb
|
132
|
+
- lib/generators/install/templates/rbacan.rb
|
152
133
|
- lib/generators/rbacan/install_generator.rb
|
153
134
|
- lib/rbacan.rb
|
154
135
|
- lib/rbacan/engine.rb
|
@@ -162,8 +143,8 @@ licenses:
|
|
162
143
|
metadata:
|
163
144
|
allowed_push_host: https://rubygems.org/profiles/hamdi777
|
164
145
|
homepage_uri: https://github.com/hamdi777/RBACan
|
165
|
-
source_code_uri:
|
166
|
-
changelog_uri:
|
146
|
+
source_code_uri: https://rubygems.org/profiles/hamdi777
|
147
|
+
changelog_uri: https://rubygems.org/profiles/hamdi777/CHANGELOG.md
|
167
148
|
post_install_message:
|
168
149
|
rdoc_options: []
|
169
150
|
require_paths:
|