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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dc17a6fb18f79cbc7f42761ead6902e96c09d3b3
4
- data.tar.gz: 57e17def29d8341147bb81ef427055384914e1f2
3
+ metadata.gz: 1648f55f08c683c55c809c5bf10d2316531f8868
4
+ data.tar.gz: e7eefea3adce0441404b5e823503a5cb76951317
5
5
  SHA512:
6
- metadata.gz: 53887e05e23adf136dff4856aa8bccec32815e36fde7add0012456db29b1a663a6e56c283f61d64298d634d7be42d4ab05a51530dcd795fda839a842ff91df1b
7
- data.tar.gz: 92ccdfc2374509a8fd33132c7dbff4f188925b891f7143c8322e3d179f4660eba2d2336e06f6627b81fd718f198c3a6c66a3d3ce92d50089f4e07c47fdb1d4f9
6
+ metadata.gz: 7f8ce956d91ab92d4314bb6601c4fbbd47a7750e3f0b1e8da7e652c6b435961906f89df7cc99937c27d1527a326f9f60831b6a3bdf01286f8664ac26e0c6fe86
7
+ data.tar.gz: 4cab5986d634a5e4e2436136f2222fbdbe89ab87c3f2eee7a57dd7900da7fa4a53fcb9fb671fe03ba1288583df98d0b8754b98758926a3097a1fcd34d4c3ece6
@@ -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/chronoscloud-authz"
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
- request = Rack::Request.new(env)
22
- rule_class = matched_acl_record.try(:rule).try(:constantize) || @configuration.default_rule
23
- rule_instance = rule_class.new(request, matched_acl_record)
24
-
25
- return render_unauthorized if !rule_instance.request_authorized?
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 @configuration.error_page
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
@@ -15,6 +15,14 @@ module ChronosAuthz
15
15
  def request_authorized?
16
16
  false
17
17
  end
18
-
18
+
19
+ def json_error
20
+ nil
21
+ end
22
+
23
+ def html_error
24
+ nil
25
+ end
26
+
19
27
  end
20
28
  end
@@ -1,3 +1,3 @@
1
1
  module ChronosAuthz
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
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.1
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-08-10 00:00:00.000000000 Z
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/chronoscloud-authz
148
+ homepage: https://github.com/chronoscloud/chronos-authz
149
149
  licenses:
150
150
  - N/A
151
151
  metadata: {}