File tree Expand file tree Collapse file tree 5 files changed +11
-1
lines changed
Expand file tree Collapse file tree 5 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -170,6 +170,7 @@ There are some configs you need to change in the files below
170170| HMD_LDAP_SEARCHBASE | ` o=users,dc=example,dc=com ` | LDAP directory to begin search from |
171171| HMD_LDAP_SEARCHFILTER | ` (uid={{username}}) ` | LDAP filter to search with |
172172| HMD_LDAP_SEARCHATTRIBUTES | ` displayName, mail ` | LDAP attributes to search with (use comma to separate) |
173+ | HMD_LDAP_USERNAMEFIELD | ` uid ` | The LDAP field which is used as the username on HackMD |
173174| HMD_LDAP_TLS_CA | ` server-cert.pem, root.pem ` | Root CA for LDAP TLS in PEM format (use comma to separate) |
174175| HMD_LDAP_PROVIDERNAME | ` My institution ` | Optional name to be displayed at login form indicating the LDAP provider |
175176| 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 7171 "searchBase" : " change this" ,
7272 "searchFilter" : " change this" ,
7373 "searchAttributes" : [" change this" ],
74+ "usernameField" : " change this e.g. uid"
7475 "tlsOptions" : {
7576 "changeme" : " See https://nodejs.org/api/tls.html#tls_tls_connect_options_callback"
7677 }
Original file line number Diff line number Diff line change @@ -96,6 +96,7 @@ module.exports = {
9696 searchBase : undefined ,
9797 searchFilter : undefined ,
9898 searchAttributes : undefined ,
99+ usernameField : undefined ,
99100 tlsca : undefined
100101 } ,
101102 saml : {
Original file line number Diff line number Diff line change @@ -71,6 +71,7 @@ module.exports = {
7171 searchBase : process . env . HMD_LDAP_SEARCHBASE ,
7272 searchFilter : process . env . HMD_LDAP_SEARCHFILTER ,
7373 searchAttributes : toArrayConfig ( process . env . HMD_LDAP_SEARCHATTRIBUTES ) ,
74+ usernameField : process . env . HMD_LDAP_USERNAMEFIELD ,
7475 tlsca : process . env . HMD_LDAP_TLS_CA
7576 } ,
7677 saml : {
Original file line number Diff line number Diff line change @@ -24,9 +24,15 @@ passport.use(new LDAPStrategy({
2424 }
2525} , function ( user , done ) {
2626 var uuid = user . uidNumber || user . uid || user . sAMAccountName
27+ var username = uuid
28+
29+ if ( config . ldap . usernameField && user [ config . ldap . usernameField ] ) {
30+ username = user [ config . ldap . usernameField ]
31+ }
32+
2733 var profile = {
2834 id : 'LDAP-' + uuid ,
29- username : uuid ,
35+ username : username ,
3036 displayName : user . displayName ,
3137 emails : user . mail ? [ user . mail ] : [ ] ,
3238 avatarUrl : null ,
You can’t perform that action at this time.
0 commit comments