Skip to content

Commit 53bf75b

Browse files
authored
Merge branch 'develop' into dependabot/go_modules/develop/github.com/go-git/go-git/v5-5.18.0
2 parents 157567b + 1a83866 commit 53bf75b

9 files changed

Lines changed: 160 additions & 37 deletions

File tree

config/dynamic/parse.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func parse(c *Config) (interface{}, error) {
6969
result, err = parseYaml(b, result)
7070
case ".json":
7171
result, err = parseJson(b, result)
72-
case ".lua", ".js", ".cjs", ".mjs", ".ts":
72+
case ".lua", ".js", ".cjs", ".mjs", ".ts", ".ldif":
7373
result = string(b)
7474
default:
7575
// try parse from JSON and YAML

examples/mail/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/mail/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"dependencies": {
3-
"nodemailer": "^7.0.11"
3+
"nodemailer": "^8.0.5"
44
}
55
}

providers/directory/config_ldif_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,18 @@ func TestLdif_Parse(t *testing.T) {
110110
}, ld.Records[0])
111111
},
112112
},
113+
{
114+
name: "comment",
115+
input: "dn: dc=mokapi, dc=io\n# line 1\n line 2\nfoo: bar",
116+
test: func(t *testing.T, ld *Ldif, err error) {
117+
require.NoError(t, err)
118+
require.Len(t, ld.Records, 1)
119+
require.Equal(t, &AddRecord{
120+
Dn: "dc=mokapi, dc=io",
121+
Attributes: map[string][]string{"foo": {"bar"}},
122+
}, ld.Records[0])
123+
},
124+
},
113125
{
114126
name: "version set",
115127
input: "version: 1\ndn: dc=mokapi, dc=io",

providers/directory/ldif.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@ func (l *Ldif) Parse(config *dynamic.Config, reader dynamic.Reader) error {
6363
}
6464
continue
6565
}
66-
if line[0] == '#' || line[0] == '-' {
67-
continue
68-
}
6966

7067
if isMultiLine(i + 1) {
7168
parsedLine += trim(line)
@@ -75,6 +72,10 @@ func (l *Ldif) Parse(config *dynamic.Config, reader dynamic.Reader) error {
7572
parsedLine = ""
7673
}
7774

75+
if line[0] == '#' || line[0] == '-' {
76+
continue
77+
}
78+
7879
kv := strings.SplitN(line, ":", 2)
7980
if len(kv) != 2 {
8081
return fmt.Errorf("invalid line %v: %s", i, line)

providers/directory/search.go

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,48 @@ import (
2222

2323
type predicate func(entry Entry) bool
2424

25+
func guidFromBytes(b []byte) string {
26+
return fmt.Sprintf("%08x-%04x-%04x-%02x%02x-%x",
27+
binary.LittleEndian.Uint32(b[0:4]),
28+
binary.LittleEndian.Uint16(b[4:6]),
29+
binary.LittleEndian.Uint16(b[6:8]),
30+
b[8], b[9],
31+
b[10:16],
32+
)
33+
}
34+
35+
func updateBaseDnForGuidIfNeeded(msg *ldap.SearchRequest, e *Entry) {
36+
binGuid, ok := e.Attributes["objectGUID"]
37+
if !ok || len(binGuid) == 0 {
38+
return
39+
}
40+
msgGuid := msg.BaseDN[6 : len(msg.BaseDN)-1]
41+
if guidFromBytes([]byte(binGuid[0])) != msgGuid {
42+
return
43+
}
44+
log.Infof("Attributes: %+v", guidFromBytes([]byte(e.Attributes["objectGUID"][0])))
45+
msg.BaseDN = e.Dn
46+
}
47+
48+
var matchingRules = map[string]string{
49+
"1.3.6.1.4.1.1466.115.121.1.38": "objectIdentifierMatch",
50+
"1.3.6.1.4.1.1466.115.121.1.15": "caseIgnoreMatch",
51+
"1.3.6.1.4.1.1466.115.121.1.26": "caseExactMatch",
52+
"1.3.6.1.4.1.1466.115.121.1.7": "booleanMatch",
53+
"1.3.6.1.4.1.1466.115.121.1.27": "integerMatch",
54+
"1.3.6.1.4.1.1466.115.121.1.12": "distinguishedNameMatch",
55+
"1.3.6.1.4.1.1466.115.121.1.24": "generalizedTimeMatch",
56+
"1.3.6.1.4.1.1466.115.121.1.5": "octetStringMatch",
57+
}
58+
59+
func inferMatchingRule(syntaxOID string) string {
60+
if v, ok := matchingRules[syntaxOID]; ok {
61+
return v
62+
}
63+
return "caseExactMatch"
64+
}
65+
66+
2567
func (d *Directory) serveSearch(rw ldap.ResponseWriter, r *ldap.Request) {
2668
msg := r.Message.(*ldap.SearchRequest)
2769
m, doMonitor := monitor.LdapFromContext(r.Context)
@@ -69,6 +111,10 @@ func (d *Directory) serveSearch(rw ldap.ResponseWriter, r *ldap.Request) {
69111

70112
switch msg.Scope {
71113
case ldap.ScopeBaseObject:
114+
// handle Active Directory extended DN (see MS-ADTS for details)
115+
if strings.HasPrefix(msg.BaseDN, "<GUID=") {
116+
updateBaseDnForGuidIfNeeded(msg, &e)
117+
}
72118
if e.Dn != msg.BaseDN {
73119
continue
74120
}
@@ -80,6 +126,10 @@ func (d *Directory) serveSearch(rw ldap.ResponseWriter, r *ldap.Request) {
80126
if dn := strings.Join(parts[1:], ","); dn != msg.BaseDN {
81127
continue
82128
}
129+
case ldap.ScopeWholeSubtree:
130+
if !strings.HasSuffix(strings.ToLower(e.Dn), strings.ToLower(msg.BaseDN)) {
131+
continue
132+
}
83133
}
84134
if d.skip(&e, msg.BaseDN) {
85135
continue
@@ -343,6 +393,9 @@ func (p *parser) equal(name, value string) (predicate, error) {
343393
if p.s != nil {
344394
t, ok := p.s.AttributeTypes[name]
345395
if ok {
396+
if t.Equality == "" {
397+
t.Equality = inferMatchingRule(t.Syntax)
398+
}
346399
switch t.Equality {
347400
case "caseIgnoreMatch", "2.5.13.2":
348401
f = func(s string) bool {

providers/directory/search_test.go

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,32 @@ attributeTypes: ( 1.2.3.4.5.6.7.8 NAME 'objectSid' DESC 'objectSid' EQUALITY act
431431
require.Equal(t, "ldap: filter syntax error: invalid SID 'S-1-5-21-foo-1234567890-1234567890-1001': invalid uint value 'foo' at position: 3", log.Entries[1].Message)
432432
},
433433
},
434+
{
435+
name: "no EQUALITY specified",
436+
input: `{ "files": [ "./schema.ldif", "./users.ldif" ] }`,
437+
reader: &dynamictest.Reader{Data: map[string]*dynamic.Config{
438+
"file:/schema.ldif": {Raw: []byte(`
439+
dn:
440+
subschemaSubentry: cn=schema
441+
442+
dn: cn=schema
443+
attributeTypes: ( 2.5.4.3 NAME 'cn' DESC 'Common Name' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE )
444+
`)},
445+
"file:/users.ldif": {Raw: []byte("dn: cn=user\ncn: UsEr")},
446+
}},
447+
test: func(t *testing.T, h ldap.Handler, _ *test.Hook, err error) {
448+
require.NoError(t, err)
449+
450+
rr := ldaptest.NewRecorder()
451+
h.ServeLDAP(rr, ldaptest.NewRequest(0, &ldap.SearchRequest{
452+
Scope: ldap.ScopeWholeSubtree,
453+
Filter: "(cn=user)",
454+
}))
455+
res := rr.Message.(*ldap.SearchResponse)
456+
457+
require.Len(t, res.Results, 1)
458+
},
459+
},
434460
}
435461

436462
for _, tc := range testcases {
@@ -609,6 +635,37 @@ func TestSearch(t *testing.T) {
609635
require.Len(t, res.Results, 1)
610636
},
611637
},
638+
{
639+
name: "scope whole subtree",
640+
input: `{ "files": [ "./users.ldif" ] }`,
641+
reader: &dynamictest.Reader{Data: map[string]*dynamic.Config{
642+
"file:/users.ldif": {Raw: []byte(`
643+
dn: cn=user
644+
645+
dn: id=user1,ou=Sales,dc=example,dc=com
646+
foo: bar
647+
648+
dn: id=user2,ou=Sales,dc=example,dc=com
649+
foo: bar
650+
651+
dn: id=user3,ou=Accounting,dc=example,dc=com
652+
foo: bar
653+
`)},
654+
}},
655+
test: func(t *testing.T, h ldap.Handler, err error) {
656+
require.NoError(t, err)
657+
658+
rr := ldaptest.NewRecorder()
659+
h.ServeLDAP(rr, ldaptest.NewRequest(0, &ldap.SearchRequest{
660+
Scope: ldap.ScopeWholeSubtree,
661+
BaseDN: "ou=Sales,dc=example,dc=com",
662+
Filter: "(foo=bar)",
663+
}))
664+
res := rr.Message.(*ldap.SearchResponse)
665+
666+
require.Len(t, res.Results, 2)
667+
},
668+
},
612669
}
613670

614671
t.Parallel()

webui/package-lock.json

Lines changed: 24 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webui/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,16 @@
5252
"@rushstack/eslint-patch": "^1.16.1",
5353
"@types/js-yaml": "^4.0.9",
5454
"@types/markdown-it-container": "^4.0.0",
55-
"@types/node": "^25.5.1",
56-
"@vitejs/plugin-vue": "^6.0.5",
55+
"@types/node": "^25.6.0",
56+
"@vitejs/plugin-vue": "^6.0.6",
5757
"@vue/eslint-config-prettier": "^10.2.0",
5858
"@vue/eslint-config-typescript": "^14.7.0",
5959
"@vue/tsconfig": "^0.9.1",
6060
"eslint": "^10.2.0",
6161
"eslint-plugin-vue": "^10.8.0",
6262
"npm-run-all": "^4.1.5",
63-
"prettier": "^3.8.2",
64-
"typescript": "~6.0.2",
63+
"prettier": "^3.8.3",
64+
"typescript": "~6.0.3",
6565
"vite": "^8.0.8",
6666
"vue-tsc": "^3.2.6",
6767
"xml2js": "^0.6.2"

0 commit comments

Comments
 (0)