Fix #5391 - Alembic migrations would only work for SQLite
[larjonas-mediagoblin.git] / mediagoblin / plugins / ldap / __init__.py
blob4673acee2dd7feff3f4e34652a71f8286608aa0a
1 # GNU MediaGoblin -- federated, autonomous media hosting
2 # Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS.
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU Affero General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU Affero General Public License for more details.
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 import os
18 from mediagoblin.auth.tools import create_basic_user
19 from mediagoblin.tools import pluginapi
21 PLUGIN_DIR = os.path.dirname(__file__)
24 def setup_plugin():
25 config = pluginapi.get_config('mediagoblin.plugins.ldap')
27 routes = [
28 ('mediagoblin.plugins.ldap.register',
29 '/auth/ldap/register/',
30 'mediagoblin.plugins.ldap.views:register'),
31 ('mediagoblin.plugins.ldap.login',
32 '/auth/ldap/login/',
33 'mediagoblin.plugins.ldap.views:login')]
35 pluginapi.register_routes(routes)
36 pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))
38 pluginapi.register_template_hooks(
39 {'create_account': 'mediagoblin/plugins/ldap/create_account_link.html'})
42 def create_user(register_form):
43 if 'username' in register_form and 'password' not in register_form:
44 return create_basic_user(register_form)
47 def no_pass_redirect():
48 return 'ldap'
51 def auth():
52 return True
54 hooks = {
55 'setup': setup_plugin,
56 'authentication': auth,
57 'auth_no_pass_redirect': no_pass_redirect,
58 'auth_create_user': create_user,