diff mbox

[Branch,~linaro-validation/lava-server/trunk] Rev 415: Get Crowd auth settings using django-debian package.

Message ID 20130806095426.8406.51145.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Paul Sokolovsky Aug. 6, 2013, 9:54 a.m. UTC
Merge authors:
  Paul Sokolovsky (pfalcon)
Related merge proposals:
  https://code.launchpad.net/~pfalcon/lava-server/crowd-settings-final/+merge/177825
  proposed by: Paul Sokolovsky (pfalcon)
  review: Approve - Antonio Terceiro (terceiro)
------------------------------------------------------------
revno: 415 [merge]
committer: Paul Sokolovsky <paul.sokolovsky@linaro.org>
branch nick: lava-server
timestamp: Tue 2013-08-06 12:52:32 +0300
message:
  Get Crowd auth settings using django-debian package.
  
  Main settings are in /srv/lava/instances/*/etc/lava-server/settings.conf
  and credentials are in /srv/lava/instances/*/etc/lava-server/crowd.conf
removed:
  lava_server/settings/crowd.py
modified:
  lava_server/context_processors.py
  lava_server/settings/common.py
  lava_server/settings/debian.py


--
lp:lava-server
https://code.launchpad.net/~linaro-validation/lava-server/trunk

You are subscribed to branch lp:lava-server.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-server/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'lava_server/context_processors.py'
--- lava_server/context_processors.py	2013-07-23 13:29:45 +0000
+++ lava_server/context_processors.py	2013-07-30 15:28:17 +0000
@@ -47,7 +47,7 @@ 
                 lava_server.__version__, hint=lava_server)}}
 
 def openid_available(request):
-    openid_enabled = "django_openid_auth.auth.OpenIDBackend" in lava_server.settings.common.AUTHENTICATION_BACKENDS
+    openid_enabled = "django_openid_auth.auth.OpenIDBackend" in settings.AUTHENTICATION_BACKENDS
     # Check if we use generic OpenID or Launchpad.net
     openid_url = getattr(settings, "OPENID_SSO_SERVER_URL", "")
     if "ubuntu.com" in openid_url or "launchpad.net" in openid_url:

=== modified file 'lava_server/settings/common.py'
--- lava_server/settings/common.py	2013-07-25 23:06:24 +0000
+++ lava_server/settings/common.py	2013-08-05 17:39:08 +0000
@@ -1,4 +1,4 @@ 
-# Copyright (C) 2010, 2011 Linaro Limited
+# Copyright (C) 2010-2013 Linaro Limited
 #
 # Author: Zygmunt Krynicki <zygmunt.krynicki@linaro.org>
 #
@@ -16,7 +16,15 @@ 
 # You should have received a copy of the GNU Affero General Public License
 # along with LAVA Server.  If not, see <http://www.gnu.org/licenses/>.
 
-import lava_server.settings.crowd as crowd
+
+# WARNING:
+# Never edit this file on a production system!
+# Any changes can be overwritten at any time by upgrade or any
+# system management operation. All production config changes
+# should happen strictly to etc/settings.conf, etc. files.
+# All comments below are strictly for development usage and
+# reference.
+
 
 # Administrator contact, used for sending
 # emergency email when something breaks
@@ -124,13 +132,6 @@ 
     'google_analytics',
 ]
 
-if crowd.enabled:
-    try:
-        import crowdrest
-        INSTALLED_APPS.append('crowdrest')
-    except ImportError:
-        pass
-
 try:
     import devserver
     INSTALLED_APPS += ['devserver']
@@ -166,13 +167,6 @@ 
 from openid import oidutil
 oidutil.log = lambda msg, level=0: None
 
-# Configuration settings for crowdrest.backend.CrowdRestBackend
-# Alternatively, can be set in production config for particular installed
-# instance.
-AUTH_CROWD_APPLICATION_USER = crowd.settings.get('username', 'appname')
-AUTH_CROWD_APPLICATION_PASSWORD = crowd.settings.get('password', 'apppass')
-AUTH_CROWD_SERVER_REST_URI = crowd.settings.get('apiurl', 'https://crowd-server/crowd/rest/usermanagement/1')
-
 RESTRUCTUREDTEXT_FILTER_SETTINGS = {"initial_header_level": 4}
 
 # Add google analytics model.

=== removed file 'lava_server/settings/crowd.py'
--- lava_server/settings/crowd.py	2013-07-25 02:09:32 +0000
+++ lava_server/settings/crowd.py	1970-01-01 00:00:00 +0000
@@ -1,24 +0,0 @@ 
-import os
-import yaml
-
-search_path = [
-    '/etc/lava-server/crowd.yaml'
-]
-
-if "VIRTUAL_ENV" in os.environ:
-    search_path.insert(0, os.path.join(os.environ["VIRTUAL_ENV"],
-                                       'etc/lava-server/crowd.yaml'))
-
-config_file = None
-
-for f in search_path:
-    if os.path.exists(f):
-        config_file = f
-        break
-
-enabled = (config_file is not None)
-
-settings = {}
-
-if config_file:
-    settings = yaml.load(open(config_file))

=== modified file 'lava_server/settings/debian.py'
--- lava_server/settings/debian.py	2012-09-24 02:55:36 +0000
+++ lava_server/settings/debian.py	2013-07-30 14:22:38 +0000
@@ -87,6 +87,22 @@ 
     OPENID_LAUNCHPAD_TEAMS_MAPPING_AUTO = False
     OPENID_LAUNCHPAD_TEAMS_MAPPING = debian_settings.get_setting("OPENID_LAUNCHPAD_TEAMS_MAPPING")
 
+# Atlassian Crowd authentication config
+AUTH_CROWD_SERVER_REST_URI = debian_settings.get_setting("AUTH_CROWD_SERVER_REST_URI")
+if AUTH_CROWD_SERVER_REST_URI:
+    # If Crowd server URL is configured, disable OpenID and
+    # enable Crowd auth backend
+    INSTALLED_APPS.append('crowdrest')
+    AUTHENTICATION_BACKENDS = ['crowdrest.backend.CrowdRestBackend'] + \
+        [x for x in AUTHENTICATION_BACKENDS if "OpenID" not in x]
+
+    # Load credentials from a separate file
+    from django_debian.config_file import ConfigFile
+    pathname = debian_settings._get_pathname("crowd")
+    crowd_config = ConfigFile.load(pathname)
+    AUTH_CROWD_APPLICATION_USER = crowd_config.AUTH_CROWD_APPLICATION_USER
+    AUTH_CROWD_APPLICATION_PASSWORD = crowd_config.AUTH_CROWD_APPLICATION_PASSWORD
+
 # Load extensions
 loader.contribute_to_settings(locals(), debian_settings)