Changeset - de26de99ac5b
kallithea/controllers/admin/auth_settings.py
Show inline comments
 
@@ -53,7 +53,7 @@ class AuthSettingsController(BaseControl
 

	
 
    def __load_defaults(self):
 
        c.available_plugins = [
 
            'kallithea.lib.auth_modules.auth_rhodecode',
 
            'kallithea.lib.auth_modules.auth_internal',
 
            'kallithea.lib.auth_modules.auth_container',
 
            'kallithea.lib.auth_modules.auth_ldap',
 
            'kallithea.lib.auth_modules.auth_crowd',
 
@@ -65,7 +65,7 @@ class AuthSettingsController(BaseControl
 
        _defaults = {}
 
        # default plugins loaded
 
        formglobals = {
 
            "auth_plugins": ["kallithea.lib.auth_modules.auth_rhodecode"]
 
            "auth_plugins": ["kallithea.lib.auth_modules.auth_internal"]
 
        }
 
        formglobals.update(Setting.get_auth_settings())
 
        formglobals["plugin_settings"] = {}
kallithea/controllers/admin/my_account.py
Show inline comments
 
@@ -116,7 +116,7 @@ class MyAccountController(BaseController
 
                skip_attrs = ['admin', 'active', 'extern_type', 'extern_name',
 
                              'new_password', 'password_confirmation']
 
                #TODO: plugin should define if username can be updated
 
                if c.extern_type != "rhodecode":
 
                if c.extern_type != "internal":
 
                    # forbid updating username for external accounts
 
                    skip_attrs.append('username')
 

	
kallithea/controllers/admin/users.py
Show inline comments
 
@@ -40,7 +40,7 @@ from kallithea.lib.exceptions import Def
 
from kallithea.lib import helpers as h
 
from kallithea.lib.auth import LoginRequired, HasPermissionAllDecorator, \
 
    AuthUser, generate_api_key
 
import kallithea.lib.auth_modules.auth_rhodecode
 
import kallithea.lib.auth_modules.auth_internal
 
from kallithea.lib import auth_modules
 
from kallithea.lib.base import BaseController, render
 
from kallithea.model.api_key import ApiKeyModel
 
@@ -121,7 +121,7 @@ class UsersController(BaseController):
 
    def create(self):
 
        """POST /users: Create a new item"""
 
        # url('users')
 
        c.default_extern_type = auth_modules.auth_rhodecode.RhodeCodeAuthPlugin.name
 
        c.default_extern_type = auth_modules.auth_internal.RhodeCodeAuthPlugin.name
 
        user_model = UserModel()
 
        user_form = UserForm()()
 
        try:
 
@@ -151,7 +151,7 @@ class UsersController(BaseController):
 
    def new(self, format='html'):
 
        """GET /users/new: Form to create a new item"""
 
        # url('new_user')
 
        c.default_extern_type = auth_modules.auth_rhodecode.RhodeCodeAuthPlugin.name
 
        c.default_extern_type = auth_modules.auth_internal.RhodeCodeAuthPlugin.name
 
        return render('admin/users/user_add.html')
 

	
 
    def update(self, id):
 
@@ -175,7 +175,7 @@ class UsersController(BaseController):
 
            form_result = _form.to_python(dict(request.POST))
 
            skip_attrs = ['extern_type', 'extern_name']
 
            #TODO: plugin should define if username can be updated
 
            if c.extern_type != "rhodecode":
 
            if c.extern_type != "internal":
 
                # forbid updating username for external accounts
 
                skip_attrs.append('username')
 

	
kallithea/controllers/api/api.py
Show inline comments
 
@@ -618,8 +618,8 @@ class ApiController(JSONRPCController):
 
    def create_user(self, apiuser, username, email, password=Optional(''),
 
                    firstname=Optional(''), lastname=Optional(''),
 
                    active=Optional(True), admin=Optional(False),
 
                    extern_name=Optional('rhodecode'),
 
                    extern_type=Optional('rhodecode')):
 
                    extern_name=Optional('internal'),
 
                    extern_type=Optional('internal')):
 
        """
 
        Creates new user. Returns new user object. This command can
 
        be executed only using api_key belonging to user with admin rights.
kallithea/lib/auth_modules/__init__.py
Show inline comments
 
@@ -305,7 +305,7 @@ class RhodeCodeExternalAuthPlugin(RhodeC
 
def importplugin(plugin):
 
    """
 
    Imports and returns the authentication plugin in the module named by plugin
 
    (e.g., plugin='kallithea.lib.auth_modules.auth_rhodecode'). Returns the
 
    (e.g., plugin='kallithea.lib.auth_modules.auth_internal'). Returns the
 
    RhodeCodeAuthPluginBase subclass on success, raises exceptions on failure.
 

	
 
    raises:
kallithea/lib/auth_modules/auth_internal.py
Show inline comments
 
file renamed from kallithea/lib/auth_modules/auth_rhodecode.py to kallithea/lib/auth_modules/auth_internal.py
 
@@ -12,7 +12,7 @@
 
# You should have received a copy of the GNU General Public License
 
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
"""
 
kallithea.lib.auth_modules.auth_rhodecode
 
kallithea.lib.auth_modules.auth_internal
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 

	
 
RhodeCode authentication plugin for built in internal auth
 
@@ -39,7 +39,7 @@ class RhodeCodeAuthPlugin(auth_modules.R
 

	
 
    @hybrid_property
 
    def name(self):
 
        return "rhodecode"
 
        return "internal"
 

	
 
    def settings(self):
 
        return []
kallithea/lib/db_manage.py
Show inline comments
 
@@ -374,8 +374,8 @@ class DbManage(object):
 
        :param skip_existing:
 
        """
 

	
 
        for k, v, t in [('auth_plugins', 'kallithea.lib.auth_modules.auth_rhodecode', 'list'),
 
                     ('auth_rhodecode_enabled', 'True', 'bool')]:
 
        for k, v, t in [('auth_plugins', 'kallithea.lib.auth_modules.auth_internal', 'list'),
 
                     ('auth_internal_enabled', 'True', 'bool')]:
 
            if skip_existing and Setting.get_by_name(k) != None:
 
                log.debug('Skipping option %s' % k)
 
                continue
 
@@ -541,7 +541,7 @@ class DbManage(object):
 
        UserModel().create_or_update(username, password, email,
 
                                     firstname='RhodeCode', lastname='Admin',
 
                                     active=True, admin=admin,
 
                                     extern_type="rhodecode")
 
                                     extern_type="internal")
 

	
 
    def create_default_user(self):
 
        log.info('creating default user')
kallithea/lib/dbmigrate/versions/016_version_2_0_0.py
Show inline comments
 
@@ -63,7 +63,7 @@ def fixups(models, _SESSION):
 
            usr.extern_name = ldap_dn
 
            usr.extern_type = 'ldap'
 
        else:
 
            usr.extern_name = 'rhodecode'
 
            usr.extern_type = 'rhodecode'
 
            usr.extern_name = 'internal'
 
            usr.extern_type = 'internal'
 
        _SESSION().add(usr)
 
        _SESSION().commit()
kallithea/lib/dbmigrate/versions/018_version_2_0_0.py
Show inline comments
 
@@ -37,7 +37,7 @@ def downgrade(migrate_engine):
 

	
 
def fixups(models, _SESSION):
 
    notify('Fixing default auth modules')
 
    plugins = 'kallithea.lib.auth_modules.auth_rhodecode'
 
    plugins = 'kallithea.lib.auth_modules.auth_internal'
 
    opts = []
 
    ldap_enabled = str2bool(getattr(
 
        models.Setting.get_by_name('ldap_active'),
 
@@ -47,7 +47,7 @@ def fixups(models, _SESSION):
 
        opts.append(('auth_ldap_enabled', 'True', 'bool'))
 

	
 
    opts.append(('auth_plugins', plugins, 'list'),)
 
    opts.append(('auth_rhodecode_enabled', 'True', 'bool'))
 
    opts.append(('auth_internal_enabled', 'True', 'bool'))
 

	
 
    for name, default, type_ in opts:
 
        setting = models.Setting.get_by_name(name)
kallithea/lib/dbmigrate/versions/020_version_2_0_1.py
Show inline comments
 
@@ -36,10 +36,10 @@ def downgrade(migrate_engine):
 

	
 

	
 
def fixups(models, _SESSION):
 
    #fix all empty extern type users to default 'rhodecode'
 
    #fix all empty extern type users to default 'internal'
 
    for usr in models.User.query().all():
 
        if not usr.extern_name:
 
            usr.extern_name = 'rhodecode'
 
            usr.extern_type = 'rhodecode'
 
            usr.extern_name = 'internal'
 
            usr.extern_type = 'internal'
 
            _SESSION().add(usr)
 
            _SESSION().commit()
kallithea/model/user.py
Show inline comments
 
@@ -185,8 +185,8 @@ class UserModel(BaseModel):
 

	
 
        try:
 
            form_data['admin'] = False
 
            form_data['extern_name'] = 'rhodecode'
 
            form_data['extern_type'] = 'rhodecode'
 
            form_data['extern_name'] = 'internal'
 
            form_data['extern_type'] = 'internal'
 
            new_user = self.create(form_data)
 

	
 
            self.sa.add(new_user)
kallithea/templates/admin/my_account/my_account_profile.html
Show inline comments
 
@@ -20,7 +20,7 @@ ${h.form(url('my_account'), method='post
 
        <% readonly = None %>
 
        <% disabled = "" %>
 
        <div class="fields">
 
           %if c.extern_type != 'rhodecode':
 
           %if c.extern_type != 'internal':
 
                <% readonly = "readonly" %>
 
                <% disabled = " disabled" %>
 
                <strong>${_('Your user is in an external Source of Record; some details cannot be managed here')}.</strong>
kallithea/templates/admin/users/user_edit_profile.html
Show inline comments
 
@@ -20,7 +20,7 @@ ${h.form(url('update_user', id=c.user.us
 
        <% readonly = None %>
 
        <% disabled = "" %>
 
        <div class="fields">
 
            %if c.extern_type != 'rhodecode':
 
            %if c.extern_type != 'internal':
 
             <div class="field">
 
               <% readonly = "readonly" %>
 
               <% disabled = " disabled" %>
kallithea/tests/api/api_base.py
Show inline comments
 
@@ -618,7 +618,7 @@ class BaseTestApi(object):
 

	
 
        id_, params = _build_data(self.apikey, 'create_user',
 
                                  username=username,
 
                                  email=email, extern_name='rhodecode')
 
                                  email=email, extern_name='internal')
 
        response = api_call(self, params)
 

	
 
        usr = UserModel().get_by_username(username)
kallithea/tests/fixture.py
Show inline comments
 
@@ -110,7 +110,7 @@ class Fixture(object):
 
            lastname='Test',
 
            active=True,
 
            admin=False,
 
            extern_type='rhodecode',
 
            extern_type='internal',
 
            extern_name=None
 
        )
 
        defs.update(custom)
kallithea/tests/functional/test_admin_auth_settings.py
Show inline comments
 
@@ -26,7 +26,7 @@ class TestAuthSettingsController(TestCon
 
        if ldap_lib_installed:
 
            raise SkipTest('skipping due to missing ldap lib')
 

	
 
        params = self._enable_plugins('kallithea.lib.auth_modules.auth_rhodecode,kallithea.lib.auth_modules.auth_ldap')
 
        params = self._enable_plugins('kallithea.lib.auth_modules.auth_internal,kallithea.lib.auth_modules.auth_ldap')
 
        params.update({'auth_ldap_host': u'dc.example.com',
 
                       'auth_ldap_port': '999',
 
                       'auth_ldap_tls_kind': 'PLAIN',
 
@@ -56,7 +56,7 @@ class TestAuthSettingsController(TestCon
 
        if ldap_lib_installed:
 
            raise SkipTest('skipping due to missing ldap lib')
 

	
 
        params = self._enable_plugins('kallithea.lib.auth_modules.auth_rhodecode,kallithea.lib.auth_modules.auth_ldap')
 
        params = self._enable_plugins('kallithea.lib.auth_modules.auth_internal,kallithea.lib.auth_modules.auth_ldap')
 
        params.update({'auth_ldap_host': '',
 
                       'auth_ldap_port': 'i-should-be-number',  # bad port num
 
                       'auth_ldap_tls_kind': 'PLAIN',
 
@@ -83,7 +83,7 @@ class TestAuthSettingsController(TestCon
 
        if ldap_lib_installed:
 
            raise SkipTest('skipping due to missing ldap lib')
 

	
 
        params = self._enable_plugins('kallithea.lib.auth_modules.auth_rhodecode,kallithea.lib.auth_modules.auth_ldap')
 
        params = self._enable_plugins('kallithea.lib.auth_modules.auth_internal,kallithea.lib.auth_modules.auth_ldap')
 
        params.update({'auth_ldap_host': 'Host',
 
                       'auth_ldap_port': '123',
 
                       'auth_ldap_tls_kind': 'PLAIN',
kallithea/tests/functional/test_admin_users.py
Show inline comments
 
@@ -56,8 +56,8 @@ class TestAdminUsersController(TestContr
 
             'firstname': name,
 
             'active': True,
 
             'lastname': lastname,
 
             'extern_name': 'rhodecode',
 
             'extern_type': 'rhodecode',
 
             'extern_name': 'internal',
 
             'extern_type': 'internal',
 
             'email': email})
 

	
 
        self.checkSessionFlash(response, '''Created user %s''' % (username))
 
@@ -124,7 +124,7 @@ class TestAdminUsersController(TestContr
 
        self.log_user()
 
        usr = fixture.create_user(self.test_user_1, password='qweqwe',
 
                                  email='testme@example.com',
 
                                  extern_type='rhodecode',
 
                                  extern_type='internal',
 
                                  extern_name=self.test_user_1,
 
                                  skip_if_exists=True)
 
        Session().commit()
 
@@ -136,7 +136,7 @@ class TestAdminUsersController(TestContr
 
            params['emails'] = [attrs['email']]
 
        if name == 'extern_type':
 
            #cannot update this via form, expected value is original one
 
            params['extern_type'] = "rhodecode"
 
            params['extern_type'] = "internal"
 
        if name == 'extern_name':
 
            #cannot update this via form, expected value is original one
 
            params['extern_name'] = self.test_user_1
kallithea/tests/functional/test_my_account.py
Show inline comments
 
@@ -109,7 +109,7 @@ class TestMyAccountController(TestContro
 
    def test_my_account_update(self, name, attrs):
 
        usr = fixture.create_user(self.test_user_1, password='qweqwe',
 
                                  email='testme@example.com',
 
                                  extern_type='rhodecode',
 
                                  extern_type='internal',
 
                                  extern_name=self.test_user_1,
 
                                  skip_if_exists=True)
 
        params = usr.get_api_data()  # current user data
 
@@ -118,7 +118,7 @@ class TestMyAccountController(TestContro
 

	
 
        params.update({'password_confirmation': ''})
 
        params.update({'new_password': ''})
 
        params.update({'extern_type': 'rhodecode'})
 
        params.update({'extern_type': 'internal'})
 
        params.update({'extern_name': self.test_user_1})
 

	
 
        params.update(attrs)
 
@@ -137,7 +137,7 @@ class TestMyAccountController(TestContro
 
            params['emails'] = [attrs['email']]
 
        if name == 'extern_type':
 
            #cannot update this via form, expected value is original one
 
            params['extern_type'] = "rhodecode"
 
            params['extern_type'] = "internal"
 
        if name == 'extern_name':
 
            #cannot update this via form, expected value is original one
 
            params['extern_name'] = str(user_id)
0 comments (0 inline, 0 general)