mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
Accept nested Active Directory groups in the LDAP group filter.
Since v12.08 (DirectoryGroupBleed) LDAP_USER_AUTHENTICATION=true logins check LDAP_GROUP_FILTER_ENABLE, which they did not do before. The membership clause (member=<user DN>) matches direct members only, so in Active Directory, where access is granted through a team group nested in the access group, legitimate users were refused, REST clients got 401, and the refusals were listed in Admin Panel / Problems as ldap.group-denied. LDAP_GROUP_FILTER_NESTED=true makes both group searches use AD's LDAP_MATCHING_RULE_IN_CHAIN, (member:1.2.840.113556.1.4.1941:=<user DN>), so the login filter and admin, role and org/team sync see nested membership. It is off by default, and an attribute already written as the extensible match is used as written. The user DN stays escaped, and a user who cannot be named is still refused without a search. Documented in LDAP.md with an upgrade note, and added to the Dockerfiles, docker-compose files, snap config and start-wekan scripts. tests/ldapNestedGroups.test.cjs drives isUserInGroup and getUserGroups with and without the setting, and checks that every member clause in ldap.js goes through groupMemberClause. Thanks to rmb82 and xet7 ! Fixes #6744.
This commit is contained in:
1 parent
2e42ce00d9
commit
dc2e7592a3
17 files changed
+318
-4
No files matched your search
@@ -105,6 +105,7 @@ ENV \
|
||||
LDAP_GROUP_FILTER_GROUP_ID_ATTRIBUTE="" \
|
||||
LDAP_GROUP_FILTER_GROUP_MEMBER_ATTRIBUTE="" \
|
||||
LDAP_GROUP_FILTER_GROUP_MEMBER_FORMAT="" \
|
||||
LDAP_GROUP_FILTER_NESTED=false \
|
||||
LDAP_GROUP_FILTER_GROUP_NAME="" \
|
||||
LDAP_UNIQUE_IDENTIFIER_FIELD="" \
|
||||
LDAP_UTF8_NAMES_SLUGIFY=true \
|
||||
|
||||
@@ -124,6 +124,7 @@ ENV \
|
||||
LDAP_GROUP_FILTER_GROUP_ID_ATTRIBUTE="" \
|
||||
LDAP_GROUP_FILTER_GROUP_MEMBER_ATTRIBUTE="" \
|
||||
LDAP_GROUP_FILTER_GROUP_MEMBER_FORMAT="" \
|
||||
LDAP_GROUP_FILTER_NESTED=false \
|
||||
LDAP_GROUP_FILTER_GROUP_NAME="" \
|
||||
LDAP_UNIQUE_IDENTIFIER_FIELD="" \
|
||||
LDAP_UTF8_NAMES_SLUGIFY=true \
|
||||
|
||||
@@ -751,6 +751,14 @@ services:
|
||||
# The format of the value of LDAP_GROUP_FILTER_GROUP_MEMBER_ATTRIBUTE. Example: 'dn' if the users dn is saved as value into the attribute.
|
||||
#- LDAP_GROUP_FILTER_GROUP_MEMBER_FORMAT=
|
||||
#
|
||||
# Active Directory nested groups (#6744). When true, a user who is a member of
|
||||
# LDAP_GROUP_FILTER_GROUP_NAME through another group (team group -> access
|
||||
# group) is a member too: the group searches use AD's
|
||||
# LDAP_MATCHING_RULE_IN_CHAIN (1.2.840.113556.1.4.1941). Needs a DN-valued
|
||||
# member attribute (member, with LDAP_GROUP_FILTER_GROUP_MEMBER_FORMAT=dn).
|
||||
# Also applies to admin status, group->role and org/team sync. Default: false.
|
||||
#- LDAP_GROUP_FILTER_NESTED=true
|
||||
#
|
||||
# The group name (id) that matches all users.
|
||||
#- LDAP_GROUP_FILTER_GROUP_NAME=
|
||||
#
|
||||
|
||||
@@ -753,6 +753,14 @@ services:
|
||||
# The format of the value of LDAP_GROUP_FILTER_GROUP_MEMBER_ATTRIBUTE. Example: 'dn' if the users dn is saved as value into the attribute.
|
||||
#- LDAP_GROUP_FILTER_GROUP_MEMBER_FORMAT=
|
||||
#
|
||||
# Active Directory nested groups (#6744). When true, a user who is a member of
|
||||
# LDAP_GROUP_FILTER_GROUP_NAME through another group (team group -> access
|
||||
# group) is a member too: the group searches use AD's
|
||||
# LDAP_MATCHING_RULE_IN_CHAIN (1.2.840.113556.1.4.1941). Needs a DN-valued
|
||||
# member attribute (member, with LDAP_GROUP_FILTER_GROUP_MEMBER_FORMAT=dn).
|
||||
# Also applies to admin status, group->role and org/team sync. Default: false.
|
||||
#- LDAP_GROUP_FILTER_NESTED=true
|
||||
#
|
||||
# The group name (id) that matches all users.
|
||||
#- LDAP_GROUP_FILTER_GROUP_NAME=
|
||||
#
|
||||
|
||||
@@ -740,6 +740,14 @@ services:
|
||||
# The format of the value of LDAP_GROUP_FILTER_GROUP_MEMBER_ATTRIBUTE. Example: 'dn' if the users dn is saved as value into the attribute.
|
||||
#- LDAP_GROUP_FILTER_GROUP_MEMBER_FORMAT=
|
||||
#
|
||||
# Active Directory nested groups (#6744). When true, a user who is a member of
|
||||
# LDAP_GROUP_FILTER_GROUP_NAME through another group (team group -> access
|
||||
# group) is a member too: the group searches use AD's
|
||||
# LDAP_MATCHING_RULE_IN_CHAIN (1.2.840.113556.1.4.1941). Needs a DN-valued
|
||||
# member attribute (member, with LDAP_GROUP_FILTER_GROUP_MEMBER_FORMAT=dn).
|
||||
# Also applies to admin status, group->role and org/team sync. Default: false.
|
||||
#- LDAP_GROUP_FILTER_NESTED=true
|
||||
#
|
||||
# The group name (id) that matches all users.
|
||||
#- LDAP_GROUP_FILTER_GROUP_NAME=
|
||||
#
|
||||
|
||||
@@ -757,6 +757,14 @@ services:
|
||||
# The format of the value of LDAP_GROUP_FILTER_GROUP_MEMBER_ATTRIBUTE. Example: 'dn' if the users dn is saved as value into the attribute.
|
||||
#- LDAP_GROUP_FILTER_GROUP_MEMBER_FORMAT=
|
||||
#
|
||||
# Active Directory nested groups (#6744). When true, a user who is a member of
|
||||
# LDAP_GROUP_FILTER_GROUP_NAME through another group (team group -> access
|
||||
# group) is a member too: the group searches use AD's
|
||||
# LDAP_MATCHING_RULE_IN_CHAIN (1.2.840.113556.1.4.1941). Needs a DN-valued
|
||||
# member attribute (member, with LDAP_GROUP_FILTER_GROUP_MEMBER_FORMAT=dn).
|
||||
# Also applies to admin status, group->role and org/team sync. Default: false.
|
||||
#- LDAP_GROUP_FILTER_NESTED=true
|
||||
#
|
||||
# The group name (id) that matches all users.
|
||||
#- LDAP_GROUP_FILTER_GROUP_NAME=
|
||||
#
|
||||
|
||||
@@ -660,6 +660,14 @@ services:
|
||||
# The format of the value of LDAP_GROUP_FILTER_GROUP_MEMBER_ATTRIBUTE. Example: 'dn' if the users dn is saved as value into the attribute.
|
||||
#- LDAP_GROUP_FILTER_GROUP_MEMBER_FORMAT=
|
||||
#
|
||||
# Active Directory nested groups (#6744). When true, a user who is a member of
|
||||
# LDAP_GROUP_FILTER_GROUP_NAME through another group (team group -> access
|
||||
# group) is a member too: the group searches use AD's
|
||||
# LDAP_MATCHING_RULE_IN_CHAIN (1.2.840.113556.1.4.1941). Needs a DN-valued
|
||||
# member attribute (member, with LDAP_GROUP_FILTER_GROUP_MEMBER_FORMAT=dn).
|
||||
# Also applies to admin status, group->role and org/team sync. Default: false.
|
||||
#- LDAP_GROUP_FILTER_NESTED=true
|
||||
#
|
||||
# The group name (id) that matches all users.
|
||||
#- LDAP_GROUP_FILTER_GROUP_NAME=
|
||||
#
|
||||
|
||||
@@ -894,6 +894,14 @@ services:
|
||||
# The format of the value of LDAP_GROUP_FILTER_GROUP_MEMBER_ATTRIBUTE. Example: 'dn' if the users dn is saved as value into the attribute.
|
||||
#- LDAP_GROUP_FILTER_GROUP_MEMBER_FORMAT=
|
||||
#
|
||||
# Active Directory nested groups (#6744). When true, a user who is a member of
|
||||
# LDAP_GROUP_FILTER_GROUP_NAME through another group (team group -> access
|
||||
# group) is a member too: the group searches use AD's
|
||||
# LDAP_MATCHING_RULE_IN_CHAIN (1.2.840.113556.1.4.1941). Needs a DN-valued
|
||||
# member attribute (member, with LDAP_GROUP_FILTER_GROUP_MEMBER_FORMAT=dn).
|
||||
# Also applies to admin status, group->role and org/team sync. Default: false.
|
||||
#- LDAP_GROUP_FILTER_NESTED=true
|
||||
#
|
||||
# The group name (id) that matches all users.
|
||||
#- LDAP_GROUP_FILTER_GROUP_NAME=
|
||||
#
|
||||
|
||||
@@ -717,6 +717,14 @@ services:
|
||||
# The format of the value of LDAP_GROUP_FILTER_GROUP_MEMBER_ATTRIBUTE. Example: 'dn' if the users dn is saved as value into the attribute.
|
||||
#- LDAP_GROUP_FILTER_GROUP_MEMBER_FORMAT=
|
||||
#
|
||||
# Active Directory nested groups (#6744). When true, a user who is a member of
|
||||
# LDAP_GROUP_FILTER_GROUP_NAME through another group (team group -> access
|
||||
# group) is a member too: the group searches use AD's
|
||||
# LDAP_MATCHING_RULE_IN_CHAIN (1.2.840.113556.1.4.1941). Needs a DN-valued
|
||||
# member attribute (member, with LDAP_GROUP_FILTER_GROUP_MEMBER_FORMAT=dn).
|
||||
# Also applies to admin status, group->role and org/team sync. Default: false.
|
||||
#- LDAP_GROUP_FILTER_NESTED=true
|
||||
#
|
||||
# The group name (id) that matches all users.
|
||||
#- LDAP_GROUP_FILTER_GROUP_NAME=
|
||||
#
|
||||
|
||||
@@ -471,6 +471,14 @@ services:
|
||||
# LDAP_GROUP_FILTER_GROUP_MEMBER_FORMAT :
|
||||
# example :
|
||||
- LDAP_GROUP_FILTER_GROUP_MEMBER_FORMAT=
|
||||
# LDAP_GROUP_FILTER_NESTED : Active Directory nested groups (#6744). When true, a user who is a member of
|
||||
# LDAP_GROUP_FILTER_GROUP_NAME through another group (team group -> access
|
||||
# group) is a member too: the group searches use AD's
|
||||
# LDAP_MATCHING_RULE_IN_CHAIN (1.2.840.113556.1.4.1941). Needs a DN-valued
|
||||
# member attribute (member, with LDAP_GROUP_FILTER_GROUP_MEMBER_FORMAT=dn).
|
||||
# Also applies to admin status, group->role and org/team sync. Default: false.
|
||||
# example : LDAP_GROUP_FILTER_NESTED=true
|
||||
- LDAP_GROUP_FILTER_NESTED=false
|
||||
# LDAP_GROUP_FILTER_GROUP_NAME :
|
||||
# example :
|
||||
- LDAP_GROUP_FILTER_GROUP_NAME=
|
||||
@@ -564,3 +572,39 @@ Service-search mode checks membership before rebinding as the user.
|
||||
Blocked credential and group-policy attempts are summarized in Admin Panel /
|
||||
Problems. See the [authentication boundary audit](../../Security/Authentication-Boundary-Audit-2026-09-27.md)
|
||||
for validation coverage and deployment limitations.
|
||||
|
||||
### Active Directory nested groups
|
||||
|
||||
`LDAP_GROUP_FILTER_GROUP_MEMBER_ATTRIBUTE=member` matches only DIRECT members of
|
||||
`LDAP_GROUP_FILTER_GROUP_NAME`. In Active Directory, access is usually granted
|
||||
through nested groups: a user is in a team group, and the team group is a member
|
||||
of the application access group. To accept those users, set:
|
||||
|
||||
```
|
||||
LDAP_GROUP_FILTER_NESTED=true
|
||||
LDAP_GROUP_FILTER_GROUP_MEMBER_ATTRIBUTE=member
|
||||
LDAP_GROUP_FILTER_GROUP_MEMBER_FORMAT=dn
|
||||
```
|
||||
|
||||
The group searches then use Active Directory's `LDAP_MATCHING_RULE_IN_CHAIN`,
|
||||
`(member:1.2.840.113556.1.4.1941:=<user DN>)`, which follows group-in-group
|
||||
membership to any depth. The same searches feed admin status sync, group->role
|
||||
sync and Organizations/Teams sync, so those see nested groups too: a user who
|
||||
is in an `LDAP_SYNC_ADMIN_GROUPS` group through another group becomes an admin.
|
||||
|
||||
This matching rule is an Active Directory feature. OpenLDAP, FreeIPA and Samba
|
||||
directories without it keep `LDAP_GROUP_FILTER_NESTED=false`, the default.
|
||||
|
||||
Writing the rule into the attribute itself,
|
||||
`LDAP_GROUP_FILTER_GROUP_MEMBER_ATTRIBUTE=member:1.2.840.113556.1.4.1941:`,
|
||||
also works and is used as written; `LDAP_GROUP_FILTER_NESTED=true` is the
|
||||
documented way.
|
||||
|
||||
**Upgrading from before v12.08:** with `LDAP_USER_AUTHENTICATION=true`, versions
|
||||
before v12.08 did not check `LDAP_GROUP_FILTER_ENABLE` at all, so every directory
|
||||
user could log in - including members of nested groups, and also users in no
|
||||
allowed group. v12.08 enforces the group filter (DirectoryGroupBleed). An Active
|
||||
Directory deployment that grants access through nested groups needs
|
||||
`LDAP_GROUP_FILTER_NESTED=true` after upgrading, or those users are refused and
|
||||
appear in Admin Panel / Problems as `ldap.group-denied`
|
||||
([#6744](https://github.com/wekan/wekan/issues/6744)).
|
||||
@@ -34,6 +34,26 @@ function loginGroupNames(options, adminSyncEnabled, adminGroupNames) {
|
||||
return splitGroupNames([names.join(','), adminGroupNames].filter(Boolean).join(','));
|
||||
}
|
||||
|
||||
// #6744: Active Directory's LDAP_MATCHING_RULE_IN_CHAIN. `member=<dn>` matches
|
||||
// only DIRECT members, so a user who gets access through a team group nested in
|
||||
// the access group was refused. With this rule the directory follows the
|
||||
// group-in-group chain to any depth and answers with every group the user is
|
||||
// in, directly or not.
|
||||
const AD_IN_CHAIN_RULE = '1.2.840.113556.1.4.1941';
|
||||
|
||||
// The one clause that names the user in a group search. `escapedValue` must
|
||||
// already be escaped for an LDAP filter. LDAP_GROUP_FILTER_NESTED=true asks for
|
||||
// nested membership; an attribute already written as an extensible match
|
||||
// (`member:1.2.840.113556.1.4.1941:`, the workaround from #6744) is used as
|
||||
// written, so turning the setting on beside it does not produce `member:...::`.
|
||||
function groupMemberClause(options, escapedValue) {
|
||||
const attribute = String(options.group_filter_group_member_attribute || '').trim();
|
||||
if (options.group_filter_nested === true && !attribute.includes(':')) {
|
||||
return `(${attribute}:${AD_IN_CHAIN_RULE}:=${escapedValue})`;
|
||||
}
|
||||
return `(${attribute}=${escapedValue})`;
|
||||
}
|
||||
|
||||
function missingLoginGroupFilterSettings(options, adminGroupNames = '') {
|
||||
const missing = missingGroupLookupSettings(options);
|
||||
if (splitGroupNames(
|
||||
@@ -49,4 +69,6 @@ module.exports = {
|
||||
missingLoginGroupFilterSettings,
|
||||
splitGroupNames,
|
||||
loginGroupNames,
|
||||
groupMemberClause,
|
||||
AD_IN_CHAIN_RULE,
|
||||
};
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
missingGroupLookupSettings,
|
||||
missingLoginGroupFilterSettings,
|
||||
loginGroupNames,
|
||||
groupMemberClause,
|
||||
} from './groupFilterConfig';
|
||||
import { resolveConfigValue } from './configResolver';
|
||||
import { requireUserCredentials, escapeUserDnValue } from './userCredentials';
|
||||
@@ -162,6 +163,9 @@ export default class LDAP {
|
||||
group_filter_group_member_attribute: this.constructor.settings_get('LDAP_GROUP_FILTER_GROUP_MEMBER_ATTRIBUTE'),
|
||||
group_filter_group_member_format : this.constructor.settings_get('LDAP_GROUP_FILTER_GROUP_MEMBER_FORMAT'),
|
||||
group_filter_group_name : this.constructor.settings_get('LDAP_GROUP_FILTER_GROUP_NAME'),
|
||||
// #6744: Active Directory nested groups (team group -> access group).
|
||||
// Off unless exactly true, so an existing install keeps direct membership.
|
||||
group_filter_nested : this.constructor.settings_get('LDAP_GROUP_FILTER_NESTED') === true,
|
||||
AD_Simple_Auth : this.constructor.settings_get('LDAP_AD_SIMPLE_AUTH'),
|
||||
Default_Domain : this.constructor.settings_get('LDAP_DEFAULT_DOMAIN'),
|
||||
};
|
||||
@@ -622,7 +626,9 @@ export default class LDAP {
|
||||
return [];
|
||||
}
|
||||
|
||||
filter.push(`(${this.options.group_filter_group_member_attribute}=${escapeLdapFilterValue(format_value)})`);
|
||||
// #6744: with LDAP_GROUP_FILTER_NESTED, also the groups the user is in
|
||||
// through other groups, so admin, role and org/team sync see them too.
|
||||
filter.push(groupMemberClause(this.options, escapeLdapFilterValue(format_value)));
|
||||
}
|
||||
|
||||
filter.push(')');
|
||||
@@ -695,7 +701,8 @@ export default class LDAP {
|
||||
ldapUser.dn || ldapUser.objectName || ldapUser.distinguishedName;
|
||||
// Never turn a membership query into a search for any allowed group.
|
||||
if (typeof format_value !== 'string' || !format_value) return false;
|
||||
filter.push(`(${this.options.group_filter_group_member_attribute}=${escapeLdapFilterValue(format_value)})`);
|
||||
// #6744: a member of the allowed group through a nested group is a member.
|
||||
filter.push(groupMemberClause(this.options, escapeLdapFilterValue(format_value)));
|
||||
}
|
||||
|
||||
if (this.options.group_filter_group_id_attribute !== '') {
|
||||
|
||||
+5
-1
@@ -3,7 +3,7 @@
|
||||
# All supported keys are defined here together with descriptions and default values
|
||||
|
||||
# list of supported keys
|
||||
keys="WEKAN_AUTOPICK WEKAN_AUTOPICK_TIMEOUT DEBUG BIND_IP MAIL_TLS_CA_CERT MAIL_TLS_SERVERNAME WEBHOOK_TLS_CA_CERT WEKAN_FERRETDB_OPLOG WEKAN_FERRETDB_HANDLER WEKAN_FERRETDB_URL DDP_TRANSPORT METEOR_REACTIVITY_ORDER MONGO_LOG_DESTINATION MONGO_URL MONGO_OPLOG_URL MONGODB_BIND_UNIX_SOCKET MONGODB_BIND_IP MONGODB_PORT MAIL_URL MAIL_FROM MAIL_SERVICE MAIL_SERVICE_USER MAIL_SERVICE_PASSWORD ROOT_URL PORT DISABLE_MONGODB CADDY_ENABLED CADDY_BIND_PORT WITH_API CARDS_LOADING CARD_OPENED_WEBHOOK_ENABLED ACCOUNTS_LOCKOUT_KNOWN_USERS_FAILURES_BEFORE ACCOUNTS_LOCKOUT_KNOWN_USERS_PERIOD ACCOUNTS_LOCKOUT_KNOWN_USERS_FAILURE_WINDOW ACCOUNTS_LOCKOUT_UNKNOWN_USERS_FAILURES_BERORE ACCOUNTS_LOCKOUT_UNKNOWN_USERS_LOCKOUT_PERIOD ACCOUNTS_LOCKOUT_UNKNOWN_USERS_FAILURE_WINDOW ACCOUNTS_COMMON_LOGIN_EXPIRATION_IN_DAYS ATTACHMENTS_UPLOAD_EXTERNAL_PROGRAM ATTACHMENTS_UPLOAD_MIME_TYPES ATTACHMENTS_UPLOAD_MAX_SIZE AVATARS_UPLOAD_EXTERNAL_PROGRAM AVATARS_UPLOAD_MIME_TYPES AVATARS_UPLOAD_MAX_SIZE MAX_IMAGE_PIXEL IMAGE_COMPRESS_RATIO BIGEVENTS_PATTERN NOTIFICATION_TRAY_AFTER_READ_DAYS_BEFORE_REMOVE NOTIFY_DUE_DAYS_BEFORE_AND_AFTER NOTIFY_DUE_AT_HOUR_OF_DAY DEFAULT_BOARD_ID EMAIL_NOTIFICATION_TIMEOUT CORS CORS_ALLOW_HEADERS CORS_EXPOSE_HEADERS MATOMO_ADDRESS MATOMO_SITE_ID MATOMO_DO_NOT_TRACK MATOMO_WITH_USERNAME METRICS_ALLOWED_IP_ADDRESSES BROWSER_POLICY_ENABLED TRUSTED_URL WEBHOOKS_ATTRIBUTES OAUTH2_ENABLED OIDC_REDIRECTION_ENABLED OAUTH2_CA_CERT OAUTH2_LOGIN_STYLE OAUTH2_CLIENT_ID OAUTH2_SECRET OAUTH2_SERVER_URL OAUTH2_AUTH_ENDPOINT OAUTH2_USERINFO_ENDPOINT OAUTH2_TOKEN_ENDPOINT OAUTH2_LOGOUT_ENDPOINT OAUTH2_ID_MAP OAUTH2_USERNAME_MAP OAUTH2_FULLNAME_MAP OAUTH2_ID_TOKEN_WHITELIST_FIELDS OAUTH2_EMAIL_MAP OAUTH2_REQUEST_PERMISSIONS OAUTH2_ADFS_ENABLED OAUTH2_B2C_ENABLED OAUTH2_MERGE_EXISTING_USERS LDAP_ENABLE LDAP_PORT LDAP_HOST LDAP_AD_SIMPLE_AUTH LDAP_BASEDN LDAP_LOGIN_FALLBACK LDAP_RECONNECT LDAP_TIMEOUT LDAP_IDLE_TIMEOUT LDAP_CONNECT_TIMEOUT LDAP_AUTHENTIFICATION LDAP_AUTHENTIFICATION_USERDN LDAP_AUTHENTIFICATION_PASSWORD LDAP_LOG_ENABLED LDAP_BACKGROUND_SYNC LDAP_BACKGROUND_SYNC_INTERVAL LDAP_BACKGROUND_SYNC_KEEP_EXISTANT_USERS_UPDATED LDAP_BACKGROUND_SYNC_IMPORT_NEW_USERS LDAP_ENCRYPTION LDAP_CA_CERT LDAP_REJECT_UNAUTHORIZED LDAP_USER_AUTHENTICATION LDAP_USER_AUTHENTICATION_FIELD LDAP_USER_SEARCH_FILTER LDAP_USER_SEARCH_SCOPE LDAP_USER_SEARCH_FIELD LDAP_SEARCH_PAGE_SIZE LDAP_SEARCH_SIZE_LIMIT LDAP_GROUP_FILTER_ENABLE LDAP_GROUP_FILTER_OBJECTCLASS LDAP_GROUP_FILTER_GROUP_ID_ATTRIBUTE LDAP_GROUP_FILTER_GROUP_MEMBER_ATTRIBUTE LDAP_GROUP_FILTER_GROUP_MEMBER_FORMAT LDAP_GROUP_FILTER_GROUP_NAME LDAP_UNIQUE_IDENTIFIER_FIELD LDAP_UTF8_NAMES_SLUGIFY LDAP_USERNAME_FIELD LDAP_FULLNAME_FIELD LDAP_MERGE_EXISTING_USERS LDAP_SYNC_USER_DATA LDAP_SYNC_USER_DATA_FIELDMAP LDAP_SYNC_GROUP_ROLES LDAP_DEFAULT_DOMAIN LDAP_EMAIL_MATCH_ENABLE LDAP_EMAIL_MATCH_REQUIRE LDAP_EMAIL_MATCH_VERIFIED LDAP_EMAIL_FIELD LDAP_SYNC_ADMIN_STATUS LDAP_SYNC_ADMIN_GROUPS HEADER_LOGIN_ID HEADER_LOGIN_FIRSTNAME HEADER_LOGIN_LASTNAME HEADER_LOGIN_EMAIL HEADER_LOGIN_TRUSTED_IPS HEADER_LOGIN_TRUSTED_PROXIES LOGOUT_WITH_TIMER LOGOUT_IN LOGOUT_ON_HOURS LOGOUT_ON_MINUTES DEFAULT_AUTHENTICATION_METHOD PASSWORD_LOGIN_ENABLED CAS_ENABLED CAS_BASE_URL CAS_LOGIN_URL CAS_VALIDATE_URL SAML_ENABLED SAML_PROVIDER SAML_ENTRYPOINT SAML_ISSUER SAML_CERT SAML_IDPSLO_REDIRECTURL SAML_PRIVATE_KEYFILE SAML_PUBLIC_CERTFILE SAML_IDENTIFIER_FORMAT SAML_LOCAL_PROFILE_MATCH_ATTRIBUTE SAML_ATTRIBUTES SAML_MERGE_EXISTING_USERS SAML_IDP_PROFILE SAML_WANT_RESPONSE_SIGNED SAML_WANT_ASSERTIONS_SIGNED SAML_LOGIN_FLOW OAUTH_GOOGLE_ENABLED OAUTH_GOOGLE_CLIENT_ID OAUTH_GOOGLE_SECRET OAUTH_GOOGLE_SECRET_FILE OAUTH_GITHUB_ENABLED OAUTH_GITHUB_CLIENT_ID OAUTH_GITHUB_SECRET OAUTH_GITHUB_SECRET_FILE OAUTH_FACEBOOK_ENABLED OAUTH_FACEBOOK_APP_ID OAUTH_FACEBOOK_SECRET OAUTH_FACEBOOK_SECRET_FILE OAUTH_TWITTER_ENABLED OAUTH_TWITTER_CONSUMER_KEY OAUTH_TWITTER_SECRET OAUTH_TWITTER_SECRET_FILE OAUTH_METEOR_DEVELOPER_ENABLED OAUTH_METEOR_DEVELOPER_CLIENT_ID OAUTH_METEOR_DEVELOPER_SECRET OAUTH_METEOR_DEVELOPER_SECRET_FILE OAUTH_WEIBO_ENABLED OAUTH_WEIBO_CLIENT_ID OAUTH_WEIBO_SECRET OAUTH_WEIBO_SECRET_FILE OAUTH_MEETUP_ENABLED OAUTH_MEETUP_CLIENT_ID OAUTH_MEETUP_SECRET OAUTH_MEETUP_SECRET_FILE OAUTH_PROVIDERS_LOGIN_STYLE OAUTH_PROVIDERS_MERGE_EXISTING_USERS PASSWORDLESS_ENABLED ORACLE_OIM_ENABLED RESULTS_PER_PAGE WAIT_SPINNER NODE_OPTIONS LDAP_AUTHENTIFICATION_PASSWORD_FILE OAUTH2_SECRET_FILE MAIL_SERVICE_PASSWORD_FILE MONGO_PASSWORD_FILE S3 S3_SECRET_FILE OAUTH2_AUTO_REGISTRATION OAUTH2_ADMIN_GROUPS NOTIFY_ON_ASSIGN LDAP_BACKGROUND_SYNC_DISABLE_NONEXISTANT_USERS LDAP_SYNC_ORGANIZATIONS LDAP_SYNC_ORGANIZATIONS_GROUPS LDAP_SYNC_TEAMS LDAP_SYNC_TEAMS_GROUPS"
|
||||
keys="WEKAN_AUTOPICK WEKAN_AUTOPICK_TIMEOUT DEBUG BIND_IP MAIL_TLS_CA_CERT MAIL_TLS_SERVERNAME WEBHOOK_TLS_CA_CERT WEKAN_FERRETDB_OPLOG WEKAN_FERRETDB_HANDLER WEKAN_FERRETDB_URL DDP_TRANSPORT METEOR_REACTIVITY_ORDER MONGO_LOG_DESTINATION MONGO_URL MONGO_OPLOG_URL MONGODB_BIND_UNIX_SOCKET MONGODB_BIND_IP MONGODB_PORT MAIL_URL MAIL_FROM MAIL_SERVICE MAIL_SERVICE_USER MAIL_SERVICE_PASSWORD ROOT_URL PORT DISABLE_MONGODB CADDY_ENABLED CADDY_BIND_PORT WITH_API CARDS_LOADING CARD_OPENED_WEBHOOK_ENABLED ACCOUNTS_LOCKOUT_KNOWN_USERS_FAILURES_BEFORE ACCOUNTS_LOCKOUT_KNOWN_USERS_PERIOD ACCOUNTS_LOCKOUT_KNOWN_USERS_FAILURE_WINDOW ACCOUNTS_LOCKOUT_UNKNOWN_USERS_FAILURES_BERORE ACCOUNTS_LOCKOUT_UNKNOWN_USERS_LOCKOUT_PERIOD ACCOUNTS_LOCKOUT_UNKNOWN_USERS_FAILURE_WINDOW ACCOUNTS_COMMON_LOGIN_EXPIRATION_IN_DAYS ATTACHMENTS_UPLOAD_EXTERNAL_PROGRAM ATTACHMENTS_UPLOAD_MIME_TYPES ATTACHMENTS_UPLOAD_MAX_SIZE AVATARS_UPLOAD_EXTERNAL_PROGRAM AVATARS_UPLOAD_MIME_TYPES AVATARS_UPLOAD_MAX_SIZE MAX_IMAGE_PIXEL IMAGE_COMPRESS_RATIO BIGEVENTS_PATTERN NOTIFICATION_TRAY_AFTER_READ_DAYS_BEFORE_REMOVE NOTIFY_DUE_DAYS_BEFORE_AND_AFTER NOTIFY_DUE_AT_HOUR_OF_DAY DEFAULT_BOARD_ID EMAIL_NOTIFICATION_TIMEOUT CORS CORS_ALLOW_HEADERS CORS_EXPOSE_HEADERS MATOMO_ADDRESS MATOMO_SITE_ID MATOMO_DO_NOT_TRACK MATOMO_WITH_USERNAME METRICS_ALLOWED_IP_ADDRESSES BROWSER_POLICY_ENABLED TRUSTED_URL WEBHOOKS_ATTRIBUTES OAUTH2_ENABLED OIDC_REDIRECTION_ENABLED OAUTH2_CA_CERT OAUTH2_LOGIN_STYLE OAUTH2_CLIENT_ID OAUTH2_SECRET OAUTH2_SERVER_URL OAUTH2_AUTH_ENDPOINT OAUTH2_USERINFO_ENDPOINT OAUTH2_TOKEN_ENDPOINT OAUTH2_LOGOUT_ENDPOINT OAUTH2_ID_MAP OAUTH2_USERNAME_MAP OAUTH2_FULLNAME_MAP OAUTH2_ID_TOKEN_WHITELIST_FIELDS OAUTH2_EMAIL_MAP OAUTH2_REQUEST_PERMISSIONS OAUTH2_ADFS_ENABLED OAUTH2_B2C_ENABLED OAUTH2_MERGE_EXISTING_USERS LDAP_ENABLE LDAP_PORT LDAP_HOST LDAP_AD_SIMPLE_AUTH LDAP_BASEDN LDAP_LOGIN_FALLBACK LDAP_RECONNECT LDAP_TIMEOUT LDAP_IDLE_TIMEOUT LDAP_CONNECT_TIMEOUT LDAP_AUTHENTIFICATION LDAP_AUTHENTIFICATION_USERDN LDAP_AUTHENTIFICATION_PASSWORD LDAP_LOG_ENABLED LDAP_BACKGROUND_SYNC LDAP_BACKGROUND_SYNC_INTERVAL LDAP_BACKGROUND_SYNC_KEEP_EXISTANT_USERS_UPDATED LDAP_BACKGROUND_SYNC_IMPORT_NEW_USERS LDAP_ENCRYPTION LDAP_CA_CERT LDAP_REJECT_UNAUTHORIZED LDAP_USER_AUTHENTICATION LDAP_USER_AUTHENTICATION_FIELD LDAP_USER_SEARCH_FILTER LDAP_USER_SEARCH_SCOPE LDAP_USER_SEARCH_FIELD LDAP_SEARCH_PAGE_SIZE LDAP_SEARCH_SIZE_LIMIT LDAP_GROUP_FILTER_ENABLE LDAP_GROUP_FILTER_OBJECTCLASS LDAP_GROUP_FILTER_GROUP_ID_ATTRIBUTE LDAP_GROUP_FILTER_GROUP_MEMBER_ATTRIBUTE LDAP_GROUP_FILTER_GROUP_MEMBER_FORMAT LDAP_GROUP_FILTER_NESTED LDAP_GROUP_FILTER_GROUP_NAME LDAP_UNIQUE_IDENTIFIER_FIELD LDAP_UTF8_NAMES_SLUGIFY LDAP_USERNAME_FIELD LDAP_FULLNAME_FIELD LDAP_MERGE_EXISTING_USERS LDAP_SYNC_USER_DATA LDAP_SYNC_USER_DATA_FIELDMAP LDAP_SYNC_GROUP_ROLES LDAP_DEFAULT_DOMAIN LDAP_EMAIL_MATCH_ENABLE LDAP_EMAIL_MATCH_REQUIRE LDAP_EMAIL_MATCH_VERIFIED LDAP_EMAIL_FIELD LDAP_SYNC_ADMIN_STATUS LDAP_SYNC_ADMIN_GROUPS HEADER_LOGIN_ID HEADER_LOGIN_FIRSTNAME HEADER_LOGIN_LASTNAME HEADER_LOGIN_EMAIL HEADER_LOGIN_TRUSTED_IPS HEADER_LOGIN_TRUSTED_PROXIES LOGOUT_WITH_TIMER LOGOUT_IN LOGOUT_ON_HOURS LOGOUT_ON_MINUTES DEFAULT_AUTHENTICATION_METHOD PASSWORD_LOGIN_ENABLED CAS_ENABLED CAS_BASE_URL CAS_LOGIN_URL CAS_VALIDATE_URL SAML_ENABLED SAML_PROVIDER SAML_ENTRYPOINT SAML_ISSUER SAML_CERT SAML_IDPSLO_REDIRECTURL SAML_PRIVATE_KEYFILE SAML_PUBLIC_CERTFILE SAML_IDENTIFIER_FORMAT SAML_LOCAL_PROFILE_MATCH_ATTRIBUTE SAML_ATTRIBUTES SAML_MERGE_EXISTING_USERS SAML_IDP_PROFILE SAML_WANT_RESPONSE_SIGNED SAML_WANT_ASSERTIONS_SIGNED SAML_LOGIN_FLOW OAUTH_GOOGLE_ENABLED OAUTH_GOOGLE_CLIENT_ID OAUTH_GOOGLE_SECRET OAUTH_GOOGLE_SECRET_FILE OAUTH_GITHUB_ENABLED OAUTH_GITHUB_CLIENT_ID OAUTH_GITHUB_SECRET OAUTH_GITHUB_SECRET_FILE OAUTH_FACEBOOK_ENABLED OAUTH_FACEBOOK_APP_ID OAUTH_FACEBOOK_SECRET OAUTH_FACEBOOK_SECRET_FILE OAUTH_TWITTER_ENABLED OAUTH_TWITTER_CONSUMER_KEY OAUTH_TWITTER_SECRET OAUTH_TWITTER_SECRET_FILE OAUTH_METEOR_DEVELOPER_ENABLED OAUTH_METEOR_DEVELOPER_CLIENT_ID OAUTH_METEOR_DEVELOPER_SECRET OAUTH_METEOR_DEVELOPER_SECRET_FILE OAUTH_WEIBO_ENABLED OAUTH_WEIBO_CLIENT_ID OAUTH_WEIBO_SECRET OAUTH_WEIBO_SECRET_FILE OAUTH_MEETUP_ENABLED OAUTH_MEETUP_CLIENT_ID OAUTH_MEETUP_SECRET OAUTH_MEETUP_SECRET_FILE OAUTH_PROVIDERS_LOGIN_STYLE OAUTH_PROVIDERS_MERGE_EXISTING_USERS PASSWORDLESS_ENABLED ORACLE_OIM_ENABLED RESULTS_PER_PAGE WAIT_SPINNER NODE_OPTIONS LDAP_AUTHENTIFICATION_PASSWORD_FILE OAUTH2_SECRET_FILE MAIL_SERVICE_PASSWORD_FILE MONGO_PASSWORD_FILE S3 S3_SECRET_FILE OAUTH2_AUTO_REGISTRATION OAUTH2_ADMIN_GROUPS NOTIFY_ON_ASSIGN LDAP_BACKGROUND_SYNC_DISABLE_NONEXISTANT_USERS LDAP_SYNC_ORGANIZATIONS LDAP_SYNC_ORGANIZATIONS_GROUPS LDAP_SYNC_TEAMS LDAP_SYNC_TEAMS_GROUPS"
|
||||
|
||||
#-------------------- TWO COPIES OF THE DATA --------------------
|
||||
# After a MongoDB -> FerretDB migration both copies stay on disk, and if both have
|
||||
@@ -546,6 +546,10 @@ DESCRIPTION_LDAP_GROUP_FILTER_GROUP_MEMBER_FORMAT="The format of the value of ld
|
||||
DEFAULT_LDAP_GROUP_FILTER_GROUP_MEMBER_FORMAT=""
|
||||
KEY_LDAP_GROUP_FILTER_GROUP_MEMBER_FORMAT="ldap-group-filter-member-format"
|
||||
|
||||
DESCRIPTION_LDAP_GROUP_FILTER_NESTED="Active Directory nested groups: also accept users who are members of ldap-group-filter-group-name through another group (team group -> access group), using LDAP_MATCHING_RULE_IN_CHAIN 1.2.840.113556.1.4.1941. Needs a DN-valued member attribute (member, with ldap-group-filter-member-format=dn). Also applies to admin status, group/role and org/team sync. Default: false"
|
||||
DEFAULT_LDAP_GROUP_FILTER_NESTED="false"
|
||||
KEY_LDAP_GROUP_FILTER_NESTED="ldap-group-filter-nested"
|
||||
|
||||
DESCRIPTION_LDAP_GROUP_FILTER_GROUP_NAME="The group name (id) that matches all users. Default: ''"
|
||||
DEFAULT_LDAP_GROUP_FILTER_GROUP_NAME=""
|
||||
KEY_LDAP_GROUP_FILTER_GROUP_NAME="ldap-group-filter-group-name"
|
||||
|
||||
@@ -666,6 +666,15 @@ REM # LDAP_GROUP_FILTER_GROUP_MEMBER_FORMAT :
|
||||
REM # example :
|
||||
REM SET LDAP_GROUP_FILTER_GROUP_MEMBER_FORMAT=
|
||||
|
||||
REM # LDAP_GROUP_FILTER_NESTED : Active Directory nested groups (#6744). When true, a user who is a member of
|
||||
REM # LDAP_GROUP_FILTER_GROUP_NAME through another group (team group -> access
|
||||
REM # group) is a member too: the group searches use AD's
|
||||
REM # LDAP_MATCHING_RULE_IN_CHAIN (1.2.840.113556.1.4.1941). Needs a DN-valued
|
||||
REM # member attribute (member, with LDAP_GROUP_FILTER_GROUP_MEMBER_FORMAT=dn).
|
||||
REM # Also applies to admin status, group->role and org/team sync. Default: false.
|
||||
REM # example : LDAP_GROUP_FILTER_NESTED=true
|
||||
REM SET LDAP_GROUP_FILTER_NESTED=false
|
||||
|
||||
REM # LDAP_GROUP_FILTER_GROUP_NAME :
|
||||
REM # example :
|
||||
REM SET LDAP_GROUP_FILTER_GROUP_NAME=
|
||||
|
||||
@@ -616,6 +616,15 @@
|
||||
# example :
|
||||
#export LDAP_GROUP_FILTER_GROUP_MEMBER_FORMAT=
|
||||
#
|
||||
# LDAP_GROUP_FILTER_NESTED : Active Directory nested groups (#6744). When true, a user who is a member of
|
||||
# LDAP_GROUP_FILTER_GROUP_NAME through another group (team group -> access
|
||||
# group) is a member too: the group searches use AD's
|
||||
# LDAP_MATCHING_RULE_IN_CHAIN (1.2.840.113556.1.4.1941). Needs a DN-valued
|
||||
# member attribute (member, with LDAP_GROUP_FILTER_GROUP_MEMBER_FORMAT=dn).
|
||||
# Also applies to admin status, group->role and org/team sync. Default: false.
|
||||
# example : export LDAP_GROUP_FILTER_NESTED=true
|
||||
#export LDAP_GROUP_FILTER_NESTED=false
|
||||
#
|
||||
# LDAP_GROUP_FILTER_GROUP_NAME :
|
||||
# example :
|
||||
#export LDAP_GROUP_FILTER_GROUP_NAME=
|
||||
|
||||
@@ -98,7 +98,10 @@ test('the query answers with NO groups when it cannot identify the user', () =>
|
||||
assert.ok(/ldapUser\.dn \|\| ldapUser\.objectName \|\|/.test(fn),
|
||||
'after trying the usual spellings of the same value');
|
||||
// The member clause must be pushed unconditionally once the value is known.
|
||||
const clause = fn.indexOf('filter.push(`(${this.options.group_filter_group_member_attribute}');
|
||||
// #6744: the clause is built by groupMemberClause, which also handles
|
||||
// LDAP_GROUP_FILTER_NESTED; the ordering requirement is unchanged.
|
||||
const clause = fn.indexOf('filter.push(groupMemberClause(this.options, escapeLdapFilterValue(format_value)))');
|
||||
assert.notStrictEqual(clause, -1, 'the member clause must be pushed in getUserGroups');
|
||||
assert.ok(clause > fn.indexOf('return [];'),
|
||||
'the clause is added after the guard, so it can never be skipped silently');
|
||||
});
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
'use strict';
|
||||
// #6744: "Regression since v12.08: LDAP login group filter ignores nested Active
|
||||
// Directory groups (users locked out)".
|
||||
//
|
||||
// v12.08 (DirectoryGroupBleed) made LDAP_USER_AUTHENTICATION=true logins check
|
||||
// LDAP_GROUP_FILTER_ENABLE at all - before it, every directory user got in. The
|
||||
// check matches `(member=<user DN>)`, which is DIRECT membership only, so in an
|
||||
// Active Directory that grants access through a team group nested in the access
|
||||
// group, legitimate users were refused.
|
||||
//
|
||||
// LDAP_GROUP_FILTER_NESTED=true makes both group searches use AD's
|
||||
// LDAP_MATCHING_RULE_IN_CHAIN, `(member:1.2.840.113556.1.4.1941:=<user DN>)`.
|
||||
// These tests drive the real isUserInGroup/getUserGroups and capture the filter
|
||||
// sent to the directory: nested membership when asked, the old direct clause when
|
||||
// not, and never a filter that stops naming the user - that would answer with
|
||||
// every group and let everyone in, the fault DirectoryGroupBleed closed.
|
||||
//
|
||||
// Run: node --test tests/ldapNestedGroups.test.cjs
|
||||
const {test} = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const harness = require('./helpers/ldapAuthHarness.cjs');
|
||||
const {groupMemberClause, AD_IN_CHAIN_RULE} = require('../packages/wekan-ldap/server/groupFilterConfig');
|
||||
|
||||
const USER_DN = 'CN=Alice Example,OU=Users,DC=corp,DC=example';
|
||||
const IN_CHAIN = `(member:1.2.840.113556.1.4.1941:=${USER_DN})`;
|
||||
|
||||
function directory(options = {}, settings = {}) {
|
||||
const h = harness(settings);
|
||||
const ldap = new h.LDAP();
|
||||
Object.assign(ldap.options, {
|
||||
group_filter_enabled: true,
|
||||
group_filter_object_class: 'group',
|
||||
group_filter_group_id_attribute: 'cn',
|
||||
group_filter_group_member_attribute: 'member',
|
||||
group_filter_group_member_format: 'dn',
|
||||
group_filter_group_name: 'WekanAccess',
|
||||
group_filter_nested: false,
|
||||
...options,
|
||||
});
|
||||
const filters = [];
|
||||
ldap.searchAll = async (base, search) => { filters.push(search.filter); return [{cn: 'WekanAccess'}]; };
|
||||
return {ldap, filters, isUserInGroup: (...args) => h.groupMethod.call(ldap, ...args)};
|
||||
}
|
||||
|
||||
test('the in-chain rule is Active Directory LDAP_MATCHING_RULE_IN_CHAIN', () => {
|
||||
assert.equal(AD_IN_CHAIN_RULE, '1.2.840.113556.1.4.1941');
|
||||
});
|
||||
|
||||
test('LDAP_GROUP_FILTER_NESTED=true builds a nested-membership clause', () => {
|
||||
assert.equal(groupMemberClause({group_filter_group_member_attribute: 'member', group_filter_nested: true}, USER_DN), IN_CHAIN);
|
||||
// Surrounding whitespace in a setting must not end up inside the filter.
|
||||
assert.equal(groupMemberClause({group_filter_group_member_attribute: ' member ', group_filter_nested: true}, USER_DN), IN_CHAIN);
|
||||
});
|
||||
|
||||
test('without the setting the clause is direct membership, exactly as before', () => {
|
||||
for (const group_filter_nested of [false, undefined, 'true', 1, 'yes']) {
|
||||
assert.equal(groupMemberClause({group_filter_group_member_attribute: 'member', group_filter_nested}, USER_DN),
|
||||
`(member=${USER_DN})`, `group_filter_nested=${JSON.stringify(group_filter_nested)} must not enable nesting`);
|
||||
}
|
||||
});
|
||||
|
||||
test('an attribute already written as the in-chain rule is used as written, never doubled', () => {
|
||||
for (const group_filter_nested of [true, false]) {
|
||||
assert.equal(groupMemberClause({
|
||||
group_filter_group_member_attribute: 'member:1.2.840.113556.1.4.1941:', group_filter_nested,
|
||||
}, USER_DN), IN_CHAIN);
|
||||
}
|
||||
});
|
||||
|
||||
test('login: a nested member of the allowed group is admitted with the in-chain filter', async () => {
|
||||
const d = directory({group_filter_nested: true});
|
||||
d.ldap.getUserGroups = async () => [];
|
||||
assert.equal(await d.isUserInGroup('alice', {dn: USER_DN}), true);
|
||||
assert.equal(d.filters.length, 1);
|
||||
assert.equal(d.filters[0], `(&(objectclass=group)${IN_CHAIN}(cn=WekanAccess))`);
|
||||
});
|
||||
|
||||
test('group sync: getUserGroups lists nested groups for admin, role and org/team sync', async () => {
|
||||
const d = directory({group_filter_nested: true});
|
||||
d.ldap.searchAll = async (base, search) => { d.filters.push(search.filter); return [{cn: 'Team A'}, {cn: 'WekanAccess'}]; };
|
||||
assert.deepEqual([...await d.ldap.getUserGroups('alice', {dn: USER_DN})], ['Team A', 'WekanAccess']);
|
||||
assert.equal(d.filters[0], `(&(objectclass=group)${IN_CHAIN})`);
|
||||
});
|
||||
|
||||
test('negative: without the setting, login still searches direct membership only', async () => {
|
||||
const d = directory();
|
||||
d.ldap.getUserGroups = async () => [];
|
||||
assert.equal(await d.isUserInGroup('alice', {dn: USER_DN}), true);
|
||||
assert.equal(d.filters[0], `(&(objectclass=group)(member=${USER_DN})(cn=WekanAccess))`);
|
||||
assert.ok(!d.filters[0].includes(AD_IN_CHAIN_RULE));
|
||||
});
|
||||
|
||||
test('negative: a nested member is refused when the directory finds no allowed group', async () => {
|
||||
const d = directory({group_filter_nested: true});
|
||||
d.ldap.getUserGroups = async () => [];
|
||||
d.ldap.searchAll = async (base, search) => { d.filters.push(search.filter); return []; };
|
||||
assert.equal(await d.isUserInGroup('alice', {dn: USER_DN}), false);
|
||||
assert.ok(d.filters[0].includes(IN_CHAIN), 'the refusal came from the nested search');
|
||||
});
|
||||
|
||||
test('negative: nesting never drops the clause that names the user', async () => {
|
||||
// A user entry without a DN cannot be named. Searching anyway would match
|
||||
// every allowed group - the DirectoryGroupBleed shape - so it must refuse
|
||||
// without searching, and getUserGroups must answer with no groups.
|
||||
for (const entry of [{}, {dn: ''}, {dn: 42}]) {
|
||||
const d = directory({group_filter_nested: true});
|
||||
d.ldap.getUserGroups = async () => [];
|
||||
assert.equal(await d.isUserInGroup('alice', entry), false);
|
||||
assert.equal(d.filters.length, 0);
|
||||
}
|
||||
const d = directory({group_filter_nested: true});
|
||||
assert.deepEqual([...await d.ldap.getUserGroups('alice', {})], []);
|
||||
assert.equal(d.filters.length, 0);
|
||||
});
|
||||
|
||||
test('negative: a DN carrying filter syntax stays escaped inside the in-chain clause', async () => {
|
||||
const hostile = 'CN=x)(cn=*),DC=corp';
|
||||
const d = directory({group_filter_nested: true});
|
||||
d.ldap.getUserGroups = async () => [];
|
||||
await d.isUserInGroup('alice', {dn: hostile});
|
||||
assert.ok(d.filters[0].includes('(member:1.2.840.113556.1.4.1941:=CN=x\\29\\28cn=\\2a\\29,DC=corp)'), d.filters[0]);
|
||||
assert.ok(!d.filters[0].includes('(cn=*)'));
|
||||
});
|
||||
|
||||
test('the setting is read as LDAP_GROUP_FILTER_NESTED and only exactly true enables it', () => {
|
||||
for (const [value, expected] of [[true, true], [false, false], [undefined, false], ['true', false], [1, false]]) {
|
||||
const {LDAP} = harness({LDAP_GROUP_FILTER_NESTED: value});
|
||||
assert.equal(new LDAP().options.group_filter_nested, expected, `LDAP_GROUP_FILTER_NESTED=${JSON.stringify(value)}`);
|
||||
}
|
||||
});
|
||||
|
||||
test('source: every group-membership clause in ldap.js goes through groupMemberClause', () => {
|
||||
// Pins the shape, not one call site: a group search added later that builds
|
||||
// `(${member_attribute}=...)` by hand would ignore LDAP_GROUP_FILTER_NESTED.
|
||||
const source = fs.readFileSync(path.join(__dirname, '../packages/wekan-ldap/server/ldap.js'), 'utf8');
|
||||
const code = source.replace(/\/\*[\s\S]*?\*\//g, '').replace(/^\s*\/\/.*$/gm, '');
|
||||
assert.ok(!/group_filter_group_member_attribute\}\s*=/.test(code),
|
||||
'a member clause is built by hand instead of with groupMemberClause');
|
||||
const calls = code.match(/groupMemberClause\(this\.options, escapeLdapFilterValue\(format_value\)\)/g) || [];
|
||||
assert.equal(calls.length, 2, 'getUserGroups and isUserInGroup both use groupMemberClause with an escaped value');
|
||||
});
|
||||
|
||||
test('the setting is documented and configurable wherever the other group settings are', () => {
|
||||
const root = path.join(__dirname, '..');
|
||||
const files = ['docs/Features/Login/LDAP.md', 'Dockerfile', 'snap-src/bin/config', 'start-wekan.sh', 'start-wekan.bat',
|
||||
...fs.readdirSync(root).filter(f => /^docker-compose.*\.yml$/.test(f))];
|
||||
for (const file of files) {
|
||||
const text = fs.readFileSync(path.join(root, file), 'utf8');
|
||||
if (!text.includes('LDAP_GROUP_FILTER_GROUP_MEMBER_FORMAT')) continue;
|
||||
assert.ok(text.includes('LDAP_GROUP_FILTER_NESTED'), `${file} lists the group settings but not LDAP_GROUP_FILTER_NESTED`);
|
||||
}
|
||||
const snap = fs.readFileSync(path.join(root, 'snap-src/bin/config'), 'utf8');
|
||||
assert.match(snap, /^keys=".* LDAP_GROUP_FILTER_NESTED /m);
|
||||
assert.match(snap, /^KEY_LDAP_GROUP_FILTER_NESTED="ldap-group-filter-nested"$/m);
|
||||
assert.match(snap, /^DEFAULT_LDAP_GROUP_FILTER_NESTED="false"$/m);
|
||||
});
|
||||
Reference in new issue
Block a user