Files
@ b232a36cc51f
Branch filter:
Location: kallithea/rhodecode/model/settings.py - annotation
b232a36cc51f
3.0 KiB
text/x-python
Improve LDAP authentication
* Adds an LDAP filter for locating the LDAP object
* Adds a search scope policy when using the Base DN
* Adds option required certificate policy when using LDAPS
* Adds attribute mapping for username, firstname, lastname, email
* Initializes rhodecode user using LDAP info (no longer uses "@ldap")
* Remembers the user object (DN) in the user table
* Updates admin interfaces
* Authenticates against actual user objects in LDAP
* Possibly other things.
Really, this should be extended to a list of LDAP configurations, but this is a good start.
* Adds an LDAP filter for locating the LDAP object
* Adds a search scope policy when using the Base DN
* Adds option required certificate policy when using LDAPS
* Adds attribute mapping for username, firstname, lastname, email
* Initializes rhodecode user using LDAP info (no longer uses "@ldap")
* Remembers the user object (DN) in the user table
* Updates admin interfaces
* Authenticates against actual user objects in LDAP
* Possibly other things.
Really, this should be extended to a list of LDAP configurations, but this is a good start.
26237de9b613 26237de9b613 26237de9b613 07a6e8c65526 26237de9b613 26237de9b613 26237de9b613 26237de9b613 26237de9b613 26237de9b613 26237de9b613 26237de9b613 26237de9b613 26237de9b613 26237de9b613 26237de9b613 26237de9b613 26237de9b613 26237de9b613 26237de9b613 26237de9b613 26237de9b613 89b9037d68b7 26237de9b613 89b9037d68b7 26237de9b613 89b9037d68b7 26237de9b613 26237de9b613 26237de9b613 26237de9b613 26237de9b613 26237de9b613 26237de9b613 89b9037d68b7 26237de9b613 26237de9b613 26237de9b613 26237de9b613 26237de9b613 26237de9b613 26237de9b613 26237de9b613 26237de9b613 26237de9b613 26237de9b613 26237de9b613 9adc0c1d9a87 042d38683d42 042d38683d42 042d38683d42 042d38683d42 042d38683d42 9adc0c1d9a87 9adc0c1d9a87 9adc0c1d9a87 9adc0c1d9a87 01be209b9828 01be209b9828 01be209b9828 01be209b9828 01be209b9828 01be209b9828 01be209b9828 01be209b9828 26237de9b613 26237de9b613 9e9f1b919c0c 9e9f1b919c0c 9e9f1b919c0c 9e9f1b919c0c 9e9f1b919c0c 9e9f1b919c0c 9e9f1b919c0c b232a36cc51f 9e9f1b919c0c 9e9f1b919c0c 9e9f1b919c0c b232a36cc51f b232a36cc51f b232a36cc51f b232a36cc51f b232a36cc51f b232a36cc51f 9e9f1b919c0c b232a36cc51f 26237de9b613 26237de9b613 26237de9b613 26237de9b613 26237de9b613 26237de9b613 26237de9b613 26237de9b613 26237de9b613 26237de9b613 26237de9b613 26237de9b613 26237de9b613 26237de9b613 26237de9b613 | #!/usr/bin/env python
# encoding: utf-8
# Model for RhodeCode settings
# Copyright (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 2
# of the License or (at your opinion) any later version of the license.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
"""
Created on Nov 17, 2010
Model for RhodeCode
:author: marcink
"""
from rhodecode.lib import helpers as h
from rhodecode.model import BaseModel
from rhodecode.model.caching_query import FromCache
from rhodecode.model.db import RhodeCodeSettings
from sqlalchemy.orm import joinedload
import logging
log = logging.getLogger(__name__)
class SettingsModel(BaseModel):
"""
Settings model
"""
def get(self, settings_key, cache=False):
r = self.sa.query(RhodeCodeSettings)\
.filter(RhodeCodeSettings.app_settings_name == settings_key).scalar()
if cache:
r = r.options(FromCache("sql_cache_short",
"get_setting_%s" % settings_key))
return r
def get_app_settings(self, cache=False):
"""Get's config from database, each config key is prefixed with
'rhodecode_' prefix, than global pylons config is updated with such
keys
"""
ret = self.sa.query(RhodeCodeSettings)
if cache:
ret = ret.options(FromCache("sql_cache_short", "get_hg_settings"))
if not ret:
raise Exception('Could not get application settings !')
settings = {}
for each in ret:
settings['rhodecode_' + each.app_settings_name] = each.app_settings_value
return settings
def get_ldap_settings(self):
"""
Returns ldap settings from database
:returns:
ldap_active
ldap_host
ldap_port
ldap_ldaps
ldap_tls_reqcert
ldap_dn_user
ldap_dn_pass
ldap_base_dn
ldap_filter
ldap_search_scope
ldap_attr_login
ldap_attr_firstname
ldap_attr_lastname
ldap_attr_email
"""
# ldap_search_scope
r = self.sa.query(RhodeCodeSettings)\
.filter(RhodeCodeSettings.app_settings_name\
.startswith('ldap_'))\
.all()
fd = {}
for row in r:
v = row.app_settings_value
if v in ['0', '1']:
v = v == '1'
fd.update({row.app_settings_name:v})
return fd
|