|
| 1 | +# archery集成ldap |
| 2 | + |
| 3 | +[archery集成ldap](https://github.com/hhyo/archery/wiki/auth#%E9%9B%86%E6%88%90ldap) |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | +编辑 `.env` 文件,写入以下内容 |
| 8 | + |
| 9 | +```shell |
| 10 | +ENABLE_LDAP=True |
| 11 | +AUTH_LDAP_SERVER_URI='ldap://10.31.0.17:389' |
| 12 | +AUTH_LDAP_BIND_DN='cn=xxx,dc=xxx,dc=xxx' |
| 13 | +AUTH_LDAP_BIND_PASSWORD='xxx' |
| 14 | +#AUTH_LDAP_USER_DN_TEMPLATE='uid=%(user)s,ou=people,dc=xxx,dc=xxx' |
| 15 | +AUTH_LDAP_ALWAYS_UPDATE_USER=True |
| 16 | +AUTH_LDAP_USER_ATTR_MAP={'username'='cn','name'='sn','email'='mail'} |
| 17 | +AUTH_LDAP_USER_SEARCH_BASE='dc=xxx,dc=xxx' |
| 18 | +``` |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | +配置完成后重启 `archery` 容器,日志输出如下 |
| 25 | + |
| 26 | +```shell |
| 27 | +2026-01-15 10:12:26,670 - archery.settings - INFO - 当前生效的外部认证方式:LDAP |
| 28 | +2026-01-15 10:12:26,671 - archery.settings - INFO - 认证后端:('django_auth_ldap.backend.LDAPBackend', 'django.contrib.auth.backends.ModelBackend') |
| 29 | +``` |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | + |
| 34 | + |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | +`archery` |
| 44 | + |
| 45 | +```shell |
| 46 | +[2026-01-15 10:16:47,934][MainThread:140663319430976][task_id:default][exception_logging_middleware.py:12][ERROR]- Traceback (most recent call last): |
| 47 | + File "/opt/venv4archery/lib/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response |
| 48 | + response = wrapped_callback(request, *callback_args, **callback_kwargs) |
| 49 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 50 | + File "/opt/venv4archery/lib/python3.11/site-packages/django/contrib/auth/decorators.py", line 22, in _wrapped_view |
| 51 | + if test_func(request.user): |
| 52 | + ^^^^^^^^^^^^^^^^^^^^^^^ |
| 53 | + File "/opt/venv4archery/lib/python3.11/site-packages/django/contrib/auth/decorators.py", line 78, in check_perms |
| 54 | + raise PermissionDenied |
| 55 | +django.core.exceptions.PermissionDenied |
| 56 | + |
| 57 | +2026-01-15 10:16:47,934 - default - ERROR - Traceback (most recent call last): |
| 58 | + File "/opt/venv4archery/lib/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response |
| 59 | + response = wrapped_callback(request, *callback_args, **callback_kwargs) |
| 60 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 61 | + File "/opt/venv4archery/lib/python3.11/site-packages/django/contrib/auth/decorators.py", line 22, in _wrapped_view |
| 62 | + if test_func(request.user): |
| 63 | + ^^^^^^^^^^^^^^^^^^^^^^^ |
| 64 | + File "/opt/venv4archery/lib/python3.11/site-packages/django/contrib/auth/decorators.py", line 78, in check_perms |
| 65 | + raise PermissionDenied |
| 66 | +django.core.exceptions.PermissionDenied |
| 67 | + |
| 68 | +2026-01-15 10:16:47,969 - django.request - WARNING - Forbidden (Permission denied): /sqlworkflow_list/ |
| 69 | +Traceback (most recent call last): |
| 70 | + File "/opt/venv4archery/lib/python3.11/site-packages/django/core/handlers/exception.py", line 56, in inner |
| 71 | + response = get_response(request) |
| 72 | + ^^^^^^^^^^^^^^^^^^^^^ |
| 73 | + File "/opt/venv4archery/lib/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response |
| 74 | + response = wrapped_callback(request, *callback_args, **callback_kwargs) |
| 75 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 76 | + File "/opt/venv4archery/lib/python3.11/site-packages/django/contrib/auth/decorators.py", line 22, in _wrapped_view |
| 77 | + if test_func(request.user): |
| 78 | + ^^^^^^^^^^^^^^^^^^^^^^^ |
| 79 | + File "/opt/venv4archery/lib/python3.11/site-packages/django/contrib/auth/decorators.py", line 78, in check_perms |
| 80 | + raise PermissionDenied |
| 81 | +django.core.exceptions.PermissionDenied |
| 82 | +``` |
| 83 | +
|
| 84 | +
|
| 85 | +
|
| 86 | +
|
| 87 | +
|
| 88 | +
|
| 89 | +
|
0 commit comments