File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -175,7 +175,8 @@ There are some config settings you need to change in the files below.
175175| ` HMD_LDAP_SEARCHBASE ` | ` o=users,dc=example,dc=com ` | LDAP directory to begin search from |
176176| ` HMD_LDAP_SEARCHFILTER ` | ` (uid={{username}}) ` | LDAP filter to search with |
177177| ` HMD_LDAP_SEARCHATTRIBUTES ` | ` displayName, mail ` | LDAP attributes to search with (use comma to separate) |
178- | ` HMD_LDAP_USERNAMEFIELD ` | ` uid ` | The LDAP field which is used as the username on HackMD |
178+ | ` HMD_LDAP_USERIDFIELD ` | ` uidNumber ` or ` uid ` or ` sAMAccountName ` | The LDAP field which is used uniquely identify a user on HackMD |
179+ | ` HMD_LDAP_USERNAMEFIELD ` | Fallback to userid | The LDAP field which is used as the username on HackMD |
179180| ` HMD_LDAP_TLS_CA ` | ` server-cert.pem, root.pem ` | Root CA for LDAP TLS in PEM format (use comma to separate) |
180181| ` HMD_LDAP_PROVIDERNAME ` | ` My institution ` | Optional name to be displayed at login form indicating the LDAP provider |
181182| ` HMD_SAML_IDPSSOURL ` | ` https://idp.example.com/sso ` | authentication endpoint of IdP. for details, see [ guide] ( docs/guides/auth.md#saml-onelogin ) . |
Original file line number Diff line number Diff line change 7878 "searchBase" : " change this" ,
7979 "searchFilter" : " change this" ,
8080 "searchAttributes" : [" change this" ],
81- "usernameField" : " change this e.g. uid" ,
81+ "usernameField" : " change this e.g. cn" ,
82+ "useridField" : " change this e.g. uid" ,
8283 "tlsOptions" : {
8384 "changeme" : " See https://nodejs.org/api/tls.html#tls_tls_connect_options_callback"
8485 }
Original file line number Diff line number Diff line change @@ -115,6 +115,7 @@ module.exports = {
115115 searchFilter : undefined ,
116116 searchAttributes : undefined ,
117117 usernameField : undefined ,
118+ useridField : undefined ,
118119 tlsca : undefined
119120 } ,
120121 saml : {
Original file line number Diff line number Diff line change @@ -84,6 +84,7 @@ module.exports = {
8484 searchFilter : process . env . HMD_LDAP_SEARCHFILTER ,
8585 searchAttributes : toArrayConfig ( process . env . HMD_LDAP_SEARCHATTRIBUTES ) ,
8686 usernameField : process . env . HMD_LDAP_USERNAMEFIELD ,
87+ useridField : process . env . HMD_LDAP_USERIDFIELD ,
8788 tlsca : process . env . HMD_LDAP_TLS_CA
8889 } ,
8990 saml : {
Original file line number Diff line number Diff line change @@ -24,8 +24,11 @@ passport.use(new LDAPStrategy({
2424 }
2525} , function ( user , done ) {
2626 var uuid = user . uidNumber || user . uid || user . sAMAccountName
27- var username = uuid
27+ if ( config . ldap . useridField && user [ config . ldap . useridField ] ) {
28+ uuid = user [ config . ldap . useridField ]
29+ }
2830
31+ var username = uuid
2932 if ( config . ldap . usernameField && user [ config . ldap . usernameField ] ) {
3033 username = user [ config . ldap . usernameField ]
3134 }
You can’t perform that action at this time.
0 commit comments