diff mbox

[Branch,~linaro-validation/lava-server/trunk] Rev 414: Do not require changing server source code to enable crowd authentication

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

Commit Message

Antonio Terceiro July 25, 2013, 11:08 p.m. UTC
Merge authors:
  Antonio Terceiro (terceiro)
Related merge proposals:
  https://code.launchpad.net/~terceiro/lava-server/crowd-config/+merge/176837
  proposed by: Antonio Terceiro (terceiro)
  review: Approve - Paul Sokolovsky (pfalcon)
------------------------------------------------------------
revno: 414 [merge]
committer: Antonio Terceiro <antonio.terceiro@linaro.org>
branch nick: trunk
timestamp: Thu 2013-07-25 20:06:24 -0300
message:
  Do not require changing server source code to enable crowd authentication
added:
  lava_server/settings/crowd.py
modified:
  lava_server/settings/common.py
  setup.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/settings/common.py'
--- lava_server/settings/common.py	2013-07-25 12:07:17 +0000
+++ lava_server/settings/common.py	2013-07-25 23:06:24 +0000
@@ -16,6 +16,7 @@ 
 # 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
 
 # Administrator contact, used for sending
 # emergency email when something breaks
@@ -120,11 +121,16 @@ 
     'linaro_django_xmlrpc',
     'lava_markitup',  # Support app for MarkItUp in LAVA
     'south',
-    # Uncomment to enable Atlassian Crowd auth support.
-    #'crowdrest',
     'google_analytics',
 ]
 
+if crowd.enabled:
+    try:
+        import crowdrest
+        INSTALLED_APPS.append('crowdrest')
+    except ImportError:
+        pass
+
 try:
     import devserver
     INSTALLED_APPS += ['devserver']
@@ -163,9 +169,9 @@ 
 # Configuration settings for crowdrest.backend.CrowdRestBackend
 # Alternatively, can be set in production config for particular installed
 # instance.
-#AUTH_CROWD_APPLICATION_USER = 'appname'
-#AUTH_CROWD_APPLICATION_PASSWORD = 'apppass'
-#AUTH_CROWD_SERVER_REST_URI = 'https://crowd-server/crowd/rest/usermanagement/1'
+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}
 

=== added file 'lava_server/settings/crowd.py'
--- lava_server/settings/crowd.py	1970-01-01 00:00:00 +0000
+++ lava_server/settings/crowd.py	2013-07-25 02:09:32 +0000
@@ -0,0 +1,24 @@ 
+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 'setup.py'
--- setup.py	2013-07-11 11:26:54 +0000
+++ setup.py	2013-07-25 23:02:35 +0000
@@ -73,10 +73,9 @@ 
         'south >= 0.7.3',
         'versiontools >= 1.8',
         'markdown >= 2.0.3',
-        # Disabled by default, as most people don't need
-        # Atlassian Crowd auth. Handled on the level of
-        # buildout.cfg instead.
-        #'django-crowd-rest-backend >= 0.3',
+
+        # optional dependency; for authentication with Attlassian Crowd SSO
+        # 'django-crowd-rest-backend >= 0.3,
     ],
     setup_requires=[
         'versiontools >= 1.8',