incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [46/50] git commit: [#6529] Added docstring and example config entry for login_overlay
Date Tue, 17 Sep 2013 19:58:13 GMT
[#6529] Added docstring and example config entry for login_overlay

Signed-off-by: Cory Johns <cjohns@slashdotmedia.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/a1779fa8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/a1779fa8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/a1779fa8

Branch: refs/heads/cj/6422
Commit: a1779fa8d9ff0cabf61399fe7911a5d7b351b306
Parents: b930a63
Author: Cory Johns <cjohns@slashdotmedia.com>
Authored: Mon Sep 16 20:54:58 2013 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Mon Sep 16 22:34:13 2013 +0000

----------------------------------------------------------------------
 Allura/allura/lib/helpers.py | 35 +++++++++++++++++++++++++++++++++++
 Allura/development.ini       |  1 +
 2 files changed, 36 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a1779fa8/Allura/allura/lib/helpers.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/helpers.py b/Allura/allura/lib/helpers.py
index 0b92968..76bedbc 100644
--- a/Allura/allura/lib/helpers.py
+++ b/Allura/allura/lib/helpers.py
@@ -1017,6 +1017,41 @@ def daterange(start_date, end_date):
 
 @contextmanager
 def login_overlay(exceptions=None):
+    """
+    Override the default behavior of redirecting to the auth.login_url and
+    instead display an overlay with content from auth.login_fragment_url.
+
+    This is to allow pages that require authentication for any actions but
+    not for the initial view to be more apparent what you will get once
+    logged in.
+
+    This should be wrapped around call to `require_access()` (presumably in
+    the `_check_security()` method on a controller).  The `exceptions` param
+    can be given a list of exposed views to leave with the original behavior.
+
+    For example:
+
+        class MyController(BaseController);
+            def _check_security(self):
+                with login_overlay(exceptions=['process']):
+                    require_access(self.neighborhood, 'register')
+
+            @expose
+            def index(self, *args, **kw):
+                return {}
+
+            @expose
+            def list(self, *args, **kw):
+                return {}
+
+            @expose
+            def process(self, *args, **kw):
+                return {}
+
+    This would show the overlay to unauthenticated users who visit `/`
+    or `/list` but would perform the normal redirect when `/process` is
+    visited.
+    """
     try:
         yield
     except HTTPUnauthorized as e:

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a1779fa8/Allura/development.ini
----------------------------------------------------------------------
diff --git a/Allura/development.ini b/Allura/development.ini
index ee9911b..9cb4b16 100644
--- a/Allura/development.ini
+++ b/Allura/development.ini
@@ -78,6 +78,7 @@ show_export_control = false
 auth.method = local
 # auth.login_url = /auth/
 # auth.logout_url = /auth/logout
+# auth.login_fragment_url = /auth/login_fragment
 
 auth.ldap.server = ldap://localhost
 auth.ldap.suffix = ou=people,dc=localdomain


Mime
View raw message