aserto 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/aserto/auth_client.rb +34 -12
- data/lib/aserto/authorization.rb +3 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a85bdfae072c313aeb99cc709595cd5f7af5b3421bfcb9378cab65c1b3cd24ec
|
4
|
+
data.tar.gz: 3c77d880673ebfa56b9ad47e597a4e2d79e657521f08cc2d8f93d8d3f0bfecf5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb416ffe02aa2cb41e01e71589f059889002fbfcbedef3c7a53ea621c742d482f2fbeb1c6655958514128b574c876d9899183855de0cb42ce0be76c685e374bc
|
7
|
+
data.tar.gz: 0e1b38f26f94c81acf25bc67177c5fba47f25b057d717e995723ad8c7160fd01cd3c4cf8fc6ddc6f7a802f5279a94f567621b63118e9b4dc6f8ac3d3f5a5eec8
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
data/lib/aserto/auth_client.rb
CHANGED
@@ -29,17 +29,27 @@ module Aserto
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def is
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
32
|
+
exec_is(config.decision)
|
33
|
+
end
|
34
|
+
|
35
|
+
def allowed?
|
36
|
+
exec_is("allowed")
|
37
|
+
end
|
38
|
+
|
39
|
+
def visible?
|
40
|
+
exec_is("visible")
|
41
|
+
end
|
42
|
+
|
43
|
+
def enabled?
|
44
|
+
exec_is("enabled")
|
45
|
+
end
|
39
46
|
|
47
|
+
private
|
48
|
+
|
49
|
+
def exec_is(decision)
|
40
50
|
begin
|
41
51
|
response = client.is(
|
42
|
-
|
52
|
+
request_is(decision), { metadata: {
|
43
53
|
"aserto-tenant-id": config.tenant_id,
|
44
54
|
authorization: "basic #{config.authorizer_api_key}"
|
45
55
|
} }
|
@@ -48,12 +58,24 @@ module Aserto
|
|
48
58
|
Aserto.logger.error(e.inspect)
|
49
59
|
false
|
50
60
|
end
|
51
|
-
|
61
|
+
|
62
|
+
decision = response.decisions.find { |el| el.decision == decision }
|
63
|
+
return false unless decision
|
64
|
+
|
65
|
+
decision.is
|
52
66
|
end
|
53
67
|
|
54
|
-
|
68
|
+
def request_is(decision)
|
69
|
+
Aserto::Authorizer::Authorizer::V1::IsRequest.new(
|
70
|
+
{
|
71
|
+
policy_context: policy_context(decision),
|
72
|
+
identity_context: identity_context,
|
73
|
+
resource_context: resource_context
|
74
|
+
}
|
75
|
+
)
|
76
|
+
end
|
55
77
|
|
56
|
-
def policy_context
|
78
|
+
def policy_context(decision)
|
57
79
|
path = Aserto::PolicyPathMapper.execute(config.policy_root, request)
|
58
80
|
Aserto.logger.debug "aserto authorizing: #{path}"
|
59
81
|
|
@@ -61,7 +83,7 @@ module Aserto
|
|
61
83
|
{
|
62
84
|
id: config.policy_id,
|
63
85
|
path: path,
|
64
|
-
decisions: [
|
86
|
+
decisions: [decision]
|
65
87
|
}
|
66
88
|
)
|
67
89
|
end
|
data/lib/aserto/authorization.rb
CHANGED
@@ -16,13 +16,14 @@ module Aserto
|
|
16
16
|
allowed = if enabled?(request)
|
17
17
|
Aserto.logger.debug("Aserto authorization enabled")
|
18
18
|
client = Aserto::AuthClient.new(request)
|
19
|
-
client.is
|
19
|
+
res = client.is
|
20
|
+
Aserto.logger.debug("Aserto authorization result -> allowed: #{res}")
|
21
|
+
res
|
20
22
|
else
|
21
23
|
Aserto.logger.debug("Aserto authorization not enabled")
|
22
24
|
true
|
23
25
|
end
|
24
26
|
|
25
|
-
Aserto.logger.debug("Aserto authorization result -> allowed: #{allowed}")
|
26
27
|
return @app.call env if allowed
|
27
28
|
|
28
29
|
config.on_unauthorized.call(env)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aserto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aserto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-07-
|
11
|
+
date: 2022-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aserto-grpc-authz
|