-default[:osqa][:revision] = "1284"
default[:osqa][:user] = "osqa"
default[:osqa][:group] = nil
default[:osqa][:database_name] = "osqa"
+++ /dev/null
-from forum.authentication.base import AuthenticationConsumer, ConsumerTemplateContext, InvalidAuthentication
-from forms import OpenStreetMapLoginForm
-
-class OpenStreetMapAuthConsumer(AuthenticationConsumer):
- def process_authentication_request(self, request):
- form_auth = OpenStreetMapLoginForm(request.POST)
-
- if form_auth.is_valid():
- request.session["auth_consumer_data"] = form_auth.get_user_data()
- return form_auth.get_user()
- else:
- raise InvalidAuthentication(" ".join(form_auth.errors.values()[0]))
-
- def get_user_data(self, key):
- return {}
-
-class OpenStreetMapAuthContext(ConsumerTemplateContext):
- mode = 'TOP_STACK_ITEM'
- weight = 0
- human_name = 'OpenStreetMap Login'
- stack_item_template = 'modules/osmauth/loginform.html'
+++ /dev/null
-from osm import OpenStreetMapAPI
-from forum.forms import NextUrlField, UserNameField, SetPasswordForm
-from django.utils.translation import ugettext as _
-from django import forms
-
-class OpenStreetMapLoginForm(forms.Form):
- """ osm account signin form """
- next = NextUrlField()
- username = UserNameField(required=False, skip_clean=True)
- password = forms.CharField(max_length=128,
- widget=forms.widgets.PasswordInput(attrs={'class':'required login'}),
- required=False)
-
- def __init__(self, data=None, files=None, auto_id='id_%s',
- prefix=None, initial=None):
- super(OpenStreetMapLoginForm, self).__init__(data, files, auto_id,
- prefix, initial)
- self.user_details = None
-
- def _clean_nonempty_field(self, field):
- value = None
- if field in self.cleaned_data:
- value = self.cleaned_data[field].strip()
- if value == '':
- value = None
- self.cleaned_data[field] = value
- return value
-
- def clean_username(self):
- return self._clean_nonempty_field('username')
-
- def clean_password(self):
- return self._clean_nonempty_field('password')
-
- def clean(self):
- error_list = []
- username = self.cleaned_data['username']
- password = self.cleaned_data['password']
-
- self.user_details = None
- if username and password:
- api = OpenStreetMapAPI(username, password)
-
- try:
- self.user_details = api.user_details()
- except:
- del self.cleaned_data['username']
- del self.cleaned_data['password']
- error_list.insert(0, (_("Please enter valid username and password "
- "(both are case-sensitive).")))
- error_list.insert(0, _('Login failed.'))
-
- elif password == None and username == None:
- error_list.append(_('Please enter username and password'))
- elif password == None:
- error_list.append(_('Please enter your password'))
- elif username == None:
- error_list.append(_('Please enter user name'))
- if len(error_list) > 0:
- self._errors['__all__'] = forms.util.ErrorList(error_list)
-
- return self.cleaned_data
-
- def get_user(self):
- """ get authenticated user """
- return "http://www.openstreetmap.org/user/%s" % self.user_details["id"]
-
- def get_user_data(self):
- """ get user data for authenticated user """
- return {
- "username": self.user_details["display_name"]
- }
+++ /dev/null
-from xml.etree.ElementTree import ElementTree
-import urllib2
-
-class OpenStreetMapAPI:
- def __init__(self, username, password):
- passman = urllib2.HTTPPasswordMgr()
- passman.add_password("Web Password", "https://api.openstreetmap.org/api/0.6", username, password)
- authhandler = urllib2.HTTPBasicAuthHandler(passman)
- self.opener = urllib2.build_opener(authhandler)
-
- def user_details(self):
- response = self.opener.open("https://api.openstreetmap.org/api/0.6/user/details")
- tree = ElementTree()
- root = tree.parse(response)
- user = root.find("user")
- return {
- "id": user.attrib["id"],
- "display_name": user.attrib["display_name"]
- }
+++ /dev/null
-{% load i18n %}
-
-<fieldset id='openstreetmap_login_fs'>
- <p><span class='big strong'>{% trans 'Enter your OpenStreetMap username and password' %}</span><br/><span class='grey'>({% trans 'or select your external provider below' %})</span></p>
- <table>
- <tr>
- <td>
- <label for="id_osm_username">{% trans 'Username' %}</label>
- </td>
- <td>
- <input id="id_osm_username" type="text" class="required login" name="username" maxlength="255" />
- </td>
- </tr>
- <tr>
- <td>
- <label for="id_osm_password">{% trans 'Password' %}</label>
- </td>
- <td>
- <input id="id_osm_password" type="password" class="required login" name="password" maxlength="255" />
- </td>
- </tr>
- <tr>
- <td>
- <input id="blogin" name="blogin" type="submit" value="{% trans 'Login' %}" />
- </td>
- <td>
- <a href="https://www.openstreetmap.org/user/new">{% trans 'Create account' %}</a><span> | </span><a href="http://www.openstreetmap.org/user/forgot-password">{% trans 'Forgot your password?' %}</a>
- </td>
- </tr>
- </table>
-</fieldset>
+++ /dev/null
-from django.conf.urls.defaults import *
-from django.views.generic.simple import direct_to_template
-from django.utils.translation import ugettext as _
-import views as app
-
-urlpatterns = patterns('',
- url(r'^%s%s%s$' % (_('account/'), _('openstreetmap/'), _('register/')), app.register, name='auth_openstreetmap_register'),
-)
node[:osqa][:sites].each do |site|
name = site[:name]
- directory = site[:directory] || "/var/www/#{name}"
+ directory = site[:directory] || "/srv/#{name}"
osqa_revision = site[:revision] || node[:osqa][:revision]
site_user = site[:user] || node[:osqa][:user]
site_user = Etc.getpwuid(site_user).name if site_user.is_a?(Integer)
variables :user => site_user, :group => site_group
end
+ directory directory do
+ owner site_user
+ group site_group
+ mode 0755
+ end
+
execute "osqa-migrate" do
action :nothing
command "python manage.py migrate forum"
notifies :reload, "service[apache2]"
end
- subversion "#{directory}/osqa" do
+ git "#{directory}/osqa" do
action :sync
- repository "http://svn.osqa.net/svnroot/osqa/trunk"
- revision osqa_revision
+ repository "git://git.openstreetmap.org/osqa.git"
+ revision "live"
user site_user
group site_group
notifies :run, "execute[osqa-migrate]"
end
- remote_directory "#{directory}/osqa/forum_modules/osmauth" do
- source "osmauth"
- owner site_user
- group site_group
- mode 0755
- files_owner site_user
- files_group site_group
- files_mode 0644
- end
-
template "#{directory}/osqa/osqa.wsgi" do
source "osqa.wsgi.erb"
owner site_user
line.gsub!(/^( *)'NAME': '.*',/, "\\1'NAME': '#{database_name}',")
line.gsub!(/^( *)'USER': '.*',/, "\\1'USER': '#{database_user}',")
line.gsub!(/^( *)'PASSWORD': '.*',/, "\\1'PASSWORD': '#{database_password}',")
+ line.gsub!(/^ALLOWED_HOSTS = .*/, "ALLOWED_HOSTS = ('help.openstreetmap.org',)")
line.gsub!(/^CACHE_BACKEND = .*/, "CACHE_BACKEND = 'memcached://127.0.0.1:11211/'")
line.gsub!(/^APP_URL = 'http:\/\/'/, "APP_URL = 'http://#{name}'")
line.gsub!(/^TIME_ZONE = 'America\/New_York'/, "TIME_ZONE = 'Europe/London'")