aserto 0.0.3 → 0.0.6
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 +4 -4
- data/VERSION +1 -1
- data/lib/aserto/auth_client.rb +1 -1
- data/lib/aserto/errors.rb +1 -0
- data/lib/aserto/resource_mapper.rb +21 -1
- data/lib/aserto.rb +11 -1
- 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: ec7d824cf97fc0b087d9f9294e06b82612b74220d2c9960766d83330d56ed1e5
|
4
|
+
data.tar.gz: 334ede61a8065c965dfd26654cb759ff0a9548231cedc057ec97f3647a5f9476
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da1e51625ff33aecce4324ef811cfc5d65e445fd3062ee80a9f810f697a0ca25468170ffa12dceba8c46a02db7a8b80f3d562041e33de888f3a4d13c8d64abf2
|
7
|
+
data.tar.gz: 9300d6917c93634d4a7059579ea20568bcb2c350306ac37c614d188046be94e4587cf50d133a129376c35c140ee5807c245dac180f0a0445690210348510c94a
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.6
|
data/lib/aserto/auth_client.rb
CHANGED
data/lib/aserto/errors.rb
CHANGED
@@ -3,7 +3,27 @@
|
|
3
3
|
module Aserto
|
4
4
|
module ResourceMapper
|
5
5
|
class << self
|
6
|
-
def execute(
|
6
|
+
def execute(request)
|
7
|
+
if defined? ::Rails
|
8
|
+
params = request.params
|
9
|
+
return {} unless params.is_a?(Hash) && !params.empty?
|
10
|
+
|
11
|
+
require_relative "rails/utils"
|
12
|
+
|
13
|
+
route = Aserto::Rails::Utils.route(request)
|
14
|
+
path = route[:path] if route
|
15
|
+
return {} unless path
|
16
|
+
|
17
|
+
fields = path.split("/")
|
18
|
+
.select { |part| part.starts_with?(":") }
|
19
|
+
.map { |field| field.sub(":", "") }
|
20
|
+
return {} if fields.empty?
|
21
|
+
|
22
|
+
require "google/protobuf/well_known_types"
|
23
|
+
return Google::Protobuf::Struct.from_hash(fields.to_h { |field| [field, params[field]] })
|
24
|
+
|
25
|
+
end
|
26
|
+
|
7
27
|
{}
|
8
28
|
end
|
9
29
|
end
|
data/lib/aserto.rb
CHANGED
@@ -51,7 +51,17 @@ module Aserto
|
|
51
51
|
def with_resource_mapper
|
52
52
|
Aserto::ResourceMapper.class_eval do |klass|
|
53
53
|
klass.define_singleton_method(:execute) do |request|
|
54
|
-
|
54
|
+
if block_given?
|
55
|
+
result = yield(request)
|
56
|
+
unless result.is_a?(Hash)
|
57
|
+
raise Aserto::InvalidResourceMapping, "block must return a hash, got: #{result.class}"
|
58
|
+
end
|
59
|
+
|
60
|
+
require "google/protobuf/well_known_types"
|
61
|
+
|
62
|
+
result.transform_keys!(&:to_s)
|
63
|
+
Google::Protobuf::Struct.from_hash(result)
|
64
|
+
end
|
55
65
|
end
|
56
66
|
end
|
57
67
|
end
|
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.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aserto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aserto-grpc-authz
|