mirror of
https://github.com/owncloud/ocis.git
synced 2026-10-23 23:29:02 +03:00
* fix: [OCISDEV-1523] fix the LDAP master-ID filter for an empty base filter EnhanceFilterWithMasterID replaced an empty LDAP filter with a master-ID-only filter. This action restricted an unrestricted search to master-ID users only. The bug broke the cross-instance user search in multi-instance deployments. The function now keeps an empty filter unchanged. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * fix: [OCISDEV-1523] require an explicit LDAP user filter with a master ID EnhanceFilterWithMasterID in ocis-pkg/ldap/filter.go now keeps an empty LDAP filter unchanged instead of restricting it to master-ID users only. The auth-basic, users, groups, and graph services reuse this function to compute their default LDAP user filter at startup. An unset filter now means these services resolve or authenticate every user in the shared LDAP directory, not only master-ID users. This action is a behavior change for a deployment that sets OCIS_MULTI_INSTANCE_MASTER_ID without an explicit OCIS_LDAP_USER_FILTER. Each service now rejects startup when OCIS_MULTI_INSTANCE_MASTER_ID is set and its own user filter is empty. This action keeps a multi-instance deployment scoped to its own users by default. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * refactor: [OCISDEV-1523] simplify EnhanceFilterWithMasterID guard clauses The function collapses three early-return guards into one condition. This action removes a duplicated rationale comment between filter.go and filter_test.go. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * docs: [OCISDEV-1523] point the changelog entry at the master backport PR The changelog entry pointed at PR 13096, the stable-8.2 backport. This commit points the entry at the master-branch PR number instead. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
64 lines
1.4 KiB
Go
64 lines
1.4 KiB
Go
package parser
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/owncloud/ocis/v2/services/auth-basic/pkg/config"
|
|
)
|
|
|
|
func TestValidateMasterIDRequiresUserFilter(t *testing.T) {
|
|
cfg := &config.Config{
|
|
Service: config.Service{Name: "auth-basic"},
|
|
TokenManager: &config.TokenManager{JWTSecret: "secret"},
|
|
AuthProvider: "ldap",
|
|
AuthProviders: config.AuthProviders{
|
|
LDAP: config.LDAPProvider{
|
|
BindPassword: "secret",
|
|
MasterID: "master-1",
|
|
UserFilter: "",
|
|
},
|
|
},
|
|
}
|
|
|
|
err := Validate(cfg)
|
|
assert.Error(t, err)
|
|
}
|
|
|
|
func TestValidateMasterIDWithUserFilterPasses(t *testing.T) {
|
|
cfg := &config.Config{
|
|
Service: config.Service{Name: "auth-basic"},
|
|
TokenManager: &config.TokenManager{JWTSecret: "secret"},
|
|
AuthProvider: "ldap",
|
|
AuthProviders: config.AuthProviders{
|
|
LDAP: config.LDAPProvider{
|
|
BindPassword: "secret",
|
|
MasterID: "master-1",
|
|
UserFilter: "(ownCloudMemberOf=instance-1)",
|
|
},
|
|
},
|
|
}
|
|
|
|
err := Validate(cfg)
|
|
assert.NoError(t, err)
|
|
}
|
|
|
|
func TestValidateNoMasterIDWithEmptyUserFilterPasses(t *testing.T) {
|
|
cfg := &config.Config{
|
|
Service: config.Service{Name: "auth-basic"},
|
|
TokenManager: &config.TokenManager{JWTSecret: "secret"},
|
|
AuthProvider: "ldap",
|
|
AuthProviders: config.AuthProviders{
|
|
LDAP: config.LDAPProvider{
|
|
BindPassword: "secret",
|
|
MasterID: "",
|
|
UserFilter: "",
|
|
},
|
|
},
|
|
}
|
|
|
|
err := Validate(cfg)
|
|
assert.NoError(t, err)
|
|
}
|