LDAP身份验证在Gitea自定义图像上不工作

发布于 2025-02-12 20:04:34 字数 3756 浏览 0 评论 0原文

我正在开发一个具有Ansible和Docker组成的Docker基础架构,并且通过LDAP对Gitea的自定义图像进行身份验证有问题。 当我尝试使用LDAP中的一个用户时,我进入Gitea日志中的错误是:

”输入图像描述在这里”

您认为这是网络问题,还是LDAP的问题是找不到用户的问题? LDIF备份的恢复正常工作,因为它添加了我要登录的用户:

“在此处输入图像说明”

当我创建时也通过图形接口手动在Gitea中手动用户,在身份验证来源中,我找到了Ansible-LDAP。 解决这个问题的方法是什么?

这是我的配置:

app.ini(of gitea)

[DEFAULT]
RUN_USER = git
RUN_MODE = prod

...

[database]
PATH = /data/gitea/gitea.db
DB_TYPE = postgres
HOST = db:5432
NAME = gitea
USER = gitea
PASSWD = gitea
LOG_SQL = false

...

dockerfile

FROM gitea/gitea:1.16.8
RUN apk add sudo
RUN chmod 777 /home
COPY entrypoint /usr/bin/custom_entrypoint
COPY gitea-cli.sh /usr/bin/gitea-cli.sh
ENTRYPOINT /usr/bin/custom_entrypoint

入门点

#!/bin/sh
set -e
while ! nc -z $GITEA__database__HOST; do sleep 1; done;
chown -R 1000:1000 /data/gitea/conf
if ! [ -f /data/gitea.initialized ]; then
    gitea-cli.sh migrate
    gitea-cli.sh admin auth add-ldap --name ansible-ldap --host 127.0.0.1 --port 1389 --security-protocol unencrypted --user-search-base dc=ldap,dc=vcc,dc=unige,dc=it --admin-filter "(objectClass=giteaAdmin)" --user-filter "(&(objectClass=inetOrgPerson)(uid=%s))" --username-attribute uid --firstname-attribute givenName --surname-attribute surname --email-attribute mail --bind-dn cn=admin,dc=ldap,dc=vcc,dc=unige,dc=it --bind-password admin --allow-deactivate-all
    touch /data/gitea.initialized
fi
exec /usr/bin/entrypoint

gitea-cli.sh

#!/bin/sh
echo 'Started gitea-cli'
USER=git HOME=/data/git GITEA_WORK_DIR=/var/lib/gitea sudo -E -u git gitea --config /data/gitea/conf/app.ini "$@"

docker-compose.yaml

db:
    image: postgres:14.3
    restart: always
    hostname: db
    environment:
      POSTGRES_DB: gitea
      POSTGRES_USER: gitea
      POSTGRES_PASSWORD: gitea
    ports:
      - 5432:5432
    volumes:
      - /data/postgres:/var/lib/postgresql/data
    networks:
      - vcc

  openldap:
    image: bitnami/openldap:2.5
    ports:
      - 1389:1389
      - 1636:1636
    environment:
      BITNAMI_DEBUG: "true"
      LDAP_LOGLEVEL: 4
      LDAP_ADMIN_USERNAME: admin
      LDAP_ADMIN_PASSWORD: admin
      LDAP_ROOT: dc=ldap,dc=vcc,dc=unige,dc=it
      LDAP_CUSTOM_LDIF_DIR: /bitnami/openldap/backup
      LDAP_CUSTOM_SCHEMA_FILE: /bitnami/openldap/schema/schema.ldif
    volumes:
      - /data/openldap/:/bitnami/openldap
    networks:
      - vcc

  gitea:
    image: 127.0.0.1:5000/custom_gitea:51
    restart: always
    hostname: git.localdomain
    build: /data/gitea/custom
    ports:
      - 4000:4000
      - 222:22
    environment:
      USER: git
      USER_UID: 1000
      USER_GID: 1000
      GITEA__database__DB_TYPE: postgres
      GITEA__database__HOST: db:5432
      GITEA__database__NAME: gitea
      GITEA__database__USER: gitea
      GITEA__database__PASSWD: gitea
      GITEA__security__INSTALL_LOCK: "true"
      GITEA__security__SECRET_KEY: XQolFkmSxJWhxkZrkrGbPDbVrEwiZshnzPOY
    volumes:
      - /data/gitea:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
      - /data/gitea/app.ini:/data/gitea/conf/app.ini
    deploy:
      mode: global
    depends_on:
      - db
      - openldap
      - openldap_admin
    networks:
      - vcc

I'm developing a Docker infrastructure with Ansible and Docker Compose and I have a problem with the authentication via LDAP on my custom image of Gitea.
The error that i get inside the logs of Gitea when I try to use one of the users that are in the LDAP is:

enter image description here

Do you think that is a problem of network or is a problem of the LDAP that doesn't find the user?
The restoration of the LDIF backup works as expected because it adds the user that I'm trying to log:

enter image description here

Also when I create manually a user in Gitea via the graphic interface, in the authentication sources I find ansible-ldap.
What can be the solution to this problem?

This is my configuration:

app.ini (of Gitea)

[DEFAULT]
RUN_USER = git
RUN_MODE = prod

...

[database]
PATH = /data/gitea/gitea.db
DB_TYPE = postgres
HOST = db:5432
NAME = gitea
USER = gitea
PASSWD = gitea
LOG_SQL = false

...

Dockerfile

FROM gitea/gitea:1.16.8
RUN apk add sudo
RUN chmod 777 /home
COPY entrypoint /usr/bin/custom_entrypoint
COPY gitea-cli.sh /usr/bin/gitea-cli.sh
ENTRYPOINT /usr/bin/custom_entrypoint

entrypoint

#!/bin/sh
set -e
while ! nc -z $GITEA__database__HOST; do sleep 1; done;
chown -R 1000:1000 /data/gitea/conf
if ! [ -f /data/gitea.initialized ]; then
    gitea-cli.sh migrate
    gitea-cli.sh admin auth add-ldap --name ansible-ldap --host 127.0.0.1 --port 1389 --security-protocol unencrypted --user-search-base dc=ldap,dc=vcc,dc=unige,dc=it --admin-filter "(objectClass=giteaAdmin)" --user-filter "(&(objectClass=inetOrgPerson)(uid=%s))" --username-attribute uid --firstname-attribute givenName --surname-attribute surname --email-attribute mail --bind-dn cn=admin,dc=ldap,dc=vcc,dc=unige,dc=it --bind-password admin --allow-deactivate-all
    touch /data/gitea.initialized
fi
exec /usr/bin/entrypoint

gitea-cli.sh

#!/bin/sh
echo 'Started gitea-cli'
USER=git HOME=/data/git GITEA_WORK_DIR=/var/lib/gitea sudo -E -u git gitea --config /data/gitea/conf/app.ini "$@"

docker-compose.yaml

db:
    image: postgres:14.3
    restart: always
    hostname: db
    environment:
      POSTGRES_DB: gitea
      POSTGRES_USER: gitea
      POSTGRES_PASSWORD: gitea
    ports:
      - 5432:5432
    volumes:
      - /data/postgres:/var/lib/postgresql/data
    networks:
      - vcc

  openldap:
    image: bitnami/openldap:2.5
    ports:
      - 1389:1389
      - 1636:1636
    environment:
      BITNAMI_DEBUG: "true"
      LDAP_LOGLEVEL: 4
      LDAP_ADMIN_USERNAME: admin
      LDAP_ADMIN_PASSWORD: admin
      LDAP_ROOT: dc=ldap,dc=vcc,dc=unige,dc=it
      LDAP_CUSTOM_LDIF_DIR: /bitnami/openldap/backup
      LDAP_CUSTOM_SCHEMA_FILE: /bitnami/openldap/schema/schema.ldif
    volumes:
      - /data/openldap/:/bitnami/openldap
    networks:
      - vcc

  gitea:
    image: 127.0.0.1:5000/custom_gitea:51
    restart: always
    hostname: git.localdomain
    build: /data/gitea/custom
    ports:
      - 4000:4000
      - 222:22
    environment:
      USER: git
      USER_UID: 1000
      USER_GID: 1000
      GITEA__database__DB_TYPE: postgres
      GITEA__database__HOST: db:5432
      GITEA__database__NAME: gitea
      GITEA__database__USER: gitea
      GITEA__database__PASSWD: gitea
      GITEA__security__INSTALL_LOCK: "true"
      GITEA__security__SECRET_KEY: XQolFkmSxJWhxkZrkrGbPDbVrEwiZshnzPOY
    volumes:
      - /data/gitea:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
      - /data/gitea/app.ini:/data/gitea/conf/app.ini
    deploy:
      mode: global
    depends_on:
      - db
      - openldap
      - openldap_admin
    networks:
      - vcc

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

始于初秋 2025-02-19 20:04:34

问题是 - 主机的入门点文件中的地址127.0.0.1,将其更改为OpenLDAP(Docker-Compose文件中的服务名称)。

The problem was the address 127.0.0.1 in the entrypoint file in --host, changing it to openldap (name of the service in the docker-compose file) worked.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文