-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #340 from eXist-db/mysec
add secure area option to generator
- Loading branch information
Showing
24 changed files
with
359 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
xquery version "3.0"; | ||
|
||
(:~ The controller library contains URL routing functions. | ||
: | ||
: @see http://www.exist-db.org/exist/apps/doc/urlrewrite.xml | ||
:) | ||
|
||
import module namespace login="http://exist-db.org/xquery/login" at "resource:org/exist/xquery/modules/persistentlogin/login.xql"; | ||
|
||
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 $local:login_domain := "org.exist-db.mysec"; | ||
declare variable $local:user := $local:login_domain || '.user'; | ||
|
||
let $logout := request:get-parameter("logout", ()) | ||
let $set-user := login:set-user($local:login_domain, (), false()) | ||
return | ||
if ($exist:path eq '') then | ||
<dispatch xmlns="http://exist.sourceforge.net/NS/exist"> | ||
<redirect url="{request:get-uri()}/"/> | ||
</dispatch> | ||
else if (($exist:path eq "/") or ($logout)) then | ||
(: forward root path to index.xql :) | ||
<dispatch xmlns="http://exist.sourceforge.net/NS/exist"> | ||
<redirect url="index.html"/> | ||
</dispatch> | ||
|
||
else if (ends-with($exist:resource, ".html")) then | ||
(: the html page is run through view.xql to expand templates :) | ||
if (request:get-attribute("org.exist-db.mysec.user")) then | ||
(: secured area checks user status :) | ||
<dispatch xmlns="http://exist.sourceforge.net/NS/exist"> | ||
<view> | ||
<forward url="{$exist:controller}/../modules/view.xql"> | ||
<set-attribute name="isAdmin" value="true"/> | ||
<set-attribute name="$exist:prefix" value="{$exist:prefix}"/> | ||
<set-attribute name="$exist:controller" value="{$exist:controller}"/> | ||
</forward> | ||
</view> | ||
<error-handler> | ||
<forward url="{$exist:controller}/../error-page.html" method="get"/> | ||
<forward url="{$exist:controller}/../modules/view.xql"/> | ||
</error-handler> | ||
</dispatch> | ||
else | ||
<dispatch xmlns="http://exist.sourceforge.net/NS/exist"> | ||
<!-- This forwards the entry to the content page blog.html --> | ||
<forward url="{$exist:controller}/security.html"/> | ||
<!-- This send the page through the templating process --> | ||
<view> | ||
<forward url="{$exist:controller}/../modules/view.xql"> | ||
<set-attribute name="$exist:prefix" value="{$exist:prefix}"/> | ||
<set-attribute name="$exist:controller" value="{$exist:controller}"/> | ||
</forward> | ||
</view> | ||
<error-handler> | ||
<forward url="{$exist:controller}/../error-page.html" method="get"/> | ||
<forward url="{$exist:controller}/../modules/view.xql"/> | ||
</error-handler> | ||
</dispatch> | ||
(: Resource paths starting with $shared are loaded from the shared-resources app :) | ||
else if (contains($exist:path, "/$shared/")) then | ||
<dispatch xmlns="http://exist.sourceforge.net/NS/exist"> | ||
<forward url="/shared-resources/{substring-after($exist:path, '/$shared/')}"> | ||
<set-header name="Cache-Control" value="max-age=3600, must-revalidate"/> | ||
</forward> | ||
</dispatch> | ||
else if (starts-with($exist:path, "/resources")) then | ||
(: images, css are contained in the top /resources/ collection. :) | ||
(: Relative path requests from sub-collections are redirected there :) | ||
<dispatch xmlns="http://exist.sourceforge.net/NS/exist"> | ||
<forward url="{$exist:controller}/../{$exist:path}"/> | ||
</dispatch> | ||
else | ||
(: everything else is passed through :) | ||
<dispatch xmlns="http://exist.sourceforge.net/NS/exist"> | ||
<cache-control cache="yes"/> | ||
</dispatch> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<div xmlns="http://www.w3.org/1999/xhtml" data-template="templates:surround" data-template-with="templates/page.html" data-template-at="content"> | ||
<div class="row"> | ||
<div class="col-md-8"> | ||
<div class="page-header"> | ||
<h1 data-template="config:app-title">Generated page</h1> | ||
</div> | ||
<div class="alert alert-success"> | ||
<p>The page template uses the <a href="http://twitter.github.com/bootstrap/">Bootstrap</a> CSS library for the page layout.</p> | ||
</div> | ||
</div> | ||
<div class="col-md-4"> | ||
<h2>Application Info</h2> | ||
<div data-template="config:app-info"/> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<div xmlns="http://www.w3.org/1999/xhtml" data-template="templates:surround" data-template-with="templates/page.html" data-template-at="content"> | ||
<div class="row"> | ||
<div class="col-md-8"> | ||
<div class="page-header"> | ||
<h1 data-template="config:app-title">Generated page</h1> | ||
</div> | ||
<div class="alert alert-danger"> | ||
<p>This is a protected page. You must be logged in as a user with the appropriate | ||
privileges.</p> | ||
</div> | ||
</div> | ||
<div class="col-md-4"> | ||
<h2>Application Info</h2> | ||
<div data-template="config:app-info"/> | ||
</div> | ||
</div> | ||
</div> |
Oops, something went wrong.