Return-Path: X-Original-To: apmail-incubator-allura-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-allura-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 43D0D10214 for ; Tue, 17 Sep 2013 19:58:19 +0000 (UTC) Received: (qmail 36767 invoked by uid 500); 17 Sep 2013 19:57:45 -0000 Delivered-To: apmail-incubator-allura-commits-archive@incubator.apache.org Received: (qmail 36533 invoked by uid 500); 17 Sep 2013 19:57:41 -0000 Mailing-List: contact allura-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: allura-dev@incubator.apache.org Delivered-To: mailing list allura-commits@incubator.apache.org Received: (qmail 35943 invoked by uid 99); 17 Sep 2013 19:57:29 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Sep 2013 19:57:29 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 68002A574; Tue, 17 Sep 2013 19:57:29 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: johnsca@apache.org To: allura-commits@incubator.apache.org Date: Tue, 17 Sep 2013 19:58:13 -0000 Message-Id: <5ba390dc041f4957b5133a83bbc456a2@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [46/50] git commit: [#6529] Added docstring and example config entry for login_overlay [#6529] Added docstring and example config entry for login_overlay Signed-off-by: Cory Johns 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 Authored: Mon Sep 16 20:54:58 2013 +0000 Committer: Dave Brondsema 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