cedar_policy 0.1.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.
- checksums.yaml +7 -0
- data/.cross_rubies +20 -0
- data/.rspec +3 -0
- data/.rubocop.yml +13 -0
- data/Cargo.lock +1315 -0
- data/Cargo.toml +7 -0
- data/LICENSE.txt +201 -0
- data/README.md +70 -0
- data/Rakefile +23 -0
- data/ext/cedar_policy/Cargo.toml +14 -0
- data/ext/cedar_policy/extconf.rb +6 -0
- data/ext/cedar_policy/src/authorizer.rs +39 -0
- data/ext/cedar_policy/src/decision.rs +57 -0
- data/ext/cedar_policy/src/entities.rs +37 -0
- data/ext/cedar_policy/src/entity.rs +70 -0
- data/ext/cedar_policy/src/entity_uid.rs +54 -0
- data/ext/cedar_policy/src/error.rs +22 -0
- data/ext/cedar_policy/src/lib.rs +30 -0
- data/ext/cedar_policy/src/policy_set.rs +40 -0
- data/ext/cedar_policy/src/request.rs +55 -0
- data/ext/cedar_policy/src/response.rs +25 -0
- data/lib/cedar_policy/version.rb +5 -0
- data/lib/cedar_policy.rb +9 -0
- data/sig/cedar_policy.rbs +4 -0
- metadata +71 -0
@@ -0,0 +1,55 @@
|
|
1
|
+
use cedar_policy::{Context, Request};
|
2
|
+
use magnus::{function, method, Error, Module, Object, RModule, Ruby};
|
3
|
+
use std::convert::Into;
|
4
|
+
|
5
|
+
use crate::entity_uid::REntityUid;
|
6
|
+
|
7
|
+
#[magnus::wrap(class = "CedarPolicy::Request")]
|
8
|
+
pub struct RRequest(Request);
|
9
|
+
|
10
|
+
impl RRequest {
|
11
|
+
fn new(
|
12
|
+
principal: Option<&REntityUid>,
|
13
|
+
action: Option<&REntityUid>,
|
14
|
+
resource: Option<&REntityUid>,
|
15
|
+
) -> Self {
|
16
|
+
Self(
|
17
|
+
Request::new(
|
18
|
+
principal.map(&Into::into),
|
19
|
+
action.map(&Into::into),
|
20
|
+
resource.map(&Into::into),
|
21
|
+
Context::empty(),
|
22
|
+
None,
|
23
|
+
)
|
24
|
+
.unwrap(),
|
25
|
+
)
|
26
|
+
}
|
27
|
+
|
28
|
+
fn principal(&self) -> Option<REntityUid> {
|
29
|
+
self.0.principal().map(&Into::into)
|
30
|
+
}
|
31
|
+
|
32
|
+
fn action(&self) -> Option<REntityUid> {
|
33
|
+
self.0.action().map(&Into::into)
|
34
|
+
}
|
35
|
+
|
36
|
+
fn resource(&self) -> Option<REntityUid> {
|
37
|
+
self.0.resource().map(&Into::into)
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
impl<'a> From<&'a RRequest> for &'a Request {
|
42
|
+
fn from(request: &'a RRequest) -> Self {
|
43
|
+
&request.0
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
pub fn init(ruby: &Ruby, module: &RModule) -> Result<(), Error> {
|
48
|
+
let class = module.define_class("Request", ruby.class_object())?;
|
49
|
+
class.define_singleton_method("new", function!(RRequest::new, 3))?;
|
50
|
+
class.define_method("principal", method!(RRequest::principal, 0))?;
|
51
|
+
class.define_method("action", method!(RRequest::action, 0))?;
|
52
|
+
class.define_method("resource", method!(RRequest::resource, 0))?;
|
53
|
+
|
54
|
+
Ok(())
|
55
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
use cedar_policy::Response;
|
2
|
+
use magnus::{method, Error, Module, RModule, Ruby};
|
3
|
+
|
4
|
+
use crate::decision::RDecision;
|
5
|
+
|
6
|
+
#[magnus::wrap(class = "CedarPolicy::Response")]
|
7
|
+
pub struct RResponse(Response);
|
8
|
+
|
9
|
+
impl RResponse {
|
10
|
+
fn decision(&self) -> RDecision {
|
11
|
+
self.0.decision().into()
|
12
|
+
}
|
13
|
+
}
|
14
|
+
|
15
|
+
impl From<Response> for RResponse {
|
16
|
+
fn from(response: Response) -> Self {
|
17
|
+
RResponse(response)
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
pub fn init(ruby: &Ruby, module: &RModule) -> Result<(), Error> {
|
22
|
+
let class = module.define_class("Response", ruby.class_object())?;
|
23
|
+
class.define_method("decision", method!(RResponse::decision, 0))?;
|
24
|
+
Ok(())
|
25
|
+
}
|
data/lib/cedar_policy.rb
ADDED
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cedar_policy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Aotokitsuruya
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-08-13 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
|
+
- ext/cedar_policy/Cargo.toml
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- ".cross_rubies"
|
22
|
+
- ".rspec"
|
23
|
+
- ".rubocop.yml"
|
24
|
+
- Cargo.lock
|
25
|
+
- Cargo.toml
|
26
|
+
- LICENSE.txt
|
27
|
+
- README.md
|
28
|
+
- Rakefile
|
29
|
+
- ext/cedar_policy/Cargo.toml
|
30
|
+
- ext/cedar_policy/extconf.rb
|
31
|
+
- ext/cedar_policy/src/authorizer.rs
|
32
|
+
- ext/cedar_policy/src/decision.rs
|
33
|
+
- ext/cedar_policy/src/entities.rs
|
34
|
+
- ext/cedar_policy/src/entity.rs
|
35
|
+
- ext/cedar_policy/src/entity_uid.rs
|
36
|
+
- ext/cedar_policy/src/error.rs
|
37
|
+
- ext/cedar_policy/src/lib.rs
|
38
|
+
- ext/cedar_policy/src/policy_set.rs
|
39
|
+
- ext/cedar_policy/src/request.rs
|
40
|
+
- ext/cedar_policy/src/response.rs
|
41
|
+
- lib/cedar_policy.rb
|
42
|
+
- lib/cedar_policy/version.rb
|
43
|
+
- sig/cedar_policy.rbs
|
44
|
+
homepage: https://github.com/elct9620/cedar-policy-rb
|
45
|
+
licenses:
|
46
|
+
- Apache-2.0
|
47
|
+
metadata:
|
48
|
+
homepage_uri: https://github.com/elct9620/cedar-policy-rb
|
49
|
+
source_code_uri: https://github.com/elct9620/cedar-policy-rb
|
50
|
+
changelog_uri: https://github.com/elct9620/cedar-policy-rb
|
51
|
+
rubygems_mfa_required: 'true'
|
52
|
+
post_install_message:
|
53
|
+
rdoc_options: []
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 3.0.0
|
61
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 3.3.11
|
66
|
+
requirements: []
|
67
|
+
rubygems_version: 3.5.9
|
68
|
+
signing_key:
|
69
|
+
specification_version: 4
|
70
|
+
summary: Ruby bindings for Cedar policy evaluation engine.
|
71
|
+
test_files: []
|