diff options
Diffstat (limited to 'mediagoblin/plugins/ldap')
-rw-r--r-- | mediagoblin/plugins/ldap/README.rst | 18 | ||||
-rw-r--r-- | mediagoblin/plugins/ldap/forms.py | 4 | ||||
-rw-r--r-- | mediagoblin/plugins/ldap/tools.py | 4 | ||||
-rw-r--r-- | mediagoblin/plugins/ldap/views.py | 12 |
4 files changed, 22 insertions, 16 deletions
diff --git a/mediagoblin/plugins/ldap/README.rst b/mediagoblin/plugins/ldap/README.rst index ea9a34b3..049b5c4d 100644 --- a/mediagoblin/plugins/ldap/README.rst +++ b/mediagoblin/plugins/ldap/README.rst @@ -14,16 +14,16 @@ .. _ldap-plugin: ============= - ldap plugin + LDAP plugin ============= .. Warning:: This plugin is not compatible with the other authentication plugins. -This plugin allow your GNU Mediagoblin instance to authenticate against an +This plugin allow your GNU MediaGoblin instance to authenticate against an LDAP server. -Set up the ldap plugin +Set up the LDAP plugin ====================== 1. Install the ``python-ldap`` package. @@ -32,13 +32,13 @@ Set up the ldap plugin [[mediagoblin.plugins.ldap]] -Configuring the ldap plugin +Configuring the LDAP plugin =========================== -This plugin allows you to use multiple ldap servers for authentication. +This plugin allows you to use multiple LDAP servers for authentication. In order to configure a server, add the following to you MediaGoblin .ini file -under the ldap plugin:: +under the LDAP plugin:: [[mediagoblin.plugins.ldap]] [[[server1]]] @@ -50,15 +50,15 @@ under the ldap plugin:: Make any necessary changes to the above to work with your sever. Make sure ``{username}`` is where the username should be in LDAP_USER_DN_TEMPLATE. -If you would like to fetch the users email from the ldap server upon account +If you would like to fetch the users email from the LDAP server upon account registration, add ``LDAP_SEARCH_BASE = 'ou=users,dc=testathon,dc=net'`` and ``EMAIL_SEARCH_FIELD = 'mail'`` under you server configuration in your MediaGoblin .ini file. .. Warning:: By default, this plugin provides no encryption when communicating with the - ldap servers. If you would like to use an SSL connection, change - LDAP_SERVER_URI to use ``ldaps://`` and whichever port you use. Default ldap + LDAP servers. If you would like to use an SSL connection, change + LDAP_SERVER_URI to use ``ldaps://`` and whichever port you use. Default LDAP port for SSL connections is 636. If you would like to use a TLS connection, add ``LDAP_START_TLS = 'true'`` under your server configuration in your MediaGoblin .ini file. diff --git a/mediagoblin/plugins/ldap/forms.py b/mediagoblin/plugins/ldap/forms.py index 1f1439ab..3d966e03 100644 --- a/mediagoblin/plugins/ldap/forms.py +++ b/mediagoblin/plugins/ldap/forms.py @@ -24,14 +24,14 @@ class RegisterForm(wtforms.Form): '', [wtforms.validators.InputRequired(), normalize_user_or_email_field(allow_email=False)]) - email = wtforms.TextField( + email = wtforms.StringField( _('Email address'), [wtforms.validators.InputRequired(), normalize_user_or_email_field(allow_user=False)]) class LoginForm(wtforms.Form): - username = wtforms.TextField( + username = wtforms.StringField( _('Username'), [wtforms.validators.InputRequired(), normalize_user_or_email_field()]) diff --git a/mediagoblin/plugins/ldap/tools.py b/mediagoblin/plugins/ldap/tools.py index 1c436792..2be2dcd7 100644 --- a/mediagoblin/plugins/ldap/tools.py +++ b/mediagoblin/plugins/ldap/tools.py @@ -16,6 +16,8 @@ import ldap import logging +import six + from mediagoblin.tools import pluginapi _log = logging.getLogger(__name__) @@ -47,7 +49,7 @@ class LDAP(object): return email def login(self, username, password): - for k, v in self.ldap_settings.iteritems(): + for k, v in six.iteritems(self.ldap_settings): try: self._connect(v) user_dn = v['LDAP_USER_DN_TEMPLATE'].format(username=username) diff --git a/mediagoblin/plugins/ldap/views.py b/mediagoblin/plugins/ldap/views.py index aef1bf56..e10c7f60 100644 --- a/mediagoblin/plugins/ldap/views.py +++ b/mediagoblin/plugins/ldap/views.py @@ -13,9 +13,12 @@ # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. + +import six + from mediagoblin import mg_globals, messages from mediagoblin.auth.tools import register_user -from mediagoblin.db.models import User +from mediagoblin.db.models import User, LocalUser from mediagoblin.decorators import allow_registration, auth_enabled from mediagoblin.plugins.ldap import forms from mediagoblin.plugins.ldap.tools import LDAP @@ -35,12 +38,13 @@ def login(request): login_form.password.data) if username: - user = User.query.filter_by( - username=username).first() + user = LocalUser.query.filter( + LocalUser.username==username + ).first() if user: # set up login in session - request.session['user_id'] = unicode(user.id) + request.session['user_id'] = six.text_type(user.id) request.session.save() if request.form.get('next'): |