awesome_acl 0.0.0

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/acl.rb +27 -0
  3. metadata +45 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4bb2566a0a8b6d07bc6a6b22c0e2d1c21e7fa7b1964240ede0d3f95b2bad8ba3
4
+ data.tar.gz: 111ad10f0de73c5448d64f43616aa4a28f4198a315c8b49c22348cfb254266f4
5
+ SHA512:
6
+ metadata.gz: 9ef0c8f6e00e956a1aca5480f7431b597169c2add8d114f4a4da898ee1f0947d314ccfa9d2e9870f32e506e346ab9d251f8134e212fa3892600a9e7f1c76b3a3
7
+ data.tar.gz: 4e4bba1b0878afa0a6a12fd4c09e74014e890f668aa036e7565d8717a7d74436ffac5896050f3187d6f3486bbed95479f7fd2adcd9ac53967a085b6479a2950c
@@ -0,0 +1,27 @@
1
+ module Acl
2
+ class Authorize
3
+ def is_authorized(model)
4
+ allowed_resources = current_overseer.acl_resources
5
+ default_resources = Settings.acl.default_resources
6
+ parsed_json = ActiveSupport::JSON.decode(default_resources)
7
+ resource_ids = {}
8
+ parsed_json.map {|x| resource_ids[x['text']] = {}; x['children'].map {|y| resource_ids[x['text']][y['text']] = y['id'] if y['text'].present?}}
9
+ auth = false
10
+
11
+ if model.is_a?(ActiveRecord::Base)
12
+ resource_model = model.class.name.downcase
13
+ elsif model.is_a?(ActiveRecord::Relation)
14
+ resource_model = model.klass.name.downcase
15
+ else
16
+ resource_model = model.to_s.gsub(':','')
17
+ end
18
+
19
+ if resource_ids[resource_model][action_name].present?
20
+ if allowed_resources.include? resource_ids[resource_model][action_name].to_s
21
+ auth = true
22
+ end
23
+ end
24
+ auth
25
+ end
26
+ end
27
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: awesome_acl
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Pradeep Ketkale
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-05-14 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: ACL
14
+ email: pbketkale@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/acl.rb
20
+ homepage: https://rubygems.org/gems/example
21
+ licenses:
22
+ - MIT
23
+ metadata:
24
+ source_code_uri: https://github.com/example/example
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 2.7.6
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: Awesome Acl is the best!
45
+ test_files: []