|
|
@@ -112,6 +112,9 @@ class PassportService {
|
|
|
|
|
|
debug('LdapStrategy: setting up..');
|
|
|
|
|
|
+ const attrMapUsername = config.crowi['security:passport-ldap:attrMapUsername'] || 'uid';
|
|
|
+ debug(`LdapStrategy: attrMapUsername=${attrMapUsername}`);
|
|
|
+
|
|
|
passport.use(new LdapStrategy(this.getLdapConfigurationFunc(config, {passReqToCallback: true}),
|
|
|
(req, ldapAccountInfo, done) => {
|
|
|
debug("LDAP authentication has succeeded", ldapAccountInfo);
|
|
|
@@ -121,9 +124,10 @@ class PassportService {
|
|
|
// it is guaranteed that username that is input from form can be acquired
|
|
|
// because this processes after authentication
|
|
|
const ldapAccountId = this.getLdapAccountIdFromReq(req);
|
|
|
- // TODO ensure to be able to select the way to determine username
|
|
|
- const usernameToBeRegistered = ldapAccountInfo['uid'];
|
|
|
|
|
|
+ const usernameToBeRegistered = ldapAccountInfo[attrMapUsername];
|
|
|
+
|
|
|
+ // find or register(create) user
|
|
|
ExternalAccount.findOrRegister('ldap', ldapAccountId, usernameToBeRegistered)
|
|
|
.then((externalAccount) => {
|
|
|
return externalAccount.getPopulatedUser();
|