fuik 0.13.0 → 0.14.0
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/README.md +6 -11
- data/app/controllers/fuik/downloads_controller.rb +1 -1
- data/config/routes.rb +6 -4
- data/lib/fuik/configuration.rb +7 -0
- data/lib/fuik/dot_access.rb +19 -3
- data/lib/fuik/engine.rb +1 -0
- data/lib/fuik/routing/dashboard_constraint.rb +9 -0
- data/lib/fuik/routing/provider_constraint.rb +4 -14
- data/lib/fuik/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0c28fbd74f30e65da8686f95d2f79fb4633a0bc5a8016eceb9a9241f2f523463
|
|
4
|
+
data.tar.gz: 5855978ebda1cef5cd8ae2388f4cce3893dcfc4090eb1956a1f0b3f4a4192925
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 62dcd0249b6b8b594c75c1833965aa9aebac051131e1fc81dd3740faeb16a6e92eb43a6cf00798f2f1543e37f77f640011b05a0467f8066323c63d00d8c6da02
|
|
7
|
+
data.tar.gz: 4436624e6f1d0e7a90f1af3c6c45871a7e75e6188bc1be051c48b4db37fdd39c0aa19b4a08bd917e5c3ca28df52c8377cf50a2df2d704a71ae24a27e24ed4fbe
|
data/README.md
CHANGED
|
@@ -57,7 +57,8 @@ Visit `/webhooks` to see all received webhooks. Click any event to view all the
|
|
|
57
57
|
|
|
58
58
|
<img alt="Fuik event detail interface" src="https://raw.githubusercontent.com/Rails-Designer/fuik/HEAD/.github/docs/event-detail.jpg" style="max-width: 100%;">
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
> [!IMPORTANT]
|
|
61
|
+
> The dashboard is enabled in development and test only (not authenticated). For production, set `Fuik.configuration.dashboard_enabled = true` and point `Fuik.configuration.events_controller_parent` to a controller that requires authentication.
|
|
61
62
|
|
|
62
63
|
|
|
63
64
|
### Dashboard features
|
|
@@ -140,6 +141,7 @@ Configure Fuik in `config/initializers/fuik.rb`:
|
|
|
140
141
|
Fuik.configure do |config|
|
|
141
142
|
# config.events_controller_parent = "AdministrationController"
|
|
142
143
|
# config.providers_allowed = %w[stripe github postmark]
|
|
144
|
+
# config.dashboard_enabled = Rails.env.development? || Rails.env.test?
|
|
143
145
|
end
|
|
144
146
|
```
|
|
145
147
|
|
|
@@ -241,20 +243,13 @@ end
|
|
|
241
243
|
|
|
242
244
|
### Provider allowlist
|
|
243
245
|
|
|
244
|
-
By default
|
|
245
|
-
- **Development/test**: all providers are allowed
|
|
246
|
-
- **Production/staging**: only providers in `app/webhooks/` are allowed
|
|
247
|
-
|
|
248
|
-
Configure with `Fuik.configuration.providers_allowed`:
|
|
246
|
+
By default all providers are accepted, in every environment. Tighten with `Fuik.configuration.providers_allowed`:
|
|
249
247
|
```ruby
|
|
250
|
-
#
|
|
251
|
-
Fuik.configuration.providers_allowed = :all
|
|
252
|
-
|
|
253
|
-
# Explicit allowlist (overrides directory scan)
|
|
248
|
+
# Explicit allowlist
|
|
254
249
|
Fuik.configuration.providers_allowed = %w[stripe github postmark]
|
|
255
250
|
```
|
|
256
251
|
|
|
257
|
-
|
|
252
|
+
Providers not in the allowlist return `404 Not Found`.
|
|
258
253
|
|
|
259
254
|
|
|
260
255
|
### Event type & ID lookup
|
data/config/routes.rb
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
Fuik::Engine.routes.draw do
|
|
4
|
-
|
|
4
|
+
constraints Fuik::Routing::DashboardConstraint.new do
|
|
5
|
+
root to: "events#index"
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
resources :events, only: %w[index show] do
|
|
8
|
+
resources :retries, only: %w[create]
|
|
9
|
+
end
|
|
10
|
+
resources :downloads, only: %w[create]
|
|
8
11
|
end
|
|
9
|
-
resources :downloads, only: %w[create]
|
|
10
12
|
|
|
11
13
|
post ":provider", to: "webhooks#create", constraints: Fuik::Routing::ProviderConstraint.new
|
|
12
14
|
end
|
data/lib/fuik/configuration.rb
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
module Fuik
|
|
4
4
|
class Configuration
|
|
5
|
+
attr_writer :dashboard_enabled
|
|
5
6
|
attr_accessor :events_controller_parent, :webhooks_controller_parent,
|
|
6
7
|
:providers_allowed, :title, :color_scheme, :webhook_processing_job_class
|
|
7
8
|
|
|
@@ -13,6 +14,12 @@ module Fuik
|
|
|
13
14
|
@title = "Webhooks"
|
|
14
15
|
@color_scheme = :light
|
|
15
16
|
end
|
|
17
|
+
|
|
18
|
+
def dashboard_enabled? = @dashboard_enabled.nil? ? local_env? : @dashboard_enabled
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def local_env? = Rails.env.development? || Rails.env.test?
|
|
16
23
|
end
|
|
17
24
|
|
|
18
25
|
class << self
|
data/lib/fuik/dot_access.rb
CHANGED
|
@@ -12,7 +12,7 @@ module Fuik
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def [](key)
|
|
15
|
-
value =
|
|
15
|
+
value = fetch_value(key)
|
|
16
16
|
|
|
17
17
|
value.is_a?(Hash) ? self.class.new(value) : value
|
|
18
18
|
end
|
|
@@ -22,7 +22,15 @@ module Fuik
|
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def dig(*keys)
|
|
25
|
-
value =
|
|
25
|
+
value = keys.reduce(self) do |current, key|
|
|
26
|
+
case current
|
|
27
|
+
when nil then return nil
|
|
28
|
+
when AccessPayload then current[key]
|
|
29
|
+
when Hash then self.class.new(current)[key]
|
|
30
|
+
when Array then current[key]
|
|
31
|
+
else raise TypeError, "#{current.class} does not have #dig method"
|
|
32
|
+
end
|
|
33
|
+
end
|
|
26
34
|
|
|
27
35
|
value.is_a?(Hash) ? self.class.new(value) : value
|
|
28
36
|
end
|
|
@@ -34,7 +42,7 @@ module Fuik
|
|
|
34
42
|
def method_missing(method_name, *arguments)
|
|
35
43
|
return super unless arguments.empty? && !block_given?
|
|
36
44
|
|
|
37
|
-
value =
|
|
45
|
+
value = fetch_value(method_name)
|
|
38
46
|
value.is_a?(Hash) ? self.class.new(value) : value
|
|
39
47
|
end
|
|
40
48
|
|
|
@@ -43,6 +51,14 @@ module Fuik
|
|
|
43
51
|
end
|
|
44
52
|
|
|
45
53
|
def to_h = @payload
|
|
54
|
+
|
|
55
|
+
private
|
|
56
|
+
|
|
57
|
+
def fetch_value(key)
|
|
58
|
+
found = [key, key.to_s, key.to_s.to_sym].find { @payload.key?(it) }
|
|
59
|
+
|
|
60
|
+
@payload[found] unless found.nil?
|
|
61
|
+
end
|
|
46
62
|
end
|
|
47
63
|
end
|
|
48
64
|
end
|
data/lib/fuik/engine.rb
CHANGED
|
@@ -7,28 +7,18 @@ module Fuik
|
|
|
7
7
|
return true if allow_all?
|
|
8
8
|
return explicit_allowlist.include?(request.params[:provider]) if explicit_allowlist?
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
return Rails.env.local? if providers_allowed == true
|
|
12
|
-
|
|
13
|
-
scanned_allowlist.include?(request.params[:provider])
|
|
10
|
+
false
|
|
14
11
|
end
|
|
15
12
|
|
|
16
13
|
private
|
|
17
14
|
|
|
18
|
-
def allow_all? =
|
|
15
|
+
def allow_all? = providers_allowed.nil? || providers_allowed == true || providers_allowed.in?([:all, "all"])
|
|
19
16
|
|
|
20
|
-
def explicit_allowlist? =
|
|
17
|
+
def explicit_allowlist? = providers_allowed.is_a?(Array)
|
|
21
18
|
|
|
22
|
-
def explicit_allowlist =
|
|
19
|
+
def explicit_allowlist = providers_allowed.to_set
|
|
23
20
|
|
|
24
21
|
def providers_allowed = Fuik.configuration.providers_allowed
|
|
25
|
-
|
|
26
|
-
def scanned_allowlist
|
|
27
|
-
@scanned_allowlist ||= Dir["#{Rails.root}/app/webhooks/*"]
|
|
28
|
-
.select { File.directory?(it) }
|
|
29
|
-
.map { File.basename(it) }
|
|
30
|
-
.to_set
|
|
31
|
-
end
|
|
32
22
|
end
|
|
33
23
|
end
|
|
34
24
|
end
|
data/lib/fuik/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fuik
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.14.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Rails Designer
|
|
@@ -96,6 +96,7 @@ files:
|
|
|
96
96
|
- lib/fuik/engine.rb
|
|
97
97
|
- lib/fuik/errors.rb
|
|
98
98
|
- lib/fuik/notifications.rb
|
|
99
|
+
- lib/fuik/routing/dashboard_constraint.rb
|
|
99
100
|
- lib/fuik/routing/provider_constraint.rb
|
|
100
101
|
- lib/fuik/test_helpers.rb
|
|
101
102
|
- lib/fuik/version.rb
|
|
@@ -165,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
165
166
|
- !ruby/object:Gem::Version
|
|
166
167
|
version: '0'
|
|
167
168
|
requirements: []
|
|
168
|
-
rubygems_version: 4.0.
|
|
169
|
+
rubygems_version: 4.0.24
|
|
169
170
|
specification_version: 4
|
|
170
171
|
summary: A fish trap for webhooks
|
|
171
172
|
test_files: []
|