cedar_policy 0.6.0-aarch64-linux-gnu

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a9c8b2062cc3bb7c920335588cfd24d853cf7b9117da786fa3a4128d5672f010
4
+ data.tar.gz: e19f200fe286085a3690f818be0635e1186648188c22f558187ae6b65b73c002
5
+ SHA512:
6
+ metadata.gz: d11a91b0c9719e838249bc6e3f2ea80ed0805a81aff6617c4dd8407e70ad9f48f2ceb31c267b7400a23fb6eb6acd7ba1e1dd8095c8889487a7eb79897e462b4e
7
+ data.tar.gz: bc841fd7459c4e3667d9d1efd9cce69b67bc23ce716a7455410446c99c2b8d6dcc14828b516b9bbe1aa4740859a1902246f55d04ee1e242e6f672e1ad82854d4
data/.cross_rubies ADDED
@@ -0,0 +1,35 @@
1
+ 3.0:aarch64-linux-gnu
2
+ 3.0:aarch64-linux-musl
3
+ 3.0:arm64-darwin
4
+ 3.0:x64-mingw32
5
+ 3.0:x86_64-darwin
6
+ 3.0:x86_64-linux-gnu
7
+ 3.0:x86_64-linux-musl
8
+ 3.1:aarch64-linux-gnu
9
+ 3.1:aarch64-linux-musl
10
+ 3.1:arm64-darwin
11
+ 3.1:x64-mingw-ucrt
12
+ 3.1:x86_64-darwin
13
+ 3.1:x86_64-linux-gnu
14
+ 3.1:x86_64-linux-musl
15
+ 3.2:aarch64-linux-gnu
16
+ 3.2:aarch64-linux-musl
17
+ 3.2:arm64-darwin
18
+ 3.2:x64-mingw-ucrt
19
+ 3.2:x86_64-darwin
20
+ 3.2:x86_64-linux-gnu
21
+ 3.2:x86_64-linux-musl
22
+ 3.3:aarch64-linux-gnu
23
+ 3.3:aarch64-linux-musl
24
+ 3.3:arm64-darwin
25
+ 3.3:x64-mingw-ucrt
26
+ 3.3:x86_64-darwin
27
+ 3.3:x86_64-linux-gnu
28
+ 3.3:x86_64-linux-musl
29
+ 3.4:aarch64-linux-gnu
30
+ 3.4:aarch64-linux-musl
31
+ 3.4:arm64-darwin
32
+ 3.4:x64-mingw-ucrt
33
+ 3.4:x86_64-darwin
34
+ 3.4:x86_64-linux-gnu
35
+ 3.4:x86_64-linux-musl
@@ -0,0 +1 @@
1
+ {".":"0.6.0"}
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,15 @@
1
+ AllCops:
2
+ NewCops: enable
3
+ TargetRubyVersion: 3.0
4
+ SuggestExtensions: false
5
+
6
+
7
+ Style/StringLiterals:
8
+ EnforcedStyle: double_quotes
9
+
10
+ Style/StringLiteralsInInterpolation:
11
+ EnforcedStyle: double_quotes
12
+
13
+ Metrics/BlockLength:
14
+ Exclude:
15
+ - 'spec/**/*'
data/CHANGELOG.md ADDED
@@ -0,0 +1,58 @@
1
+ # Changelog
2
+
3
+ ## [0.6.0](https://github.com/elct9620/cedar-policy-rb/compare/v0.5.3...v0.6.0) (2025-06-12)
4
+
5
+
6
+ ### ⚠ BREAKING CHANGES
7
+
8
+ * depends on behavior in RubyGems >= 3.3.22
9
+
10
+ ### Features
11
+
12
+ * adds support for musl libc ([#43](https://github.com/elct9620/cedar-policy-rb/issues/43)) ([563f4f4](https://github.com/elct9620/cedar-policy-rb/commit/563f4f45aeb9f97cccc8aad384702a7ac5dcbc7a))
13
+
14
+
15
+ ### Miscellaneous Chores
16
+
17
+ * release 0.6.0 ([1e18e75](https://github.com/elct9620/cedar-policy-rb/commit/1e18e75574ef30d00cf21de212b88360d718e5b4))
18
+
19
+ ## [0.5.3](https://github.com/elct9620/cedar-policy-rb/compare/v0.5.2...v0.5.3) (2025-06-10)
20
+
21
+
22
+ ### Bug Fixes
23
+
24
+ * pass ruby versions to rb-sys-dock using --ruby-versions flag ([b94f1b7](https://github.com/elct9620/cedar-policy-rb/commit/b94f1b7e9c5d52c4e514c5f8553ccf7a71b25c53))
25
+
26
+ ## [0.5.2](https://github.com/elct9620/cedar-policy-rb/compare/v0.5.1...v0.5.2) (2025-01-22)
27
+
28
+
29
+ ### Bug Fixes
30
+
31
+ * rb-sys version too old cause build failed ([6b58381](https://github.com/elct9620/cedar-policy-rb/commit/6b583811e9d7e8eef3fe1843e7a04f8b9fc6f975))
32
+
33
+ ## [0.5.1](https://github.com/elct9620/cedar-policy-rb/compare/v0.5.0...v0.5.1) (2025-01-22)
34
+
35
+
36
+ ### Bug Fixes
37
+
38
+ * the Gemfile.lock not updated ([8853e74](https://github.com/elct9620/cedar-policy-rb/commit/8853e747188e83aa4ac1bfa7b4d1c361932cdb76))
39
+
40
+ ## [0.5.0](https://github.com/elct9620/cedar-policy-rb/compare/v0.4.0...v0.5.0) (2025-01-22)
41
+
42
+
43
+ ### Features
44
+
45
+ * **deps:** bump rust cedar_policy to v4.3.0 ([9aea4f1](https://github.com/elct9620/cedar-policy-rb/commit/9aea4f130867243b4d61be41a2f8abfd3d021df2))
46
+ * **deps:** update cedar-policy to 4.2.0 ([a7218d7](https://github.com/elct9620/cedar-policy-rb/commit/a7218d7c3af0384cfcdae735f07b06c624ea8002))
47
+
48
+ ## [0.4.0](https://github.com/elct9620/cedar-policy-rb/compare/cedar_policy-v0.3.0...cedar_policy/v0.4.0) (2024-10-06)
49
+
50
+
51
+ ### Features
52
+
53
+ * **deps:** upgrade cedar-policy to v4.1.0 ([61d6fa1](https://github.com/elct9620/cedar-policy-rb/commit/61d6fa1a59ab2edd71972410c1d9d697fde60776))
54
+
55
+
56
+ ### Bug Fixes
57
+
58
+ * commitizen hook file bundled into gem ([b0c9c77](https://github.com/elct9620/cedar-policy-rb/commit/b0c9c77459ec614bfd4698d804969adb9b4bccc1))
data/LICENSE.txt ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2024 ZhengXian Qiu
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,123 @@
1
+ Cedar Policy
2
+ ===
3
+
4
+ Ruby bindings for Cedar policy evaluation engine.
5
+
6
+ ## Installation
7
+
8
+ Install the gem and add to the application's Gemfile by executing:
9
+
10
+ $ bundle add cedar_policy
11
+
12
+ If bundler is not being used to manage dependencies, install the gem by executing:
13
+
14
+ $ gem install cedar_policy
15
+
16
+ ## Usage
17
+
18
+ > [!WARNING]
19
+ > This gem is still under development and the API may change in the future.
20
+
21
+ ### PolicySet
22
+
23
+ Define a policy by Cedar Language:
24
+
25
+ ```ruby
26
+ policy = <<~POLICY
27
+ permit(
28
+ principal == AdminUser::"1",
29
+ action == Action::"view",
30
+ resource
31
+ );
32
+ POLICY
33
+ policy_set = CedarPolicy::PolicySet.new(policy)
34
+ ```
35
+
36
+ > Currently, the single policy is not supported.
37
+
38
+ ### Request
39
+
40
+ Prepare the Entity's ID via `EntityUid` or an object with `#to_hash` method which returns a hash with `:type` and `:id` keys.
41
+
42
+ ```ruby
43
+ principal = CedarPolicy::EntityUid.new("User", "1") # or { type: "User", id: "1" }
44
+ action = CedarPolicy::EntityUid.new("Action", "view")
45
+ resource = CedarPolicy::EntityUid.new("Image", "1")
46
+ ```
47
+
48
+ The `Context` object is used to store the request context. Use `Context` or an object with `#to_hash` method which returns a hash.
49
+
50
+ ```ruby
51
+ ctx = CedarPolicy::Context.new({ ip: "127.0.0.1" }) # or { ip: "127.0.0.1" }
52
+ ```
53
+ > The `Context` object can initialize without any arguments as an empty context.
54
+
55
+ Create a `Request` object with the principal, action, resource, and context.
56
+
57
+ ```ruby
58
+ request = CedarPolicy::Request.new(principal, action, resource, ctx)
59
+ ```
60
+
61
+ ### Entities
62
+
63
+ Define the entities with related this request. It should be an array of `Entity` objects which have `#to_hash` method returns a hash with `:uid`,`:attrs`, and `:parents` keys.
64
+
65
+ ```ruby
66
+ entities = CedarPolicy::Entities.new([
67
+ CedarPolicy::Entity.new(
68
+ CedarPolicy::EntityUid.new("User", "1"),
69
+ { role: "admin" },
70
+ [] # Parents' EntityUid
71
+ ),
72
+ {
73
+ uid: { type: "Image", id: "1" },
74
+ attrs: {},
75
+ parents: []
76
+ }
77
+ ])
78
+ ```
79
+
80
+ ### Authorizer
81
+
82
+ Create an `Authorizer` object and authorize the request with the policy set and entities.
83
+
84
+ ```ruby
85
+ authorizer = CedarPolicy::Authorizer.new
86
+ ```
87
+
88
+ If boolean result is enough, use `#authorize?` method.
89
+
90
+ ```ruby
91
+ authorizer.authorize?(request, policy_set, entities) # => true
92
+ ```
93
+
94
+ If you want to get the decision object, use `#authorize` method.
95
+
96
+ ```ruby
97
+ response = authorizer.authorize(request, policy_set, entities)
98
+ response.decision # => CedarPolicy::Decision::ALLOW
99
+ ```
100
+
101
+ > The diagnostics is not supported yet in the response.
102
+
103
+ ## Roadmap
104
+
105
+ * [ ] Add DSL to improve developer experience
106
+ * [ ] Add batch authorization support
107
+ * [x] Diagnostics return with response
108
+ * [ ] Validator support
109
+ * [ ] Schema support
110
+
111
+ ## Development
112
+
113
+ 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.
114
+
115
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
116
+
117
+ ## Contributing
118
+
119
+ Bug reports and pull requests are welcome on GitHub at https://github.com/elct9620/cedar-policy-rb.
120
+
121
+ ## License
122
+
123
+ The gem is available as open source under the terms of the [Apache-2.0 License](https://opensource.org/license/apache-2-0).
data/Rakefile ADDED
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ require "rb_sys/extensiontask"
13
+
14
+ task build: :compile
15
+
16
+ GEMSPEC = Gem::Specification.load("cedar_policy.gemspec")
17
+
18
+ RbSys::ExtensionTask.new("cedar_policy", GEMSPEC) do |ext|
19
+ ext.lib_dir = "lib/cedar_policy"
20
+ ext.cross_compile = true
21
+ end
22
+
23
+ task default: %i[compile spec rubocop]
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CedarPolicy
4
+ # :nodoc:
5
+ class Context
6
+ def initialize(context = {})
7
+ @context = context
8
+ end
9
+
10
+ def to_hash
11
+ CedarPolicy.deep_serialize(@context)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CedarPolicy
4
+ # :nodoc:
5
+ class Entities
6
+ include Enumerable
7
+
8
+ def initialize(entities = [])
9
+ @entities = Set.new(entities.map do |entity|
10
+ next entity if entity.is_a?(Entity)
11
+
12
+ Entity.new(*entity.values_at(:uid, :attrs, :parents))
13
+ end)
14
+ end
15
+
16
+ def each(&block)
17
+ return enum_for(:each) unless block_given?
18
+
19
+ @entities.each(&block)
20
+ end
21
+
22
+ def to_ary
23
+ @entities.map { |entity| CedarPolicy.deep_serialize(entity) }
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CedarPolicy
4
+ # :nodoc:
5
+ class Entity
6
+ attr_reader :uid, :attrs, :parents
7
+
8
+ def initialize(uid, attrs = {}, parents = [])
9
+ raise ArgumentError unless uid.is_a?(EntityUid) || uid.is_a?(Hash)
10
+
11
+ @uid = if uid.is_a?(EntityUid)
12
+ uid
13
+ else
14
+ EntityUid.new(*uid.values_at(:type, :id))
15
+ end
16
+ @attrs = attrs
17
+ @parents = Set.new(parents)
18
+ end
19
+
20
+ def eql?(other)
21
+ hash == other.hash
22
+ end
23
+
24
+ def hash
25
+ [self.class, @uid].hash
26
+ end
27
+
28
+ def to_hash
29
+ {
30
+ uid: @uid,
31
+ attrs: @attrs,
32
+ parents: @parents.to_a
33
+ }
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CedarPolicy
4
+ # :nodoc:
5
+ class EntityUid
6
+ attr_reader :type_name, :id
7
+
8
+ def initialize(type_name, id)
9
+ @type_name = type_name.to_s
10
+ @id = id.to_s
11
+
12
+ freeze
13
+ end
14
+
15
+ def eql?(other)
16
+ hash == other.hash
17
+ end
18
+ alias == eql?
19
+
20
+ def hash
21
+ [self.class, @type_name, @id].hash
22
+ end
23
+
24
+ def to_str
25
+ "#{@type_name}::#{@id.inspect}"
26
+ end
27
+ alias to_s to_str
28
+ alias inspect to_str
29
+
30
+ def to_hash
31
+ { type: @type_name, id: @id }
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CedarPolicy
4
+ VERSION = "0.6.0"
5
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+ require "set"
5
+
6
+ require_relative "cedar_policy/version"
7
+ require_relative "cedar_policy/cedar_policy"
8
+ require_relative "cedar_policy/entity_uid"
9
+ require_relative "cedar_policy/entity"
10
+ require_relative "cedar_policy/entities"
11
+ require_relative "cedar_policy/context"
12
+
13
+ # :nodoc:
14
+ module CedarPolicy
15
+ class Error < StandardError; end
16
+
17
+ def self.deep_serialize(input)
18
+ input.to_hash.each_with_object({}) do |(key, value), output|
19
+ output[key.to_sym] =
20
+ case value
21
+ when ->(h) { h.respond_to?(:to_hash) } then deep_serialize(value)
22
+ when Array
23
+ value.map { |item| item.respond_to?(:to_hash) ? deep_serialize(item) : item }
24
+ else
25
+ value
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,18 @@
1
+ {
2
+ "release-type": "ruby",
3
+ "last-release-sha": "7d06a6458e9805cc6ec05f456c650708cc9d9e9f",
4
+ "packages": {
5
+ ".":{
6
+ "component": "cedar_policy",
7
+ "include-component-in-tag": false,
8
+ "release-type": "ruby"
9
+ }
10
+ },
11
+ "extra-files": [
12
+ {
13
+ "type": "toml",
14
+ "path": "ext/cedar_policy/Cargo.toml",
15
+ "jsonpath": "$.package.version"
16
+ }
17
+ ]
18
+ }
@@ -0,0 +1,4 @@
1
+ module CedarPolicy
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cedar_policy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.6.0
5
+ platform: aarch64-linux-gnu
6
+ authors:
7
+ - Aotokitsuruya
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2025-06-12 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Ruby bindings for Cedar policy evaluation engine.
14
+ email:
15
+ - contact@aotoki.me
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".cross_rubies"
21
+ - ".release-please-manifest.json"
22
+ - ".rspec"
23
+ - ".rubocop.yml"
24
+ - CHANGELOG.md
25
+ - LICENSE.txt
26
+ - README.md
27
+ - Rakefile
28
+ - lib/cedar_policy.rb
29
+ - lib/cedar_policy/3.0/cedar_policy.so
30
+ - lib/cedar_policy/3.1/cedar_policy.so
31
+ - lib/cedar_policy/3.2/cedar_policy.so
32
+ - lib/cedar_policy/3.3/cedar_policy.so
33
+ - lib/cedar_policy/3.4/cedar_policy.so
34
+ - lib/cedar_policy/context.rb
35
+ - lib/cedar_policy/entities.rb
36
+ - lib/cedar_policy/entity.rb
37
+ - lib/cedar_policy/entity_uid.rb
38
+ - lib/cedar_policy/version.rb
39
+ - release-please-config.json
40
+ - sig/cedar_policy.rbs
41
+ homepage: https://github.com/elct9620/cedar-policy-rb
42
+ licenses:
43
+ - Apache-2.0
44
+ metadata:
45
+ homepage_uri: https://github.com/elct9620/cedar-policy-rb
46
+ source_code_uri: https://github.com/elct9620/cedar-policy-rb
47
+ changelog_uri: https://github.com/elct9620/cedar-policy-rb
48
+ rubygems_mfa_required: 'true'
49
+ post_install_message:
50
+ rdoc_options: []
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '3.0'
58
+ - - "<"
59
+ - !ruby/object:Gem::Version
60
+ version: 3.5.dev
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: 3.3.22
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 3.3.22
69
+ requirements: []
70
+ rubygems_version: 3.5.23
71
+ signing_key:
72
+ specification_version: 4
73
+ summary: Ruby bindings for Cedar policy evaluation engine.
74
+ test_files: []