Browse Source

minor fixes

tags/v2.0.0-rc1
Shivaram Lingamneni 4 years ago
parent
commit
306ca986a8
4 changed files with 19 additions and 9 deletions
  1. 5
    1
      irc/ldap/config.go
  2. 4
    3
      irc/ldap/grafana.go
  3. 6
    4
      irc/ldap/login.go
  4. 4
    1
      oragono.yaml

+ 5
- 1
irc/ldap/config.go View File

@@ -4,7 +4,11 @@
4 4
 // Modification notice:
5 5
 // 1. All field names were changed from toml and snake case to yaml and kebab case,
6 6
 //    matching the Oragono project conventions
7
-// 2. Two fields were added: `Autocreate` and `Timeout`
7
+// 2. Four fields were added:
8
+//    2.1 `Enabled`
9
+//    2.2 `Autocreate`
10
+//    2.3 `Timeout`
11
+//    2.4 `RequireGroups`
8 12
 
9 13
 // XXX: none of AttributeMap does anything in oragono, except MemberOf,
10 14
 // which can be used to retrieve group memberships

+ 4
- 3
irc/ldap/grafana.go View File

@@ -1,8 +1,9 @@
1 1
 // Copyright 2014-2018 Grafana Labs
2 2
 // Released under the Apache 2.0 license
3 3
 
4
-// Modification notice: these functions were altered by substituting
5
-// `serverConn` for `Server`.
4
+// Modification notice:
5
+// 1. `serverConn` was substituted for `Server` as the type of the server object
6
+// 2. Debug loglines were altered to work with Oragono's logging system
6 7
 
7 8
 package ldap
8 9
 
@@ -210,7 +211,7 @@ func (server *serverConn) requestMemberOf(entry *ldap.Entry) ([]string, error) {
210 211
 			-1,
211 212
 		)
212 213
 
213
-		server.log.Info("Searching for user's groups", "filter", filter)
214
+		server.logger.Debug("ldap", "Searching for groups with filter", filter)
214 215
 
215 216
 		// support old way of reading settings
216 217
 		groupIDAttribute := config.Attr.MemberOf

+ 6
- 4
irc/ldap/login.go View File

@@ -43,10 +43,12 @@ var (
43 43
 )
44 44
 
45 45
 // equivalent of Grafana's `Server`, but unexported
46
+// also, `log` was renamed to `logger`, since the APIs are slightly different
47
+// and this way the compiler will catch any unchanged references to Grafana's `Server.log`
46 48
 type serverConn struct {
47 49
 	Config     *ServerConfig
48 50
 	Connection *ldap.Conn
49
-	log        *logger.Manager
51
+	logger     *logger.Manager
50 52
 }
51 53
 
52 54
 func CheckLDAPPassphrase(config ServerConfig, accountName, passphrase string, log *logger.Manager) (err error) {
@@ -58,7 +60,7 @@ func CheckLDAPPassphrase(config ServerConfig, accountName, passphrase string, lo
58 60
 
59 61
 	server := serverConn{
60 62
 		Config: &config,
61
-		log:    log,
63
+		logger: log,
62 64
 	}
63 65
 
64 66
 	err = server.Dial()
@@ -126,10 +128,10 @@ func (server *serverConn) validateGroupMembership(user *ldap.Entry) (err error)
126 128
 	var memberOf []string
127 129
 	memberOf, err = server.getMemberOf(user)
128 130
 	if err != nil {
129
-		server.log.Debug("ldap", "could not retrieve group memberships", err.Error())
131
+		server.logger.Debug("ldap", "could not retrieve group memberships", err.Error())
130 132
 		return
131 133
 	}
132
-	server.log.Debug("ldap", fmt.Sprintf("found group memberships: %v", memberOf))
134
+	server.logger.Debug("ldap", fmt.Sprintf("found group memberships: %v", memberOf))
133 135
 	foundGroup := false
134 136
 	for _, inGroup := range memberOf {
135 137
 		for _, acceptableGroup := range server.Config.RequireGroups {

+ 4
- 1
oragono.yaml View File

@@ -392,6 +392,8 @@ accounts:
392 392
     #     enabled: true
393 393
     #     # should we automatically create users if their LDAP login succeeds?
394 394
     #     autocreate: true
395
+    #     # example configuration that works with Forum Systems's testing server:
396
+    #     # https://www.forumsys.com/tutorials/integration-how-to/ldap/online-ldap-test-server/
395 397
     #     host: "ldap.forumsys.com"
396 398
     #     port: 389
397 399
     #     timeout: 30s
@@ -404,7 +406,8 @@ accounts:
404 406
     #     #bind-dn: "cn=read-only-admin,dc=example,dc=com"
405 407
     #     #bind-password: "password"
406 408
     #     #search-filter: "(uid=%s)"
407
-    #     # example of requiring that users be in a particular group:
409
+    #     # example of requiring that users be in a particular group
410
+    #     # (note that this is an OR over the listed groups, not an AND):
408 411
     #     #require-groups:
409 412
     #     #    - "ou=mathematicians,dc=example,dc=com"
410 413
     #     #group-search-filter-user-attribute: "dn"

Loading…
Cancel
Save