chronos_authz 0.0.1 → 0.0.2
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/chronos_authz.gemspec +1 -1
- data/lib/chronos_authz/authorizer.rb +14 -7
- data/lib/chronos_authz/rule.rb +9 -1
- data/lib/chronos_authz/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1648f55f08c683c55c809c5bf10d2316531f8868
|
|
4
|
+
data.tar.gz: e7eefea3adce0441404b5e823503a5cb76951317
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7f8ce956d91ab92d4314bb6601c4fbbd47a7750e3f0b1e8da7e652c6b435961906f89df7cc99937c27d1527a326f9f60831b6a3bdf01286f8664ac26e0c6fe86
|
|
7
|
+
data.tar.gz: 4cab5986d634a5e4e2436136f2222fbdbe89ab87c3f2eee7a57dd7900da7fa4a53fcb9fb671fe03ba1288583df98d0b8754b98758926a3097a1fcd34d4c3ece6
|
data/chronos_authz.gemspec
CHANGED
|
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
|
|
|
7
7
|
s.version = ChronosAuthz::VERSION
|
|
8
8
|
s.authors = ["Marianne Angelie del Mundo", "Rodette Pedro", "JR Respino", "Jayson Uy"]
|
|
9
9
|
s.email = %w(marianne@chronoscloud.com rodette@chronoscloud.com jr@chronoscloud.com jayson@chronoscloud.com)
|
|
10
|
-
s.homepage = "https://github.com/chronoscloud/
|
|
10
|
+
s.homepage = "https://github.com/chronoscloud/chronos-authz"
|
|
11
11
|
s.summary = "A minimal and declarative authorization layer"
|
|
12
12
|
s.description = "A declarative authorization Rack middleware that supports custom authorization logic on a per-resource basis"
|
|
13
13
|
s.license = 'N/A'
|
|
@@ -18,18 +18,25 @@ module ChronosAuthz
|
|
|
18
18
|
|
|
19
19
|
return render_unauthorized if @configuration.strict_mode && matched_acl_record.nil?
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
if !matched_acl_record.nil?
|
|
22
|
+
request = Rack::Request.new(env)
|
|
23
|
+
rule_class = matched_acl_record.try(:rule).try(:constantize) || @configuration.default_rule
|
|
24
|
+
@rule_instance = rule_class.new(request, matched_acl_record)
|
|
25
|
+
|
|
26
|
+
return render_unauthorized if !@rule_instance.request_authorized?
|
|
27
|
+
|
|
28
|
+
RequestStore.store[:chronos_authz_claims] = @rule_instance.user_claims
|
|
29
|
+
end
|
|
26
30
|
|
|
27
|
-
RequestStore.store[:chronos_authz_claims] = rule_instance.user_claims
|
|
28
31
|
status, headers, response = @app.call(env)
|
|
29
32
|
end
|
|
30
33
|
|
|
31
34
|
def render_unauthorized
|
|
32
|
-
if
|
|
35
|
+
if !@rule_instance.json_error.nil?
|
|
36
|
+
return [403, {'Content-Type' => 'application/json'}, [@rule_instance.json_error.to_json]]
|
|
37
|
+
elsif !@rule_instance.html_error.nil?
|
|
38
|
+
return [403, {'Content-Type' => 'text/html'}, [@rule_instance.html_error]]
|
|
39
|
+
elsif @configuration.error_page
|
|
33
40
|
# html = ActionView::Base.new.render(file: @configuration.error_page)
|
|
34
41
|
return [403, {'Content-Type' => 'text/html'}, [File.read(@configuration.error_page)]]
|
|
35
42
|
end
|
data/lib/chronos_authz/rule.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: chronos_authz
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Marianne Angelie del Mundo
|
|
@@ -11,7 +11,7 @@ authors:
|
|
|
11
11
|
autorequire:
|
|
12
12
|
bindir: bin
|
|
13
13
|
cert_chain: []
|
|
14
|
-
date: 2018-
|
|
14
|
+
date: 2018-10-19 00:00:00.000000000 Z
|
|
15
15
|
dependencies:
|
|
16
16
|
- !ruby/object:Gem::Dependency
|
|
17
17
|
name: railties
|
|
@@ -145,7 +145,7 @@ files:
|
|
|
145
145
|
- spec/helpers/custom_rule.rb
|
|
146
146
|
- spec/options_validator_spec.rb
|
|
147
147
|
- spec/spec_helper.rb
|
|
148
|
-
homepage: https://github.com/chronoscloud/
|
|
148
|
+
homepage: https://github.com/chronoscloud/chronos-authz
|
|
149
149
|
licenses:
|
|
150
150
|
- N/A
|
|
151
151
|
metadata: {}
|