prauga-flexdoc 0.4.4 → 0.4.5
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 +36 -3
- data/assets/flexdoc.standalone.js +52 -52
- data/lib/prauga/flexdoc/config.rb +2 -2
- data/lib/prauga/flexdoc/host.rb +17 -5
- data/lib/prauga/flexdoc/host_execution.rb +462 -0
- data/lib/prauga/flexdoc/rack_app.rb +137 -1
- data/lib/prauga/flexdoc/rails.rb +4 -3
- data/lib/prauga/flexdoc/version.rb +1 -1
- data/lib/prauga/flexdoc.rb +3 -2
- metadata +17 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e0ad5c0a29615b41c949585cb71e6991d212c10c9edabd9cbddf68d9ed5888d8
|
|
4
|
+
data.tar.gz: 475a99a8da26711567faee0746eda38fbedf36ff5b06f268ad5d075c3cd4bb1f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 51f75c062a8b0d0bfc0f475b85845332f8f04f861e21c8573ab188e4ec0ff29119ce2dab990f07ceed9d79c4c1ad004db90e997d7769eeb17b10bd98c5a6a062
|
|
7
|
+
data.tar.gz: 988e43033ae430ae1388c60fe4d97c7171f4ceb71875df3f2e3fc7168e14284a1037843782c826db61cc2145b64ede757322c9a31fa4ffa03c460de30e63d53e
|
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Prauga FlexDoc for Ruby
|
|
2
2
|
|
|
3
|
-
`prauga-flexdoc` `0.4.
|
|
3
|
+
`prauga-flexdoc` `0.4.5` provides one framework-neutral Ruby 3.2+ host for the canonical FlexDoc renderer, plus thin Rack and Rails integrations.
|
|
4
4
|
|
|
5
5
|
## Rack
|
|
6
6
|
|
|
@@ -22,6 +22,37 @@ run Prauga::FlexDoc::RackApp.new(host)
|
|
|
22
22
|
|
|
23
23
|
The Rack app reconstructs `SCRIPT_NAME + PATH_INFO`, so it also works correctly when mounted beneath another Rack application.
|
|
24
24
|
|
|
25
|
+
## Native host execution (3.3)
|
|
26
|
+
|
|
27
|
+
Ruby can execute Try It requests inside the API host using the same FlexDoc execute envelope used by Node, the Runner, and the other native adapters. Execution is opt-in and requires both `try_it_host_execution: true` and a real executor with a non-empty exact-origin allowlist:
|
|
28
|
+
|
|
29
|
+
```ruby
|
|
30
|
+
executor = Prauga::FlexDoc::HostExecution.new(
|
|
31
|
+
allowed_origins: ["https://api.internal.example"]
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
host = Prauga::FlexDoc::Host.new(
|
|
35
|
+
Prauga::FlexDoc::Config.new(
|
|
36
|
+
path: "/docs",
|
|
37
|
+
spec_url: "/openapi.json",
|
|
38
|
+
try_it_host_execution: true
|
|
39
|
+
),
|
|
40
|
+
host_execution: executor
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
# Configure application authentication/authorization middleware around the
|
|
44
|
+
# FlexDoc subtree first, then acknowledge that boundary explicitly.
|
|
45
|
+
run Prauga::FlexDoc::RackApp.new(host, host_execution_protected: true)
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The Rack transport then owns `POST /docs/__flexdoc/execute`. Without a real executor, FlexDoc advertises `available: false` and the execute path remains a 404.
|
|
49
|
+
|
|
50
|
+
**Fail-closed rule:** when host execution is available, `RackApp.new` raises `ArgumentError` unless `host_execution_protected: true` is supplied. The flag does not authenticate requests; it is an explicit assertion that the surrounding Rack/Rails stack already protects the documentation and execute surface. The outbound origin allowlist is not user authentication.
|
|
51
|
+
|
|
52
|
+
This first native slice supports the canonical JSON and multipart envelopes, Basic/Bearer/OAuth2-bearer and header/query API-key request auth, raw/JSON/binary/urlencoded/GraphQL/form-data bodies, same-origin redirect revalidation, unsafe-header stripping, a 32 MiB inbound envelope bound, a 10 MiB response bound, and a full-response deadline. Host-only cookies, client certificates, Digest/Hawk/NTLM/Kerberos, OAuth 1.0, AWS SigV4, host secrets, and runtime-derived environment are not advertised yet.
|
|
53
|
+
|
|
54
|
+
The Ruby executor blocks link-local/cloud-metadata targets and validates DNS results before connecting. It then pins `Net::HTTP` to one of the validated addresses with `ipaddr=` while retaining the original hostname for the HTTP `Host` header and TLS SNI/certificate verification. Environment proxy routing is disabled for native execution, so the validated destination cannot be bypassed through `http_proxy`/`HTTP_PROXY`. Private-network relaxation is not part of this slice.
|
|
55
|
+
|
|
25
56
|
## Rails
|
|
26
57
|
|
|
27
58
|
In `config/routes.rb`:
|
|
@@ -37,8 +68,10 @@ host = Prauga::FlexDoc::Host.new(
|
|
|
37
68
|
Prauga::FlexDoc::Rails.mount(self, host: host, at: "/docs")
|
|
38
69
|
```
|
|
39
70
|
|
|
40
|
-
Rails already uses Rack, so the Rails helper intentionally mounts the same `RackApp` rather than introducing a Rails-specific renderer host. If `at:` is supplied, it must resolve to the same normalized path as `host.config.path`; the helper raises immediately on a mismatch so the HTML shell cannot point at renderer asset URLs that the mounted Rack app will reject.
|
|
71
|
+
Rails already uses Rack, so the Rails helper intentionally mounts the same `RackApp` rather than introducing a Rails-specific renderer host. If `at:` is supplied, it must resolve to the same normalized path as `host.config.path`; the helper raises immediately on a mismatch so the HTML shell cannot point at renderer asset URLs that the mounted Rack app will reject. Native execution uses that same mounted Rack app, so Rails does not need a separate executor implementation.
|
|
72
|
+
|
|
73
|
+
When the host has native execution available, protect the `/docs` mount with the application's authentication/authorization stack and pass `host_execution_protected: true` to `Prauga::FlexDoc::Rails.mount(...)`. The Rails helper forwards that acknowledgement into `RackApp`; omitting it keeps native execution fail closed.
|
|
41
74
|
|
|
42
75
|
## Packaging
|
|
43
76
|
|
|
44
|
-
The gem packages the exact canonical `flexdoc.standalone.js` and `.css`. CI tests the neutral host, Rack mounting, Rails routing, gem contents, and byte-for-byte renderer parity.
|
|
77
|
+
The gem packages the exact canonical `flexdoc.standalone.js` and `.css`. CI tests the neutral host, Rack mounting, Rails routing, native host execution, gem contents, and byte-for-byte renderer parity.
|