File tree 5 files changed +11
-1
lines changed
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
170
170
| HMD_LDAP_SEARCHBASE | ` o=users,dc=example,dc=com ` | LDAP directory to begin search from |
171
171
| HMD_LDAP_SEARCHFILTER | ` (uid={{username}}) ` | LDAP filter to search with |
172
172
| 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 |
173
174
| HMD_LDAP_TLS_CA | ` server-cert.pem, root.pem ` | Root CA for LDAP TLS in PEM format (use comma to separate) |
174
175
| HMD_LDAP_PROVIDERNAME | ` My institution ` | Optional name to be displayed at login form indicating the LDAP provider |
175
176
| 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 71
71
"searchBase" : " change this" ,
72
72
"searchFilter" : " change this" ,
73
73
"searchAttributes" : [" change this" ],
74
+ "usernameField" : " change this e.g. uid"
74
75
"tlsOptions" : {
75
76
"changeme" : " See https://nodejs.org/api/tls.html#tls_tls_connect_options_callback"
76
77
}
Original file line number Diff line number Diff line change @@ -96,6 +96,7 @@ module.exports = {
96
96
searchBase : undefined ,
97
97
searchFilter : undefined ,
98
98
searchAttributes : undefined ,
99
+ usernameField : undefined ,
99
100
tlsca : undefined
100
101
} ,
101
102
saml : {
Original file line number Diff line number Diff line change @@ -71,6 +71,7 @@ module.exports = {
71
71
searchBase : process . env . HMD_LDAP_SEARCHBASE ,
72
72
searchFilter : process . env . HMD_LDAP_SEARCHFILTER ,
73
73
searchAttributes : toArrayConfig ( process . env . HMD_LDAP_SEARCHATTRIBUTES ) ,
74
+ usernameField : process . env . HMD_LDAP_USERNAMEFIELD ,
74
75
tlsca : process . env . HMD_LDAP_TLS_CA
75
76
} ,
76
77
saml : {
Original file line number Diff line number Diff line change @@ -24,9 +24,15 @@ passport.use(new LDAPStrategy({
24
24
}
25
25
} , function ( user , done ) {
26
26
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
+
27
33
var profile = {
28
34
id : 'LDAP-' + uuid ,
29
- username : uuid ,
35
+ username : username ,
30
36
displayName : user . displayName ,
31
37
emails : user . mail ? [ user . mail ] : [ ] ,
32
38
avatarUrl : null ,
You can’t perform that action at this time.
0 commit comments