You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2014/10/03 17:28:45 UTC
[1/2] git commit: [#7732] make SSLMiddleware generic and usable
Repository: allura
Updated Branches:
refs/heads/db/7732 [created] e923270e0
[#7732] make SSLMiddleware generic and usable
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/197b8fb7
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/197b8fb7
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/197b8fb7
Branch: refs/heads/db/7732
Commit: 197b8fb7f24f393075507088d2f34df62364fe57
Parents: 5536ebe
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Fri Oct 3 03:12:03 2014 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Oct 3 03:12:03 2014 +0000
----------------------------------------------------------------------
Allura/allura/config/middleware.py | 8 ++++----
Allura/allura/lib/custom_middleware.py | 12 ++++--------
Allura/development.ini | 12 +++++++++++-
3 files changed, 19 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/197b8fb7/Allura/allura/config/middleware.py
----------------------------------------------------------------------
diff --git a/Allura/allura/config/middleware.py b/Allura/allura/config/middleware.py
index 91a3575..ab0d400 100644
--- a/Allura/allura/config/middleware.py
+++ b/Allura/allura/config/middleware.py
@@ -144,11 +144,11 @@ def _make_core_app(root, global_conf, full_stack=True, **app_conf):
app = CSRFMiddleware(app, '_session_id')
# Setup the allura SOPs
app = allura_globals_middleware(app)
- # Ensure https for logged in users, http for anonymous ones
- if (asbool(app_conf.get('auth.method', 'local') == 'sfx')
- and config.get('override_root') != 'task'):
+ # Ensure http and https used per config
+ if config.get('override_root') != 'task':
app = SSLMiddleware(app, app_conf.get('no_redirect.pattern'),
- app_conf.get('force_ssl.pattern'))
+ app_conf.get('force_ssl.pattern'),
+ app_conf.get('force_ssl.logged_in'))
# Setup resource manager, widget context SOP
app = ew.WidgetMiddleware(
app,
http://git-wip-us.apache.org/repos/asf/allura/blob/197b8fb7/Allura/allura/lib/custom_middleware.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/custom_middleware.py b/Allura/allura/lib/custom_middleware.py
index 981c602..0b60526 100644
--- a/Allura/allura/lib/custom_middleware.py
+++ b/Allura/allura/lib/custom_middleware.py
@@ -151,7 +151,7 @@ class SSLMiddleware(object):
'Verify the https/http schema is correct'
- def __init__(self, app, no_redirect_pattern=None, force_ssl_pattern=None):
+ def __init__(self, app, no_redirect_pattern=None, force_ssl_pattern=None, force_ssl_logged_in=False):
self.app = app
if no_redirect_pattern:
self._no_redirect_re = re.compile(no_redirect_pattern)
@@ -161,6 +161,7 @@ class SSLMiddleware(object):
self._force_ssl_re = re.compile(force_ssl_pattern)
else:
self._force_ssl_re = re.compile('$$$')
+ self._force_ssl_logged_in = force_ssl_logged_in
def __call__(self, environ, start_response):
req = Request(environ)
@@ -174,13 +175,8 @@ class SSLMiddleware(object):
resp = exc.HTTPNotFound()
secure = req.url.startswith('https://')
srv_path = req.url.split('://', 1)[-1]
- # This SFUSER check is SourceForge-specific (to require all logged-in users to use https)
- # BUT has the additional affect of not forcing SSL for regular Allura instances
- # This is important for local development, at least. When we remove SFUSER (perhaps by requiring SSL everywhere),
- # we can use `no_redirect.pattern = .` for local development to work
- # without SSL
- force_ssl = req.cookies.get(
- 'SFUSER') or self._force_ssl_re.match(environ['PATH_INFO'])
+ force_ssl = (self._force_ssl_logged_in and req.cookies.get('ALLURA-USER')) \
+ or self._force_ssl_re.match(environ['PATH_INFO'])
if not secure and force_ssl:
resp = exc.HTTPFound(location='https://' + srv_path)
elif secure and not force_ssl:
http://git-wip-us.apache.org/repos/asf/allura/blob/197b8fb7/Allura/development.ini
----------------------------------------------------------------------
diff --git a/Allura/development.ini b/Allura/development.ini
index 1ecaefc..43bcc9e 100644
--- a/Allura/development.ini
+++ b/Allura/development.ini
@@ -132,7 +132,17 @@ user_prefs_storage.ldap.fields.display_name = cn
# search.project.additional_display_fields = private, url, title
# search.user.additional_display_fields = email_addresses
-# Set the locations of some static resources
+; To make all pages use ssl:
+; force_ssl.pattern = .
+; To use ssl if and only if a user is logged in:
+; force_ssl.logged_in = true
+; If you set force_ssl.logged_in, you probably want some URLs to be ssl when logged out:
+; force_ssl.pattern = ^/auth|^/[a-z0-9-]+/import_project/ ; import_project uses a login overlay
+; And to permit some URLs to be accessed over http anyway:
+; no_redirect.pattern = ^/nf/\d+/_(ew|static)_/|^/rest/|^/nf/tool_icon_css|^/auth/refresh_repo
+
+
+# Set the locations of some static resources. ("ew" stands for EasyWidgets library)
# script_name is the path that is handled by the application
# url_base is the prefix that references to the static resources should have
no_redirect.pattern = ^/nf/\d+/_(ew|static)_/.*|^/rest/.*
[2/2] git commit: [#7732] .ini cleanup
Posted by br...@apache.org.
[#7732] .ini cleanup
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/e923270e
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/e923270e
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/e923270e
Branch: refs/heads/db/7732
Commit: e923270e0c58abd655606798c2179d2f91cbf196
Parents: 197b8fb
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Fri Oct 3 03:12:22 2014 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Oct 3 03:12:22 2014 +0000
----------------------------------------------------------------------
Allura/allura/lib/app_globals.py | 1 -
Allura/development.ini | 39 ++++-------------------------------
2 files changed, 4 insertions(+), 36 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/e923270e/Allura/allura/lib/app_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/app_globals.py b/Allura/allura/lib/app_globals.py
index 9c80253..2d5136e 100644
--- a/Allura/allura/lib/app_globals.py
+++ b/Allura/allura/lib/app_globals.py
@@ -160,7 +160,6 @@ class Globals(object):
else: # pragma no cover
log.warning('Solr config not set; using in-memory MockSOLR')
self.solr = self.solr_short_timeout = MockSOLR()
- self.use_queue = asbool(config.get('use_queue', False))
# Load login/logout urls; only used for customized logins
self.login_url = config.get('auth.login_url', '/auth/')
http://git-wip-us.apache.org/repos/asf/allura/blob/e923270e/Allura/development.ini
----------------------------------------------------------------------
diff --git a/Allura/development.ini b/Allura/development.ini
index 43bcc9e..46da630 100644
--- a/Allura/development.ini
+++ b/Allura/development.ini
@@ -46,10 +46,9 @@ next=main
[app:main]
use = egg:Allura
full_stack = true
-use_queue = true
site_name = Allura
-domain = forge-allura.apache.org
+domain = localhost
base_url = http://localhost:8080
#lang = ru
@@ -145,19 +144,11 @@ user_prefs_storage.ldap.fields.display_name = cn
# Set the locations of some static resources. ("ew" stands for EasyWidgets library)
# script_name is the path that is handled by the application
# url_base is the prefix that references to the static resources should have
-no_redirect.pattern = ^/nf/\d+/_(ew|static)_/.*|^/rest/.*
-# Pages that must always be SSL even when logged out, such as ones using the login overlay
-force_ssl.pattern = ^/[a-z0-9-]+/import_project/
-# to make all pages use ssl, even when not logged in:
-# force_ssl.pattern = .
-
+# If you use a CDN, put your CDN prefix in the url_base values
ew.script_name = /nf/%(build_key)s/_ew_/
ew.url_base = /nf/%(build_key)s/_ew_/
-# ew.url_base = ://a.fsdn.com/allura/nf/%(build_key)s/_ew_/
static.script_name = /nf/%(build_key)s/_static_/
static.url_base = /nf/%(build_key)s/_static_/
-# static.url_base = ://a.fsdn.com/allura/nf/%(build_key)s/_static_/
-# cdn.url_base = //a.fsdn.com/allura
; Expires header for "static" resources served through allura (e.g. icons, attachments, /nf/tool_icon_css)
files_expires_header_secs = 1209600 ; 2 weeks
@@ -289,28 +280,6 @@ forgemail.return_path = noreply@sf.net
# no need to sleep in devel
ensure_index.sleep = 0
-# If you'd like to fine-tune the individual locations of the cache data dirs
-# for the Cache data, or the Session saves, un-comment the desired settings
-# here:
-#beaker.cache.data_dir = %(here)s/data/cache
-#beaker.session.data_dir = %(here)s/data/sessions
-
-# pick the form for your database
-# %(here) may include a ':' character on Windows environments; this can
-# invalidate the URI when specifying a SQLite db via path name
-# sqlalchemy.url=postgres://username:password@hostname:port/databasename
-# sqlalchemy.url=mysql://username:password@hostname:port/databasename
-
-
-# If you have sqlite, here's a simple default to get you started
-# in development
-
-sqlalchemy.url = sqlite:///%(here)s/devdata.db
-#echo shouldn't be used together with the logging module.
-sqlalchemy.echo = false
-sqlalchemy.echo_pool = false
-sqlalchemy.pool_recycle = 3600
-
# set this to "false" if you are deploying to production and want performance improvements
auto_reload_templates = true
@@ -332,7 +301,7 @@ user_message.max_messages = 20
[app:tool_test]
use = egg:Allura
-override_root=basetest_project_root
+override_root=basetest_project_root ; TurboGears will use controllers/basetest_project_root.py as root controller
full_stack = true
cache_dir = %(here)s/data
@@ -374,7 +343,7 @@ markdown_render_max_length = 999999999
[app:task]
use = main
-override_root = task
+override_root = task ; TurboGears will use controllers/task.py as root controller
# Logging configuration
# Add additional loggers, handlers, formatters here