@mashroom/mashroom-security-provider-ldap
Advanced tools
Comparing version 1.3.2 to 1.4.0
@@ -12,7 +12,9 @@ "use strict"; | ||
var _querystring = _interopRequireDefault(require("querystring")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/* eslint require-atomic-updates: warn */ | ||
const AUTHENTICATION_RESULT_SESSION_KEY = '__MASHROOM_SECURITY_AUTH_USER'; | ||
const AUTHENTICATION_EXPIRES_SESSION_KEY = '__MASHROOM_SECURITY_AUTH_EXPIRES'; | ||
const AUTHENTICATION_RESULT_SESSION_KEY = '__MASHROOM_SECURITY_LDAP_AUTH_USER'; | ||
const AUTHENTICATION_EXPIRES_SESSION_KEY = '__MASHROOM_SECURITY_LDAP_AUTH_EXPIRES'; | ||
@@ -46,6 +48,13 @@ class MashroomLdapSecurityProvider { | ||
async authenticate(request, response) { | ||
async canAuthenticateWithoutUserInteraction() { | ||
return false; | ||
} | ||
async authenticate(request, response, authenticationHints = {}) { | ||
let buff = Buffer.from(decodeURI(request.originalUrl)); | ||
const base64encodedReferrer = buff.toString('base64'); | ||
response.redirect(`${this._loginPage}?ref=${base64encodedReferrer}`); | ||
const authenticationHintsQuery = _querystring.default.stringify(authenticationHints); | ||
response.redirect(`${this._loginPage}?ref=${base64encodedReferrer}${authenticationHintsQuery ? '&' + authenticationHintsQuery : ''}`); | ||
return { | ||
@@ -95,11 +104,14 @@ status: 'deferred' | ||
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 roles = this._getRolesForUserGroups(groups, logger); | ||
const mashroomUser = { | ||
username, | ||
displayName: user.cn, | ||
email: user.mail, | ||
pictureUrl: null, | ||
roles, | ||
groups | ||
}; | ||
logger.debug('User successfully authenticated:', mashroomUser); | ||
request.session[AUTHENTICATION_RESULT_SESSION_KEY] = mashroomUser; | ||
@@ -143,3 +155,3 @@ request.session[AUTHENTICATION_EXPIRES_SESSION_KEY] = Date.now() + this._authenticationTimeoutSec * 1000; | ||
getRolesForUserGroups(groups, logger) { | ||
_getRolesForUserGroups(groups, logger) { | ||
if (!groups || groups.length === 0) { | ||
@@ -146,0 +158,0 @@ return []; |
@@ -7,3 +7,3 @@ { | ||
"license": "MIT", | ||
"version": "1.3.2", | ||
"version": "1.4.0", | ||
"files": [ | ||
@@ -16,9 +16,9 @@ "dist/**" | ||
"devDependencies": { | ||
"@babel/cli": "^7.8.3", | ||
"@mashroom/mashroom": "1.3.2", | ||
"@mashroom/mashroom-security": "1.3.2", | ||
"@mashroom/mashroom-utils": "1.3.2", | ||
"@babel/cli": "^7.8.4", | ||
"@mashroom/mashroom": "1.4.0", | ||
"@mashroom/mashroom-security": "1.4.0", | ||
"@mashroom/mashroom-utils": "1.4.0", | ||
"eslint": "^6.8.0", | ||
"express": "^4.17.1", | ||
"jest": "^24.9.0" | ||
"jest": "^25.1.0" | ||
}, | ||
@@ -25,0 +25,0 @@ "jest": { |
### Mashroom LDAP Security Provider | ||
# Mashroom LDAP Security Provider | ||
Plugin for [Mashroom Server](https://www.mashroom-server.com), a **Integration Platform for Microfrontends**. | ||
Plugin for [Mashroom Server](https://www.mashroom-server.com), a **Integration Platform for Microfrontends**. | ||
This plugin adds a LDAP security provider. | ||
#### Usage | ||
## Usage | ||
@@ -55,3 +55,3 @@ If *node_modules/@mashroom* is configured as plugin path just add **@mashroom/mashroom-security-provider-ldap** as *dependency*. | ||
* _authenticationTimeoutSec_: The inactivity time after that the authentication expires. Since this plugin uses the session to store make sure the session _cookie.maxAge_ is greater than this value. | ||
For a server that requires TLS you have to provide a _tlsOptions_ object: | ||
@@ -66,6 +66,6 @@ | ||
"cert": "./server-cert.pem", | ||
// Necessary only if the server requires client certificate authentication. | ||
//"key": "./client-key.pem", | ||
// Necessary only if the server uses a self-signed certificate. | ||
@@ -72,0 +72,0 @@ // "rejectUnauthorized": false, |
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
18007
334