authoreyes 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.
@@ -0,0 +1,59 @@
1
+ module Authoreyes
2
+ module Parser
3
+ # The PrivilegeReader handles the part of the authorization DSL in
4
+ # a +privileges+ block. Here, privilege hierarchies are defined.
5
+ class PrivilegesReader
6
+ # TODO handle privileges with separated context
7
+ attr_reader :privileges, :privilege_hierarchy # :nodoc:
8
+
9
+ def initialize # :nodoc:
10
+ @current_privelege = nil
11
+ @current_context = nil
12
+ @privileges = []
13
+ # {priv => [[priv,ctx], ...]}
14
+ @privilege_hierarchy = {}
15
+ end
16
+
17
+ def initialize_copy(from) # :nodoc:
18
+ @privileges = from.privileges.clone
19
+ @privilege_hierarchy = from.privilege_hierarchy.clone
20
+ end
21
+
22
+ def append_privilege(priv) # :nodoc:
23
+ @privileges << priv unless @privileges.include?(priv)
24
+ end
25
+
26
+ # Defines part of a privilege hierarchy. For the given +privilege+,
27
+ # included privileges may be defined in the block (through includes)
28
+ # or as option :+includes+. If the optional context is given,
29
+ # the privilege hierarchy is limited to that context.
30
+ #
31
+ def privilege(privilege, context = nil, options = {}, &block)
32
+ if context.is_a?(Hash)
33
+ options = context
34
+ context = nil
35
+ end
36
+ @current_privelege = privilege
37
+ @current_context = context
38
+ append_privilege privilege
39
+ instance_eval(&block) if block
40
+ includes(*options[:includes]) if options[:includes]
41
+ ensure
42
+ @current_privelege = nil
43
+ @current_context = nil
44
+ end
45
+
46
+ # Specifies +privileges+ that are to be assigned as lower ones. Only to
47
+ # be used inside a privilege block.
48
+ def includes(*privileges)
49
+ raise DSLError,
50
+ "includes only in privilege block" if @current_privelege.nil?
51
+ privileges.each do |priv|
52
+ append_privilege priv
53
+ @privilege_hierarchy[@current_privelege] ||= []
54
+ @privilege_hierarchy[@current_privelege] << [priv, @current_context]
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,3 @@
1
+ module Authoreyes
2
+ VERSION = "0.1.1"
3
+ end
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: authoreyes
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Tektite Software
8
+ - Xavier Bick
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2016-07-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.12'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.12'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '10.0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '10.0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: minitest
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '5.0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '5.0'
56
+ description: |-
57
+ A powerful, modern authorization plugin for Ruby on
58
+ Rails featuring a declarative DSL for centralized
59
+ authorization roles.
60
+ Based on Declarative Authorization.
61
+ email:
62
+ - fxb9500@gmail.com
63
+ executables: []
64
+ extensions: []
65
+ extra_rdoc_files: []
66
+ files:
67
+ - ".gitignore"
68
+ - ".travis.yml"
69
+ - Gemfile
70
+ - LICENSE.txt
71
+ - README.md
72
+ - Rakefile
73
+ - authoreyes.gemspec
74
+ - authorization_rules.dist.rb
75
+ - bin/console
76
+ - bin/setup
77
+ - lib/authoreyes.rb
78
+ - lib/authoreyes/authorization.rb
79
+ - lib/authoreyes/authorization/anonymous_user.rb
80
+ - lib/authoreyes/authorization/attribute.rb
81
+ - lib/authoreyes/authorization/attribute_with_permission.rb
82
+ - lib/authoreyes/authorization/authorization_rule.rb
83
+ - lib/authoreyes/authorization/authorization_rule_set.rb
84
+ - lib/authoreyes/authorization/engine.rb
85
+ - lib/authoreyes/parser.rb
86
+ - lib/authoreyes/parser/authorization_rules_parser.rb
87
+ - lib/authoreyes/parser/dsl_parser.rb
88
+ - lib/authoreyes/parser/priveleges_reader.rb
89
+ - lib/authoreyes/version.rb
90
+ homepage: https://www.github.com/tektite-software/authoreyes
91
+ licenses:
92
+ - MIT
93
+ metadata: {}
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ requirements: []
109
+ rubyforge_project:
110
+ rubygems_version: 2.6.6
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: A modern authorization plugin for Rails.
114
+ test_files: []
115
+ has_rdoc: