@mashroom/mashroom-security-provider-ldap
Advanced tools
Comparing version 1.1.3 to 1.1.4
@@ -14,2 +14,3 @@ "use strict"; | ||
/* eslint require-atomic-updates: warn */ | ||
const AUTHENTICATION_RESULT_SESSION_KEY = '__MASHROOM_SECURITY_AUTH_USER'; | ||
@@ -20,3 +21,2 @@ const AUTHENTICATION_EXPIRES_SESSION_KEY = '__MASHROOM_SECURITY_AUTH_EXPIRES'; | ||
constructor(loginPage, userSearchFilter, groupSearchFilter, groupToRoleMappingPath, ldapClient, serverRootFolder, authenticationTimeoutSec, loggerFactory) { | ||
this._logger = loggerFactory('mashroom.security.provider.ldap'); | ||
this._loginPage = loginPage; | ||
@@ -30,2 +30,4 @@ this._userSearchFilter = userSearchFilter; | ||
if (groupToRoleMappingPath) { | ||
const logger = loggerFactory('mashroom.security.provider.ldap'); | ||
if (!_path.default.isAbsolute(groupToRoleMappingPath)) { | ||
@@ -36,6 +38,5 @@ this._groupToRoleMappingPath = _path.default.resolve(serverRootFolder, groupToRoleMappingPath); | ||
if (this._groupToRoleMappingPath && _fs.default.existsSync(this._groupToRoleMappingPath)) { | ||
this._logger.info(`Using user to role mapping: ${this._groupToRoleMappingPath}`); | ||
logger.info(`Using user to role mapping: ${this._groupToRoleMappingPath}`); | ||
} else { | ||
this._logger.warn(`Group to role mapping file not found: ${groupToRoleMappingPath}`); | ||
logger.warn(`Group to role mapping file not found: ${groupToRoleMappingPath}`); | ||
this._groupToRoleMappingPath = null; | ||
@@ -69,2 +70,3 @@ } | ||
async login(request, username, password) { | ||
const logger = request.pluginContext.loggerFactory('mashroom.security.provider.ldap'); | ||
let user = null; | ||
@@ -74,4 +76,3 @@ | ||
this._logger.debug(`Search for users: ${userSearchFilter}`); | ||
logger.debug(`Search for users: ${userSearchFilter}`); | ||
const users = await this._ldapClient.search(userSearchFilter); | ||
@@ -83,4 +84,3 @@ | ||
} else { | ||
this._logger.warn(`Multiple users found for search query: ${userSearchFilter}`); | ||
logger.warn(`Multiple users found for search query: ${userSearchFilter}`); | ||
return { | ||
@@ -91,4 +91,3 @@ success: false | ||
} else { | ||
this._logger.warn(`No users found for search query: ${userSearchFilter}`); | ||
logger.warn(`No users found for search query: ${userSearchFilter}`); | ||
return { | ||
@@ -101,10 +100,6 @@ success: false | ||
await this._ldapClient.login(user, password); | ||
const groups = await this._getUserGroups(user); | ||
this._logger.debug(`Found user groups for user ${username}: `, groups); | ||
const roles = this.getRolesForUserGroups(groups); | ||
this._logger.debug(`Found roles for user ${username}: `, roles); | ||
const groups = await this._getUserGroups(user, logger); | ||
logger.debug(`Found user groups for user ${username}: `, groups); | ||
const roles = this.getRolesForUserGroups(groups, logger); | ||
logger.debug(`Found roles for user ${username}: `, roles); | ||
const mashroomUser = { | ||
@@ -143,3 +138,3 @@ username, | ||
async _getUserGroups(user) { | ||
async _getUserGroups(user, logger) { | ||
if (!this._groupSearchFilter || !this._groupSearchFilter.trim()) { | ||
@@ -150,5 +145,3 @@ return []; | ||
const groupSearchFilter = `(&${this._groupSearchFilter}(member=${user.dn}))`; | ||
this._logger.debug(`Search for user groups: ${groupSearchFilter}`); | ||
logger.debug(`Search for user groups: ${groupSearchFilter}`); | ||
const groupEntries = await this._ldapClient.search(groupSearchFilter); | ||
@@ -158,3 +151,3 @@ return groupEntries.map(e => e.cn); | ||
getRolesForUserGroups(groups) { | ||
getRolesForUserGroups(groups, logger) { | ||
if (!groups || groups.length === 0) { | ||
@@ -166,3 +159,3 @@ return []; | ||
const groupToRoles = this._getGroupToRoleMapping(); | ||
const groupToRoles = this._getGroupToRoleMapping(logger); | ||
@@ -187,3 +180,3 @@ if (groupToRoles) { | ||
_getGroupToRoleMapping() { | ||
_getGroupToRoleMapping(logger) { | ||
if (!this._groupToRoleMappingPath) { | ||
@@ -200,4 +193,3 @@ return null; | ||
} else { | ||
this._logger.warn(`No group to roles definition found: ${this._groupToRoleMappingPath || '-'}.`); | ||
logger.warn(`No group to roles definition found: ${this._groupToRoleMappingPath || '-'}.`); | ||
this._groupToRoleMapping = null; | ||
@@ -204,0 +196,0 @@ } |
@@ -7,3 +7,3 @@ { | ||
"license": "MIT", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"files": [ | ||
@@ -17,5 +17,5 @@ "dist/**" | ||
"@babel/cli": "^7.6.0", | ||
"@mashroom/mashroom": "1.1.3", | ||
"@mashroom/mashroom-security": "1.1.3", | ||
"@mashroom/mashroom-utils": "1.1.3", | ||
"@mashroom/mashroom": "1.1.4", | ||
"@mashroom/mashroom-security": "1.1.4", | ||
"@mashroom/mashroom-utils": "1.1.4", | ||
"eslint": "^6.4.0", | ||
@@ -22,0 +22,0 @@ "express": "^4.17.1", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17683
328