-
Notifications
You must be signed in to change notification settings - Fork 6
26 q2 #631
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
26 q2 #631
Changes from 62 commits
50d01f9
d037dd4
4de7afe
670ec66
0bc767f
6827042
ac63d7c
6257d3b
82223f5
926747f
bf04a20
879024d
8045aed
0c3a617
5fab5ba
d5b4aec
d3d9ec7
c3fac08
9d33b3c
a15d13a
486d0bc
eac9e4a
27ff9ac
65c04d1
64cce3a
cc24531
2a595b0
05c3ca1
fe2b221
d51c6ff
84c9aa1
20d5671
790a85f
cbcc44f
86ae54c
8e324ec
46e8269
c837619
c4ebecd
d5cc3b9
ba55dab
7c34874
d8e0f1e
498b549
4818e82
edbe9cb
3af2434
e02c0f4
da5cda7
1eeb4d5
881f7fd
be3c2b5
4f39efc
2a2b84f
e7a473f
245bb43
7d39040
ba1724d
05df0aa
7bdb949
c041696
176411c
f75499e
88e5809
bcb658d
78a444e
9ec4fe3
3ccfcad
1be8530
7324afd
f3bb637
6613294
2223588
b23b008
dfffb12
8db248d
0bbece7
c3501d6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,3 +19,4 @@ edoc/rest2/v2.json | |
| # node-reladted stuff | ||
| node_modules/ | ||
|
|
||
| .codex | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,3 @@ | ||
| [submodule "edoc/include/xstring"] | ||
| path = edoc/include/xstring | ||
| url = https://github.com/dariok/XStringUtils | ||
| [submodule "edoc/include/wdbmeta"] | ||
| path = edoc/include/wdbmeta | ||
| url = https://github.com/dariok/wdbmeta |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,30 +5,30 @@ | |
| :) | ||
| xquery version "3.1"; | ||
|
|
||
| import module namespace login = "http://exist-db.org/xquery/login" at "resource:org/exist/xquery/modules/persistentlogin/login.xql"; | ||
| import module namespace request = "http://exist-db.org/xquery/request" at "java:org.exist.xquery.functions.request.RequestModule"; | ||
| import module namespace request = "http://exist-db.org/xquery/request" at "java:org.exist.xquery.functions.request.RequestModule"; | ||
|
|
||
| declare namespace config = "https://github.com/dariok/wdbplus/config"; | ||
| declare namespace exist = "http://exist.sourceforge.net/NS/exist"; | ||
| declare namespace meta = "https://github.com/dariok/wdbplus/wdbmeta"; | ||
|
|
||
| declare variable $exist:path external; | ||
| declare variable $exist:resource external; | ||
| declare variable $exist:controller external; | ||
| declare variable $exist:prefix external; | ||
| (: declare variable $exist:root external; :) | ||
| declare variable $exist:root external; | ||
|
|
||
| declare variable $local:isget := request:get-method() = ("GET","get"); | ||
| declare variable $local:config := doc("/db/apps/edoc/config.xml")/config:config; | ||
|
|
||
| util:log("info", request:get-method() || " " || request:get-url() || ' ? ' || request:get-query-string() || " -> resource: " || $exist:resource), | ||
| (: util:log("info", "Request-Path: " || $exist:path || "; Resource: " || $exist:resource || "; Controller: " || $exist:controller || "; Prefix: " || $exist:prefix || "; Root: " || $exist:root), :) | ||
| util:log("info", request:get-method() || " " || request:get-url() || ' ? ' || request:get-query-string() || " → resource: " || $exist:resource), | ||
|
|
||
| (: static HTML page for API documentation should be served directly to make sure it is always accessible :) | ||
| if ( | ||
| ( $local:isget and $exist:resource = ('v2.json', 'apiv2.html') ) | ||
| ) then | ||
| if ( $local:isget and $exist:resource = ('v2.json', 'apiv2.html') ) then | ||
| <dispatch xmlns="http://exist.sourceforge.net/NS/exist"> | ||
| <forward url="{$exist:controller}/rest2/{$exist:resource}"/> | ||
| </dispatch> | ||
|
|
||
| (: login :) | ||
| else if ( $exist:resource = 'login' ) then | ||
| <dispatch xmlns="http://exist.sourceforge.net/NS/exist"> | ||
|
|
@@ -41,23 +41,37 @@ else if ( $exist:resource = 'logout' ) then | |
| <add-parameter name="logout" value="logout" /> | ||
| </forward> | ||
| </dispatch> | ||
|
|
||
| (: REST API :) | ||
| else if ( contains($exist:path, 'api/v2') ) then | ||
| <dispatch xmlns="http://exist.sourceforge.net/NS/exist"> | ||
| <forward url="{$exist:controller}/rest2/api.xq"/> | ||
| <forward url="{$exist:controller}/rest2/api.xq"> | ||
| { | ||
| (: we currently need this workaround here as Jetty snatches all OPTIONS requests before they can be parsed by roaster :) | ||
| if ( request:get-method() = ('options', 'OPTIONS') and $local:config//config:origin = request:get-header('origin') ) | ||
| then ( | ||
| <set-header name="Access-Control-Allow-Origin" value="{ request:get-header('origin') }" />, | ||
| <set-header name="Access-Control-Allow-Methods" value="{ request:get-method() }" />, | ||
| <set-header name="Access-Control-Allow-Headers" value="authorization" />, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The new API-v2 OPTIONS workaround sets Useful? React with 👍 / 👎. |
||
| <set-header name="Access-Control-Allow-Credentials" value="true" /> | ||
| ) | ||
| else () | ||
| } | ||
| </forward> | ||
| </dispatch> | ||
|
|
||
| (: global index.html :) | ||
| else if ( $exist:resource eq '' or $exist:resource eq 'index.html' ) then | ||
| <dispatch xmlns="http://exist.sourceforge.net/NS/exist"> | ||
| <forward url="{$exist:controller}/global/index.html"/> | ||
| </dispatch> | ||
|
|
||
| (: admin pages :) | ||
| else if ( ends-with($exist:resource, ".html") and contains($exist:path, '/admin/') ) then | ||
| <dispatch xmlns="http://exist.sourceforge.net/NS/exist"> | ||
| { login:set-user("wd", substring-before(request:get-uri(), $exist:path), xs:dayTimeDuration("P2D"), false()) } | ||
| <view> | ||
| <set-header name="Cache-Control" value="no-cache"/> | ||
| <forward url="{$exist:controller}/admin/view.xql"> | ||
| </forward> | ||
| <forward url="{$exist:controller}/admin/view.xql"/> | ||
| </view> | ||
| <error-handler> | ||
| <forward url="{$exist:controller}/templates/error-page.html" method="get"/> | ||
|
|
@@ -75,34 +89,41 @@ else if ( ends-with($exist:resource, ".html") ) then | |
| } | ||
| </forward> | ||
| </view> | ||
| <error-handler> | ||
| <forward url="{$exist:controller}/templates/error-page.html" method="get"/> | ||
| <forward url="{$exist:controller}/modules/view.xql"/> | ||
| </error-handler> | ||
| </dispatch> | ||
| (: generic resources :) | ||
| else if ( contains($exist:path, "/$shared/") ) then | ||
| <dispatch xmlns="http://exist.sourceforge.net/NS/exist"> | ||
| <forward url="{$exist:controller}/resources/{substring-after($exist:path, '/$shared/')}"> | ||
| { | ||
| for $header in $local:config//config:header | ||
| return <set-header>{ $header/@* }</set-header> | ||
| } | ||
| </forward> | ||
| </dispatch> | ||
| (: instance specific resources :) | ||
| else if ( contains($exist:path, "/$global/") ) then | ||
| <dispatch xmlns="http://exist.sourceforge.net/NS/exist"> | ||
| <forward url="{$exist:controller}/data/resources/{substring-after($exist:path, '/$global/')}"> | ||
| { | ||
| for $header in $local:config//config:header | ||
| return <set-header>{ $header/@* }</set-header> | ||
| } | ||
| </forward> | ||
| </dispatch> | ||
| else if ( ends-with($exist:path, ".xql") ) then | ||
|
|
||
| (: generic resources :) | ||
| else if ( contains($exist:path, "/$shared/") ) then | ||
| <dispatch xmlns="http://exist.sourceforge.net/NS/exist"> | ||
| <forward url="{$exist:controller}/resources/{substring-after($exist:path, '/$shared/')}"> | ||
| { | ||
| for $header in $local:config//config:header | ||
| return <set-header>{ $header/@* }</set-header> | ||
| } | ||
| </forward> | ||
| </dispatch> | ||
| (: instance specific resources :) | ||
| else if ( contains($exist:path, "/$global/") ) then | ||
| <dispatch xmlns="http://exist.sourceforge.net/NS/exist"> | ||
| <forward url="{$exist:controller}/data/resources/{substring-after($exist:path, '/$global/')}"> | ||
| { | ||
| for $header in $local:config//config:header | ||
| return <set-header>{ $header/@* }</set-header> | ||
| } | ||
| </forward> | ||
| </dispatch> | ||
|
|
||
| else if ( ends-with($exist:path, ".xql") or ends-with($exist:path, ".xq") ) then | ||
| <dispatch xmlns="http://exist.sourceforge.net/NS/exist"> | ||
| <set-header name="Cache-Control" value="no-cache"/> | ||
| <set-attribute name="app-root" value="{$exist:prefix}{$exist:controller}"/> | ||
| </dispatch> | ||
| else | ||
|
|
||
| (: everything else is passed through :) | ||
| else | ||
| <dispatch xmlns="http://exist.sourceforge.net/NS/exist"> | ||
| <cache-control cache="yes"/> | ||
| <set-header name="Cache-Control" value="max-age=604800, must-revalidate"/> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This route guard still whitelists
apiv2.html, but the commit renamed the documentation page tov2.html. Requests for/rest2/v2.htmlnow miss this static forward and fall through to the generic HTML branch, which routes through the app view pipeline instead of serving the docs file directly, so the API documentation page becomes inaccessible.Useful? React with 👍 / 👎.