diff --git a/README.md b/README.md index bb16eb4..6755b4b 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ This image enables the SSH repository access function implemented in kallithea v ## Tags -- 0.6.3 - - Version 0.6.3 of the pip package. +- 0.7.0 + - Version 0.7.0 of the pip package. ## Data location @@ -97,6 +97,13 @@ If a port number to be published externally is specified, update the SSH URL tem This setting is applied to the database. This is a setting that can be updated in the Web UI. +- `KALLITHEA_LDAP_ENABLE` +If set to FORCE_ENABLE, change to enable LDAP authentication. (empty by default, not modify.) +This setting is applied to the database. +This is a setting that can be updated in the Web UI. +The UI and the following corresponding environment variables are set in the DB. +`KALLITHEA_LDAP_HOST`, `KALLITHEA_LDAP_PORT`, `KALLITHEA_LDAP_DN_USER`, `KALLITHEA_LDAP_DN_PASS`, `KALLITHEA_LDAP_TLS_KIND`, `KALLITHEA_LDAP_TLS_CERT`, `KALLITHEA_LDAP_CERT_DIR`, `KALLITHEA_LDAP_BASE_DN`, `KALLITHEA_LDAP_FILTER`, `KALLITHEA_LDAP_SCOPE`, `KALLITHEA_LDAP_ATTR_LOGIN`, `KALLITHEA_LDAP_ATTR_FIRSTNAME`, `KALLITHEA_LDAP_ATTR_LASTNAME`, `KALLITHEA_LDAP_ATTR_EMAIL` + - `KALLITHEA_DB_MIGRATION` If set to TRUE (capitals exactly), it will run in migration assistance mode. (empty by default) The support mode does not execute normal services, but functions as a migration execution support tool when upgrading. @@ -110,7 +117,7 @@ The following is an example of a simple docker-compose.yml for Sqlite. ``` services: app: - image: toras9000/kallithea-mp:0.6.3 + image: toras9000/kallithea-mp:0.7.0 restart: unless-stopped ports: - "8010:5000" diff --git a/build/Dockerfile b/build/Dockerfile index ff42c37..ad174b1 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -3,7 +3,7 @@ FROM ubuntu:20.04 ARG DEBIAN_FRONTEND=noninteractive # Pass the path in advance to the directory where kallithea is installed. -ENV PATH $PATH:/home/kallithea/.local/bin +ENV PATH=$PATH:/home/kallithea/.local/bin # set locale ENV LC_ALL=C.UTF-8 @@ -25,7 +25,7 @@ RUN <<-EOL useradd -m -c '' -g kallithea kallithea EOL -# Package version when installing by pip. ex.) 0.6.0 +# Package version when installing by pip. ex.) 0.7.0 ARG KALLITHEA_VER=x.x.x RUN <<-EOL @@ -34,9 +34,10 @@ RUN <<-EOL : This is only needed for kallithea installation. curl -sL https://deb.nodesource.com/setup_14.x | bash - - apt-get install -y --no-install-recommends \ - build-essential libffi-dev pkg-config \ - python3-dev libpq-dev libmysqlclient-dev \ + apt-get install -y --no-install-recommends \ + build-essential libffi-dev pkg-config \ + python3-dev libpq-dev libmysqlclient-dev \ + libldap2-dev libsasl2-dev slapd ldap-utils tox \ nodejs : Build su-exec @@ -46,13 +47,14 @@ RUN <<-EOL rm -rf /tmp/su-exec : Install pip. - curl -sL https://bootstrap.pypa.io/get-pip.py | su-exec kallithea:kallithea python3 - "setuptools < 58.0" --user + curl -sL https://bootstrap.pypa.io/get-pip.py | su-exec kallithea:kallithea python3 - "setuptools < 58.0" "pip < 24.1" --user : Install kallithea and optional packages. su-exec kallithea:kallithea python3 -m pip install --no-cache-dir --user \ kallithea${KALLITHEA_VER:+==$KALLITHEA_VER} \ psycopg2 \ - mysqlclient + mysqlclient \ + python-ldap : Preparing the front-end files. su-exec kallithea:kallithea kallithea-cli front-end-build diff --git a/build/assets/helper/exists-db-table.py b/build/assets/helper/exists-db-table.py index 3032409..51a4781 100644 --- a/build/assets/helper/exists-db-table.py +++ b/build/assets/helper/exists-db-table.py @@ -8,8 +8,7 @@ try: engine = sqlalchemy.engine.create_engine(db_uri) with engine.connect() as db: - db.connect() - exists = db.has_table(db_table) + exists = engine.has_table(db_table) if exists: sys.exit(0) diff --git a/build/assets/startup.sh b/build/assets/startup.sh index 70c7627..e163efb 100644 --- a/build/assets/startup.sh +++ b/build/assets/startup.sh @@ -235,6 +235,39 @@ if [ -n "$KALLITHEA_DB_URL" ]; then KALLITHEA_SSH_URI_TEMPL=ssh://{system_user}@{hostname}:${KALLITHEA_EXTERNAL_SSH_PORT}/{repo} upsert_db_setting 'clone_ssh_tmpl' "$KALLITHEA_SSH_URI_TEMPL" 'unicode' fi + + # Force enable LDAP + LDAP_SETTINGS_WRITE=$KALLITHEA_LDAP_ENABLE + if [ -z "$KALLITHEA_LDAP_HOST" ]; then LDAP_SETTINGS_WRITE=no; fi + if [ -z "$KALLITHEA_LDAP_ATTR_LOGIN" ]; then LDAP_SETTINGS_WRITE=no; fi + if [ -z "$KALLITHEA_LDAP_ATTR_FIRSTNAME" ]; then LDAP_SETTINGS_WRITE=no; fi + if [ -z "$KALLITHEA_LDAP_ATTR_LASTNAME" ]; then LDAP_SETTINGS_WRITE=no; fi + if [ -z "$KALLITHEA_LDAP_ATTR_EMAIL" ]; then LDAP_SETTINGS_WRITE=no; fi + if [ "$LDAP_SETTINGS_WRITE" = "TRUE" ]; then + echo '... Enable LDAP Settings' + # add LDAP plugin + AUTH_PLUGINS=$(get_db_setting 'auth_plugins') + if [[ "$AUTH_PLUGINS" != *kallithea.lib.auth_modules.auth_ldap* ]]; then + upsert_db_setting 'auth_plugins' "${AUTH_PLUGINS},kallithea.lib.auth_modules.auth_ldap" 'list' + fi + + # LDAP settings + upsert_db_setting 'auth_ldap_enabled' "True" 'unicode' + upsert_db_setting 'auth_ldap_host' "${KALLITHEA_LDAP_HOST}" 'unicode' + upsert_db_setting 'auth_ldap_port' "${KALLITHEA_LDAP_PORT}" 'unicode' + upsert_db_setting 'auth_ldap_dn_user' "${KALLITHEA_LDAP_DN_USER}" 'unicode' + upsert_db_setting 'auth_ldap_dn_pass' "${KALLITHEA_LDAP_DN_PASS}" 'unicode' + upsert_db_setting 'auth_ldap_tls_kind' "${KALLITHEA_LDAP_TLS_KIND:-LDAPS}" 'unicode' + upsert_db_setting 'auth_ldap_tls_reqcert' "${KALLITHEA_LDAP_TLS_CERT:-NEVER}" 'unicode' + upsert_db_setting 'auth_ldap_cacertdir' "${KALLITHEA_LDAP_CERT_DIR}" 'unicode' + upsert_db_setting 'auth_ldap_base_dn' "${KALLITHEA_LDAP_BASE_DN}" 'unicode' + upsert_db_setting 'auth_ldap_filter' "${KALLITHEA_LDAP_FILTER}" 'unicode' + upsert_db_setting 'auth_ldap_search_scope' "${KALLITHEA_LDAP_SCOPE:-ONELEVEL}" 'unicode' + upsert_db_setting 'auth_ldap_attr_login' "${KALLITHEA_LDAP_ATTR_LOGIN}" 'unicode' + upsert_db_setting 'auth_ldap_attr_firstname' "${KALLITHEA_LDAP_ATTR_FIRSTNAME}" 'unicode' + upsert_db_setting 'auth_ldap_attr_lastname' "${KALLITHEA_LDAP_ATTR_LASTNAME}" 'unicode' + upsert_db_setting 'auth_ldap_attr_email' "${KALLITHEA_LDAP_ATTR_EMAIL}" 'unicode' + fi fi echo "Start SSH server ..." diff --git a/docker-bake.hcl b/docker-bake.hcl index 52908bf..cafbb17 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -3,7 +3,7 @@ variable "WITH_LATEST_TAG" { } variable "KALLITHEA_IMAGE_VER" { - default = "0.6.3" + default = "0.7.0" } variable "KALLITHEA_FLAVOR" {