hasura_handler 0.1.8 → 0.1.9
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b476da389358677671ebee56a1d014dc90779a73ade92eaf6d17f894192d0f4c
|
4
|
+
data.tar.gz: 1aef41672a1832e2abe57e78b260fdef87a0e0147c470898ccb17dfb3b05c791
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 466c57748a94c57040c9d963af6982f4796370c30c582c0c3a306b5d4bc0573f3d3989d6a4e3702f7c162c8e5ad659ee50b032aecc7ac606003dddafca9ffe1a
|
7
|
+
data.tar.gz: 921d0f38484c4d6f127660e7a999ef5af1a0bce82013aeccace3abf1ca6d4468c567d11355dc35691c97480056ad88829cba2dd0984ba9b6208679f62ff2b02b
|
@@ -3,14 +3,14 @@ require_dependency "hasura_handler/application_controller"
|
|
3
3
|
module HasuraHandler
|
4
4
|
class AuthHookController < ApplicationController
|
5
5
|
def get_mode
|
6
|
-
@headers = clean_headers
|
6
|
+
@headers = clean_headers
|
7
7
|
authenticate
|
8
8
|
end
|
9
9
|
|
10
10
|
def post_mode
|
11
11
|
@headers = raw_params['headers'].
|
12
12
|
to_h.
|
13
|
-
map{ |k,v| [
|
13
|
+
map{ |k,v| [standardize_header(k), v] }.
|
14
14
|
to_h
|
15
15
|
|
16
16
|
authenticate
|
@@ -19,7 +19,11 @@ module HasuraHandler
|
|
19
19
|
private
|
20
20
|
|
21
21
|
def authenticate
|
22
|
-
@authenticator = HasuraHandler.
|
22
|
+
@authenticator = HasuraHandler.
|
23
|
+
authenticator.
|
24
|
+
to_s.
|
25
|
+
constantize.
|
26
|
+
new(@headers)
|
23
27
|
|
24
28
|
if @authenticator.success?
|
25
29
|
render json: @authenticator.response, status: 200
|
@@ -27,5 +31,9 @@ module HasuraHandler
|
|
27
31
|
render json: { error: true, message: @authenticator.error_message }, status: 401
|
28
32
|
end
|
29
33
|
end
|
34
|
+
|
35
|
+
def standardize_header(header)
|
36
|
+
"HTTP_#{header.to_s.gsub('-', '_').upcase}"
|
37
|
+
end
|
30
38
|
end
|
31
39
|
end
|
data/lib/hasura_handler.rb
CHANGED
@@ -35,11 +35,11 @@ module HasuraHandler
|
|
35
35
|
yield self
|
36
36
|
|
37
37
|
if (self.events_enabled || self.actions_enabled) && self.auth_key.blank?
|
38
|
-
raise
|
38
|
+
raise 'HasuraHandler requires the auth_key to be configured if actions or events are enabled.'
|
39
39
|
end
|
40
40
|
|
41
41
|
if self.authentication_enabled && self.authenticator.blank?
|
42
|
-
raise
|
42
|
+
raise 'HasuraHandler requires the authenticator to be configured if authentication hook is enabled.'
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
@@ -2,5 +2,13 @@ module HasuraHandler
|
|
2
2
|
class Engine < ::Rails::Engine
|
3
3
|
isolate_namespace HasuraHandler
|
4
4
|
config.generators.api_only = true
|
5
|
+
|
6
|
+
if Rails.version.to_f < 6
|
7
|
+
config.eager_load_paths += Dir[Rails.root.join('app', '{actions,reactions}', '*.rb')]
|
8
|
+
end
|
9
|
+
|
10
|
+
config.to_prepare do
|
11
|
+
Dir[Rails.root.join('app', '{actions,reactions}', '*.rb')].each{ |file| require_dependency file }
|
12
|
+
end
|
5
13
|
end
|
6
14
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module HasuraHandler
|
2
2
|
class EventHandler
|
3
|
+
extend ActiveSupport::DescendantsTracker
|
4
|
+
|
3
5
|
class << self
|
4
6
|
attr_reader :hasura_matchers
|
5
7
|
|
@@ -8,8 +10,8 @@ module HasuraHandler
|
|
8
10
|
allowed_matchers = [:table, :trigger, :op]
|
9
11
|
|
10
12
|
matchers.keys.each do |matcher|
|
11
|
-
raise
|
12
|
-
raise
|
13
|
+
raise "invalid matcher: #{matcher}" unless allowed_matchers.include?(matcher)
|
14
|
+
raise "invalid matcher value for: #{matcher}" unless matchers[matcher].is_a?(String)
|
13
15
|
end
|
14
16
|
|
15
17
|
@hasura_matchers = matchers
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hasura_handler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kaz Walker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|