Changeset - d2319cb2ba9b
[Not reviewed]
Merge default
0 5 0
Mads Kiilerich (mads) - 6 years ago 2019-12-19 20:50:33
mads@kiilerich.com
Merge stable
5 files changed with 11 insertions and 6 deletions:
0 comments (0 inline, 0 general)
kallithea/bin/ldap_sync.py
Show inline comments
 
@@ -11,48 +11,49 @@
 
#
 
# 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.bin.ldap_sync
 
~~~~~~~~~~~~~~~~~~~~~~~
 

	
 
LDAP sync script
 

	
 
This file was forked by the Kallithea project in July 2014.
 
Original author and date, and relevant copyright and licensing information is below:
 
:created_on: Mar 06, 2013
 
:author: marcink
 
:copyright: (c) 2013 RhodeCode GmbH, and others.
 
:license: GPLv3, see LICENSE.md for more details.
 
"""
 

	
 
from __future__ import print_function
 

	
 
import urllib2
 
import uuid
 
from ConfigParser import ConfigParser
 

	
 
import ldap
 

	
 
from kallithea.lib.compat import json
 

	
 

	
 
config = ConfigParser()
 
config.read('ldap_sync.conf')
 

	
 

	
 
class InvalidResponseIDError(Exception):
 
    """ Request and response don't have the same UUID. """
 

	
 

	
 
class ResponseError(Exception):
 
    """ Response has an error, something went wrong with request execution. """
 

	
 

	
 
class UserAlreadyInGroupError(Exception):
 
    """ User is already a member of the target group. """
 

	
 

	
 
class UserNotInGroupError(Exception):
 
    """ User is not a member of the target group. """
 

	
 

	
 
class API(object):
kallithea/i18n/ru/LC_MESSAGES/kallithea.po
Show inline comments
 
@@ -59,49 +59,49 @@ msgid ""
 
"fulfilling the request."
 
msgstr ""
 
"Сервер не может выполнить запрос из-за неправильного условия в запросе."
 

	
 
msgid "%s committed on %s"
 
msgstr "%s выполнил коммит в %s"
 

	
 
msgid "Changeset was too big and was cut off..."
 
msgstr "Изменения оказались слишком большими и были вырезаны..."
 

	
 
msgid "%s %s feed"
 
msgstr "Лента новостей %s %s"
 

	
 
msgid "Changes on %s repository"
 
msgstr "Изменения в репозитории %s"
 

	
 
msgid "Click here to add new file"
 
msgstr "Нажмите чтобы добавить новый файл"
 

	
 
msgid "%s at %s"
 
msgstr "%s (%s)"
 

	
 
msgid "You can only delete files with revision being a valid branch"
 
msgstr ""
 
"Вы можете удалять файлы только в ревизии, связанной с существующей веткой "
 
"Вы можете удалять файлы только в ревизии, являющейся корректной веткой"
 

	
 
msgid "Deleted file %s via Kallithea"
 
msgstr "Файл %s удалён с помощью Kallithea"
 

	
 
msgid "Successfully deleted file %s"
 
msgstr "Файл %s удалён"
 

	
 
msgid "Error occurred during commit"
 
msgstr "Во время коммита произошла ошибка"
 

	
 
msgid "You can only edit files with revision being a valid branch"
 
msgstr ""
 
"Вы можете редактировать файлы только в ревизии, связанной с существующей "
 
"веткой "
 

	
 
msgid "Edited file %s via Kallithea"
 
msgstr "Файл %s отредактирован с помощью Kallithea"
 

	
 
msgid "No changes"
 
msgstr "Без изменений"
 

	
 
msgid "Successfully committed to %s"
 
msgstr "Изменения применены в %s"
 

	
 
@@ -690,51 +690,51 @@ msgid_plural "%d months"
 
msgstr[0] "%d месяц"
 
msgstr[1] "%d месяца"
 
msgstr[2] "%d месяцев"
 

	
 
msgid "%d day"
 
msgid_plural "%d days"
 
msgstr[0] "%d день"
 
msgstr[1] "%d дня"
 
msgstr[2] "%d дней"
 

	
 
msgid "%d hour"
 
msgid_plural "%d hours"
 
msgstr[0] "%d час"
 
msgstr[1] "%d часов"
 
msgstr[2] "%d часа"
 

	
 
msgid "%d minute"
 
msgid_plural "%d minutes"
 
msgstr[0] "%d минута"
 
msgstr[1] "%d минут"
 
msgstr[2] "%d минуты"
 

	
 
msgid "%d second"
 
msgid_plural "%d seconds"
 
msgstr[0] "%d секунды"
 
msgstr[0] "%d секунда"
 
msgstr[1] "%d секунды"
 
msgstr[2] "%d секунды"
 
msgstr[2] "%d секунд"
 

	
 
msgid "in %s"
 
msgstr "в %s"
 

	
 
msgid "%s ago"
 
msgstr "%s назад"
 

	
 
msgid "in %s and %s"
 
msgstr "в %s и %s"
 

	
 
msgid "%s and %s ago"
 
msgstr "%s и %s назад"
 

	
 
msgid "just now"
 
msgstr "прямо сейчас"
 

	
 
msgid "on line %s"
 
msgstr "на строке %s"
 

	
 
msgid "[Mention]"
 
msgstr "[Упоминание]"
 

	
 
msgid "top level"
 
msgstr "верхний уровень"
 
@@ -816,49 +816,49 @@ msgstr "Пользователь с именем \"%(username)s\" уже существует"
 

	
 
msgid "Username %(username)s is not valid"
 
msgstr "Имя \"%(username)s\" недопустимо"
 

	
 
msgid "Invalid user group name"
 
msgstr "Неверное имя группы пользователей"
 

	
 
msgid "User group \"%(usergroup)s\" already exists"
 
msgstr "Группа пользователей \"%(usergroup)s\" уже существует"
 

	
 
msgid ""
 
"user group name may only contain alphanumeric characters underscores, "
 
"periods or dashes and must begin with alphanumeric character"
 
msgstr ""
 
"имя группы пользователей может содержать только буквы, цифры, символы "
 
"подчеркивания, точки и тире; а так же должно начинаться с буквы или цифры"
 

	
 
msgid "Cannot assign this group as parent"
 
msgstr "Невозможно использовать эту группу как родителя"
 

	
 
msgid "Group \"%(group_name)s\" already exists"
 
msgstr "Группа \"%(group_name)s\" уже существует"
 

	
 
msgid "Repository with name \"%(group_name)s\" already exists"
 
msgstr "Репозитарий с  именем \"%(group_name)s\" уже существует"
 
msgstr "Репозиторий с именем «%(group_name)s» уже существует"
 

	
 
msgid "Invalid characters (non-ascii) in password"
 
msgstr "Недопустимые символы (не ascii) в пароле"
 

	
 
msgid "Invalid old password"
 
msgstr "Неверно задан старый пароль"
 

	
 
msgid "Passwords do not match"
 
msgstr "Пароли не совпадают"
 

	
 
msgid "Repository named %(repo)s already exists"
 
msgstr "Репозитарий %(repo)s уже существует"
 

	
 
msgid "Repository \"%(repo)s\" already exists in group \"%(group)s\""
 
msgstr "Репозитарий \"%(repo)s\" уже существует в группе \"%(group)s\""
 

	
 
msgid "Repository group with name \"%(repo)s\" already exists"
 
msgstr "Группа репозиториев \"%(repo)s\" уже существует"
 

	
 
msgid "Fork has to be the same type as parent"
 
msgstr "Тип форка будет совпадать с родительским"
 

	
 
msgid "You don't have permissions to create repository in this group"
 
msgstr "У вас недостаточно прав для создания репозиториев в этой группе"
kallithea/lib/ssh.py
Show inline comments
 
@@ -45,69 +45,71 @@ def parse_pub_key(ssh_key):
 
    SshKeyParseError: SSH key is missing
 
    >>> parse_pub_key('''AAAAB3NzaC1yc2EAAAALVGhpcyBpcyBmYWtlIQ''')
 
    Traceback (most recent call last):
 
    ...
 
    SshKeyParseError: Incorrect SSH key - it must have both a key type and a base64 part
 
    >>> parse_pub_key('''abc AAAAB3NzaC1yc2EAAAALVGhpcyBpcyBmYWtlIQ''')
 
    Traceback (most recent call last):
 
    ...
 
    SshKeyParseError: Incorrect SSH key - it must start with 'ssh-(rsa|dss|ed25519)'
 
    >>> parse_pub_key('''ssh-rsa  AAAAB3NzaC1yc2EAAAALVGhpcyBpcyBmYWtlIQ''')
 
    Traceback (most recent call last):
 
    ...
 
    SshKeyParseError: Incorrect SSH key - failed to decode base64 part 'AAAAB3NzaC1yc2EAAAALVGhpcyBpcyBmYWtlIQ'
 
    >>> parse_pub_key('''ssh-rsa  AAAAB2NzaC1yc2EAAAALVGhpcyBpcyBmYWtlIQ==''')
 
    Traceback (most recent call last):
 
    ...
 
    SshKeyParseError: Incorrect SSH key - base64 part is not 'ssh-rsa' as claimed but 'csh-rsa'
 
    >>> parse_pub_key('''ssh-rsa  AAAAB3NzaC1yc2EAAAA'LVGhpcyBpcyBmYWtlIQ''')
 
    Traceback (most recent call last):
 
    ...
 
    SshKeyParseError: Incorrect SSH key - unexpected characters in base64 part "AAAAB3NzaC1yc2EAAAA'LVGhpcyBpcyBmYWtlIQ"
 
    >>> parse_pub_key(''' ssh-rsa  AAAAB3NzaC1yc2EAAAALVGhpcyBpcyBmYWtlIQ== and a comment
 
    ... ''')
 
    ('ssh-rsa', '\x00\x00\x00\x07ssh-rsa\x00\x00\x00\x0bThis is fake!', 'and a comment\n')
 
    >>> parse_pub_key('''ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIP1NA2kBQIKe74afUXmIWD9ByDYQJqUwW44Y4gJOBRuo''')
 
    ('ssh-ed25519', '\x00\x00\x00\x0bssh-ed25519\x00\x00\x00 \xfdM\x03i\x01@\x82\x9e\xef\x86\x9fQy\x88X?A\xc86\x10&\xa50[\x8e\x18\xe2\x02N\x05\x1b\xa8', '')
 
    """
 
    if not ssh_key:
 
        raise SshKeyParseError(_("SSH key is missing"))
 

	
 
    parts = ssh_key.split(None, 2)
 
    if len(parts) < 2:
 
        raise SshKeyParseError(_("Incorrect SSH key - it must have both a key type and a base64 part"))
 

	
 
    keytype, keyvalue, comment = (parts + [''])[:3]
 
    if keytype not in ('ssh-rsa', 'ssh-dss', 'ssh-ed25519'):
 
        raise SshKeyParseError(_("Incorrect SSH key - it must start with 'ssh-(rsa|dss|ed25519)'"))
 

	
 
    if re.search(r'[^a-zA-Z0-9+/=]', keyvalue):
 
        raise SshKeyParseError(_("Incorrect SSH key - unexpected characters in base64 part %r") % keyvalue)
 

	
 
    try:
 
        decoded = keyvalue.decode('base64')
 
    except binascii.Error:
 
        raise SshKeyParseError(_("Incorrect SSH key - failed to decode base64 part %r") % keyvalue)
 

	
 
    if not decoded.startswith('\x00\x00\x00\x07' + str(keytype) + '\x00'):
 
    if not decoded.startswith('\x00\x00\x00' + chr(len(keytype)) + str(keytype) + '\x00'):
 
        raise SshKeyParseError(_("Incorrect SSH key - base64 part is not %r as claimed but %r") % (str(keytype), str(decoded[4:].split('\0', 1)[0])))
 

	
 
    return keytype, decoded, comment
 

	
 

	
 
SSH_OPTIONS = 'no-pty,no-port-forwarding,no-X11-forwarding,no-agent-forwarding'
 

	
 

	
 
def authorized_keys_line(kallithea_cli_path, config_file, key):
 
    """
 
    Return a line as it would appear in .authorized_keys
 

	
 
    >>> from kallithea.model.db import UserSshKeys, User
 
    >>> user = User(user_id=7, username='uu')
 
    >>> key = UserSshKeys(user_ssh_key_id=17, user=user, description='test key')
 
    >>> key.public_key='''ssh-rsa  AAAAB3NzaC1yc2EAAAALVGhpcyBpcyBmYWtlIQ== and a comment'''
 
    >>> authorized_keys_line('/srv/kallithea/venv/bin/kallithea-cli', '/srv/kallithea/my.ini', key)
 
    'no-pty,no-port-forwarding,no-X11-forwarding,no-agent-forwarding,command="/srv/kallithea/venv/bin/kallithea-cli ssh-serve -c /srv/kallithea/my.ini 7 17" ssh-rsa AAAAB3NzaC1yc2EAAAALVGhpcyBpcyBmYWtlIQ==\\n'
 
    """
 
    try:
 
        keytype, decoded, comment = parse_pub_key(key.public_key)
 
    except SshKeyParseError:
 
        return '# Invalid Kallithea SSH key: %s %s\n' % (key.user.user_id, key.user_ssh_key_id)
 
    mimekey = decoded.encode('base64').replace('\n', '')
kallithea/templates/admin/settings/settings_visual.html
Show inline comments
 
@@ -37,48 +37,50 @@ ${h.form(url('admin_settings_visual'), m
 
            </div>
 

	
 
            <div class="form-group">
 
                <label class="control-label">${_('HTTP Clone URL')}:</label>
 
                <div>
 
                    ${h.text('clone_uri_tmpl', size=80, class_='form-control')}
 
                    <span class="help-block">${_('''Schema of clone URL construction eg. '{scheme}://{user}@{netloc}/{repo}'.
 
                                                    The following variables are available:
 
                                                    {scheme} 'http' or 'https' sent from running Kallithea server,
 
                                                    {user}   current user username,
 
                                                    {netloc} network location/server host of running Kallithea server,
 
                                                    {repo}   full repository name,
 
                                                    {repoid} ID of repository, can be used to construct clone-by-id,
 
                                                    {system_user}  name of the Kallithea system user,
 
                                                    {hostname}  server hostname
 
                                                    ''')}
 
                    </span>
 
                </div>
 
                %if c.ssh_enabled:
 
                <label class="control-label">${_('SSH Clone URL')}:</label>
 
                <div>
 
                    ${h.text('clone_ssh_tmpl', size=80, class_='form-control')}
 
                    <span class="help-block">${_('''Schema for constructing SSH clone URL, eg. 'ssh://{system_user}@{hostname}/{repo}'.''')}</span>
 
                </div>
 
                %else:
 
                ${h.hidden('clone_ssh_tmpl', size=80, class_='form-control')}
 
                %endif
 
            </div>
 

	
 
            <div class="form-group">
 
                <label class="control-label" for="dashboard_items">${_('Repository page size')}:</label>
 
                <div>
 
                    ${h.text('dashboard_items',size=5,class_='form-control')}
 
                    <span class="help-block">${_('Number of items displayed in the repository pages before pagination is shown.')}</span>
 
                </div>
 
            </div>
 

	
 
            <div class="form-group">
 
                <label class="control-label" for="admin_grid_items">${_('Admin page size')}:</label>
 
                <div>
 
                    ${h.text('admin_grid_items',size=5,class_='form-control')}
 
                    <span class="help-block">${_('Number of items displayed in the admin pages grids before pagination is shown.')}</span>
 
                </div>
 
            </div>
 

	
 
            <div class="form-group">
 
                <label class="control-label">${_('Icons')}:</label>
 
                <div>
 
                    <div class="checkbox">
 
                        <label>
scripts/make-release
Show inline comments
 
#!/bin/bash
 
set -e
 
set -x
 

	
 
cleanup()
 
{
 
  echo "Removing venv $venv"
 
  rm  -rf "$venv"
 
}
 

	
 
echo "Checking that you are NOT inside a virtualenv"
 
[ -z "$VIRTUAL_ENV" ]
 

	
 
venv=$(mktemp -d --tmpdir kallithea-release-XXXXX)
 
trap cleanup EXIT
 

	
 
echo "Setting up a fresh virtualenv in $venv"
 
virtualenv -p python2 "$venv"
 
. "$venv/bin/activate"
 

	
 
echo "Install/verify tools needed for building and uploading stuff"
 
pip install --upgrade -e . -r dev_requirements.txt twine
 
pip install --upgrade -e . -r dev_requirements.txt twine python-ldap python-pam
 

	
 
echo "Cleanup and update copyrights ... and clean checkout"
 
scripts/run-all-cleanup
 
scripts/update-copyrights.py
 
hg up -cr .
 

	
 
echo "Make release build from clean checkout in build/"
 
rm -rf build dist
 
hg archive build
 
cd build
 

	
 
echo "Check that each entry in MANIFEST.in match something"
 
sed -e 's/[^ ]*[ ]*\([^ ]*\).*/\1/g' MANIFEST.in | xargs ls -lad
 

	
 
echo "Build dist"
 
python2 setup.py compile_catalog
 
python2 setup.py sdist
 

	
 
echo "Verify VERSION from kallithea/__init__.py"
 
namerel=$(cd dist && echo Kallithea-*.tar.gz)
 
namerel=${namerel%.tar.gz}
 
version=${namerel#Kallithea-}
 
ls -l $(pwd)/dist/$namerel.tar.gz
 
echo "Releasing Kallithea $version in directory $namerel"
0 comments (0 inline, 0 general)