lemonldap-ng-handler 0.5.5 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +114 -0
- package/LICENSE +677 -0
- package/README.md +305 -0
- package/lib/handlerDevOps.d.ts +22 -0
- package/lib/handlerDevOpsST.d.ts +10 -0
- package/lib/handlerMain.d.ts +30 -0
- package/lib/handlerServiceToken.d.ts +8 -0
- package/lib/index.d.ts +10 -0
- package/lib/index.js +2 -325
- package/lib/index.js.map +1 -0
- package/lib/index.mjs +726 -0
- package/lib/index.mjs.map +1 -0
- package/lib/init.d.ts +30 -0
- package/lib/tsv.d.ts +59 -0
- package/package.json +20 -30
- package/lib/conf.js +0 -340
- package/lib/handlerDevOps.js +0 -167
- package/lib/handlerDevOpsST.js +0 -23
- package/lib/handlerOAuth2.js +0 -55
- package/lib/handlerServiceToken.js +0 -59
- package/lib/safelib.js +0 -174
package/lib/index.js
CHANGED
|
@@ -1,325 +1,2 @@
|
|
|
1
|
-
(function() {
|
|
2
|
-
|
|
3
|
-
* LemonLDAP::NG handler for Node.js/express
|
|
4
|
-
*
|
|
5
|
-
* See README.md for license and copyright
|
|
6
|
-
*/
|
|
7
|
-
var Handler, conf, h, normalizeUrl, urlParse;
|
|
8
|
-
|
|
9
|
-
conf = null;
|
|
10
|
-
|
|
11
|
-
normalizeUrl = require('normalize-url');
|
|
12
|
-
|
|
13
|
-
urlParse = require('url').parse;
|
|
14
|
-
|
|
15
|
-
Handler = class Handler {
|
|
16
|
-
constructor(args) {
|
|
17
|
-
var m;
|
|
18
|
-
m = require('./conf');
|
|
19
|
-
this.conf = new m(args);
|
|
20
|
-
this.logger = this.conf.logger;
|
|
21
|
-
this.userLogger = this.conf.userLogger;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
run(req, res, next) {
|
|
25
|
-
var id, normalizedUrl, protection, self, u, uri, vhost;
|
|
26
|
-
self = this;
|
|
27
|
-
vhost = req.headers.host;
|
|
28
|
-
normalizedUrl = normalizeUrl(vhost + req.url);
|
|
29
|
-
uri = urlParse(normalizedUrl).path;
|
|
30
|
-
if (this.conf.tsv.maintenance[vhost]) {
|
|
31
|
-
self.logger.info(`Go to portal with maintenance error code ${vhost}`);
|
|
32
|
-
return this.setError(res, '/', 503, 'Service Temporarily Unavailable');
|
|
33
|
-
}
|
|
34
|
-
protection = this.isUnprotected(req, uri);
|
|
35
|
-
// Skip value is 2
|
|
36
|
-
if (protection === 2) {
|
|
37
|
-
next();
|
|
38
|
-
return new Promise(function(resolve, reject) {
|
|
39
|
-
return resolve(true);
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
id = this.fetchId(req);
|
|
43
|
-
if (id) {
|
|
44
|
-
return self.retrieveSession(id).then(function(session) {
|
|
45
|
-
return self.grant(req, uri, session).then(function() {
|
|
46
|
-
// TODO: display uid
|
|
47
|
-
self.userLogger.info(`User ${session[self.conf.tsv.whatToTrace]} was granted to access to ${uri}`);
|
|
48
|
-
self.sendHeaders(req, session);
|
|
49
|
-
self.hideCookie(req);
|
|
50
|
-
return next();
|
|
51
|
-
}).catch(function(e) {
|
|
52
|
-
self.userLogger.warn(`${session[self.conf.tsv.whatToTrace]} rejected: ` + (e != null ? (e.message != null ? e.message : e) : ''));
|
|
53
|
-
return self.forbidden(req, res, session);
|
|
54
|
-
});
|
|
55
|
-
}).catch(function(e) {
|
|
56
|
-
self.logger.info(`Session error: ${e}`);
|
|
57
|
-
return self.goToPortal(res, 'http://' + vhost + uri);
|
|
58
|
-
});
|
|
59
|
-
} else {
|
|
60
|
-
self.logger.debug("No id");
|
|
61
|
-
u = `://${vhost}${uri}`;
|
|
62
|
-
if ((this.conf.tsv.https != null) && this.conf.tsv.https[vhost]) {
|
|
63
|
-
u = `https${u}`;
|
|
64
|
-
} else {
|
|
65
|
-
u = `http${u}`;
|
|
66
|
-
}
|
|
67
|
-
return this.goToPortal(res, u);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
nginxServer(options) {
|
|
72
|
-
var fcgiOpt, k, self, srv;
|
|
73
|
-
self = this;
|
|
74
|
-
fcgiOpt = {
|
|
75
|
-
mode: "fcgi",
|
|
76
|
-
port: 9090,
|
|
77
|
-
ip: 'localhost'
|
|
78
|
-
};
|
|
79
|
-
if (options != null) {
|
|
80
|
-
for (k in fcgiOpt) {
|
|
81
|
-
if (options[k] != null) {
|
|
82
|
-
fcgiOpt[k] = options[k];
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
// Define server
|
|
87
|
-
srv = fcgiOpt.mode === 'fcgi' ? require('node-fastcgi') : require('http');
|
|
88
|
-
srv.createServer(function(req, res) {
|
|
89
|
-
var next, resp;
|
|
90
|
-
next = function() {
|
|
91
|
-
return res.writeHead(200, req.headers);
|
|
92
|
-
};
|
|
93
|
-
resp = self.run(req, res, next);
|
|
94
|
-
if (resp.then) {
|
|
95
|
-
return resp.then(function() {
|
|
96
|
-
return res.end();
|
|
97
|
-
});
|
|
98
|
-
} else {
|
|
99
|
-
return res.end();
|
|
100
|
-
}
|
|
101
|
-
}).listen(fcgiOpt.port, fcgiOpt.ip);
|
|
102
|
-
return self.logger.info("Server started at " + fcgiOpt.ip + ":" + fcgiOpt.port);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
grant(req, uri, session) {
|
|
106
|
-
var d, self;
|
|
107
|
-
self = this;
|
|
108
|
-
d = new Promise(function(resolve, reject) {
|
|
109
|
-
var i, j, len, ref, rule, vhost;
|
|
110
|
-
vhost = self.resolveAlias(req);
|
|
111
|
-
if (self.conf.tsv.defaultCondition[vhost] == null) {
|
|
112
|
-
self.logger.error(`No configuration found for ${vhost} (or not listed in Node.js virtualHosts)`);
|
|
113
|
-
return reject();
|
|
114
|
-
}
|
|
115
|
-
if (self.conf.tsv.locationRegexp[vhost] == null) {
|
|
116
|
-
self.conf.tsv.locationRegexp[vhost] = [];
|
|
117
|
-
}
|
|
118
|
-
ref = self.conf.tsv.locationRegexp[vhost];
|
|
119
|
-
for (i = j = 0, len = ref.length; j < len; i = ++j) {
|
|
120
|
-
rule = ref[i];
|
|
121
|
-
if (uri.match(rule)) {
|
|
122
|
-
return resolve(self.conf.tsv.locationCondition[vhost][i](req, session));
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
if (self.conf.tsv.defaultCondition[vhost](req, session)) {
|
|
126
|
-
return resolve();
|
|
127
|
-
} else {
|
|
128
|
-
return reject();
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
return d;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
forbidden(req, res, session) {
|
|
135
|
-
var u, uri;
|
|
136
|
-
uri = req.uri;
|
|
137
|
-
u = session._logout;
|
|
138
|
-
if (u) {
|
|
139
|
-
return this.goToPortal(res, u, 'logout=1');
|
|
140
|
-
}
|
|
141
|
-
// req.redirect is defined when running under express. If not
|
|
142
|
-
// we are running as FastCGI server
|
|
143
|
-
return this.setError(res, '/', 403, 'Forbidden');
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
sendHeaders(req, session) {
|
|
147
|
-
var err, i, k, ref, v, vhost;
|
|
148
|
-
vhost = this.resolveAlias(req);
|
|
149
|
-
try {
|
|
150
|
-
i = 0;
|
|
151
|
-
req.headers['Lm-Remote-User'] = session[this.conf.tsv.whatToTrace];
|
|
152
|
-
ref = this.conf.tsv.forgeHeaders[vhost](session);
|
|
153
|
-
for (k in ref) {
|
|
154
|
-
v = ref[k];
|
|
155
|
-
i++;
|
|
156
|
-
req.headers[k] = v;
|
|
157
|
-
req.rawHeaders.push(k, v);
|
|
158
|
-
// req.redirect is defined when running under express. If not
|
|
159
|
-
// we are running as FastCGI server
|
|
160
|
-
if (req.redirect == null) {
|
|
161
|
-
req.headers[`Headername${i}`] = k;
|
|
162
|
-
req.headers[`Headervalue${i}`] = v;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
} catch (error) {
|
|
166
|
-
err = error;
|
|
167
|
-
this.logger.warn(`No headers configuration found for ${vhost}: ${err}`);
|
|
168
|
-
}
|
|
169
|
-
return true;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
resolveAlias(req) {
|
|
173
|
-
var vhost;
|
|
174
|
-
vhost = req.headers.host.replace(/:.*$/, '');
|
|
175
|
-
return this.conf.tsv.vhostAlias[vhost] || vhost;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// Get cookie value
|
|
179
|
-
fetchId(req) {
|
|
180
|
-
var cor;
|
|
181
|
-
if (req.headers.cookie) {
|
|
182
|
-
cor = this.conf.tsv.cookieDetect.exec(req.headers.cookie);
|
|
183
|
-
if (cor && cor[1] !== '0') {
|
|
184
|
-
return cor[1];
|
|
185
|
-
}
|
|
186
|
-
} else {
|
|
187
|
-
return false;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// Get session from store
|
|
192
|
-
retrieveSession(id) {
|
|
193
|
-
var d, self;
|
|
194
|
-
self = this;
|
|
195
|
-
d = new Promise(function(resolve, reject) {
|
|
196
|
-
return self.conf.sa.get(id).then(function(session) {
|
|
197
|
-
var now;
|
|
198
|
-
// Timestamp in seconds
|
|
199
|
-
now = Date.now() / 1000 | 0;
|
|
200
|
-
if (now - session._utime > self.conf.tsv.timeout || (self.conf.tsv.timeoutActivity && session._lastSeen && now - $session._lastSeen > self.conf.tsv.timeoutActivity)) {
|
|
201
|
-
self.userLogger.info(`Session ${id} expired`);
|
|
202
|
-
reject(false);
|
|
203
|
-
}
|
|
204
|
-
// Update the session to notify activity, if necessary
|
|
205
|
-
if (self.conf.tsv.timeoutActivity && now - session._lastSeen > 60) {
|
|
206
|
-
session._lastSeen = now;
|
|
207
|
-
self.conf.sa.update(id, session);
|
|
208
|
-
}
|
|
209
|
-
return resolve(session);
|
|
210
|
-
}).catch(function(e) {
|
|
211
|
-
self.userLogger.info(`Session ${id} can't be found in store: ${e}`);
|
|
212
|
-
return reject(false);
|
|
213
|
-
});
|
|
214
|
-
});
|
|
215
|
-
return d;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
// Check if uri is protected
|
|
219
|
-
isUnprotected(req, uri) {
|
|
220
|
-
var i, j, len, ref, rule, vhost;
|
|
221
|
-
vhost = this.resolveAlias(req);
|
|
222
|
-
if (this.conf.tsv.defaultCondition[vhost] == null) {
|
|
223
|
-
return false;
|
|
224
|
-
}
|
|
225
|
-
ref = this.conf.tsv.locationRegexp[vhost];
|
|
226
|
-
for (i = j = 0, len = ref.length; j < len; i = ++j) {
|
|
227
|
-
rule = ref[i];
|
|
228
|
-
if (uri.match(rule)) {
|
|
229
|
-
return this.conf.tsv.locationProtection[vhost][i];
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
return this.conf.tsv.defaultProtection[vhost];
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
// Remove LLNG cookie from headers
|
|
236
|
-
hideCookie(req) {
|
|
237
|
-
return req.headers.cookie = req.headers.cookie.replace(this.conf.tsv.cookieDetect, '');
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
goToPortal(res, uri, args) {
|
|
241
|
-
var urlc;
|
|
242
|
-
if (typeof this.conf.tsv.portal !== 'function') {
|
|
243
|
-
console.error("Configuration is not ready");
|
|
244
|
-
if (res.redirect) {
|
|
245
|
-
res.status(503).send('Waiting for configuration');
|
|
246
|
-
} else {
|
|
247
|
-
res.writeHead(503);
|
|
248
|
-
res.end();
|
|
249
|
-
}
|
|
250
|
-
return res;
|
|
251
|
-
}
|
|
252
|
-
urlc = this.conf.tsv.portal();
|
|
253
|
-
if (uri) {
|
|
254
|
-
urlc += '?url=' + new Buffer.from(encodeURI(uri)).toString('base64');
|
|
255
|
-
}
|
|
256
|
-
if (args) {
|
|
257
|
-
urlc += uri ? '&' : '?';
|
|
258
|
-
urlc += args;
|
|
259
|
-
}
|
|
260
|
-
// req.redirect is defined when running under express. If not
|
|
261
|
-
// we are running as FastCGI server
|
|
262
|
-
this.logger.debug("Redirecting to " + urlc);
|
|
263
|
-
if (res.redirect) {
|
|
264
|
-
res.redirect(urlc);
|
|
265
|
-
} else {
|
|
266
|
-
// Nginx doesn't accept 302 from a auth request. LLNG Nginx configuration
|
|
267
|
-
// maps 401 to 302 when "Location" is set
|
|
268
|
-
res.writeHead(401, {
|
|
269
|
-
Location: urlc
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
return res;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
setError(res, uri, code, txt) {
|
|
276
|
-
var u;
|
|
277
|
-
if (this.conf.tsv.useRedirectOnError) {
|
|
278
|
-
u = this.conf.tsv.portal() + `?lmError=${code}&url=` + new Buffer.from(encodeURI(uri)).toString('base64');
|
|
279
|
-
this.logger.debug(`Redirecting to ${u}`);
|
|
280
|
-
if (res.redirect != null) {
|
|
281
|
-
return res.redirect(u);
|
|
282
|
-
} else {
|
|
283
|
-
// Nginx doesn't accept 302 from a auth request. LLNG Nginx configuration
|
|
284
|
-
// maps 401 to 302 when "Location" is set
|
|
285
|
-
return res.writeHead(401, {
|
|
286
|
-
Location: u
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
|
-
} else {
|
|
290
|
-
if (res.redirect != null) {
|
|
291
|
-
return res.status(code).send(txt);
|
|
292
|
-
} else {
|
|
293
|
-
return res.writeHead(code, txt);
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
};
|
|
299
|
-
|
|
300
|
-
h = {};
|
|
301
|
-
|
|
302
|
-
module.exports = {
|
|
303
|
-
init: function(args) {
|
|
304
|
-
var err;
|
|
305
|
-
if (args.type) {
|
|
306
|
-
try {
|
|
307
|
-
h = require('./handler' + args.type);
|
|
308
|
-
return h = new h(args);
|
|
309
|
-
} catch (error) {
|
|
310
|
-
err = error;
|
|
311
|
-
console.error(`Unable to load ${args.type} handler: ${err}`);
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
return h = new Handler(args);
|
|
315
|
-
},
|
|
316
|
-
run: function(req, res, next) {
|
|
317
|
-
return h.run(req, res, next);
|
|
318
|
-
},
|
|
319
|
-
nginxServer: function(options) {
|
|
320
|
-
return h.nginxServer(options);
|
|
321
|
-
},
|
|
322
|
-
class: Handler
|
|
323
|
-
};
|
|
324
|
-
|
|
325
|
-
}).call(this);
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@lemonldap-ng/conf"),e=require("@lemonldap-ng/session"),o=require("@lemonldap-ng/safelib"),s=require("@lemonldap-ng/logger"),r=require("vm"),i=require("re2"),n=require("http");function a(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}function c(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(o){if("default"!==o){var s=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(e,o,s.get?s:{enumerable:!0,get:function(){return t[o]}})}})),e.default=t,Object.freeze(e)}var h=a(t),l=a(e),d=a(o),u=a(s),p=a(r),f=a(i),v=a(n);const g=new f.default("^logout(?:_sso|_app|_app_sso|)(?:s+(.*))?$","i");let m=0;const w=["cda","cookieExpiration","cipher","cookieName","customFunctions","httpOnly","securedCookie","timeout","timeoutActivity","useRedirectOnError","useRedirectOnForbidden","whatToTrace","loopBackUrl"];const y=(t,e)=>e.some((e=>e instanceof RegExp?e.test(t):e===t));function b(t,e){if(e={defaultProtocol:"http:",normalizeProtocol:!0,forceHttp:!1,forceHttps:!1,stripAuthentication:!0,stripHash:!1,stripTextFragment:!0,stripWWW:!0,removeQueryParameters:[/^utm_\w+/i],removeTrailingSlash:!0,removeSingleSlash:!0,removeDirectoryIndex:!1,sortQueryParameters:!0,...e},t=t.trim(),/^data:/i.test(t))return((t,{stripHash:e})=>{const o=/^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(t);if(!o)throw new Error(`Invalid URL: ${t}`);let{type:s,data:r,hash:i}=o.groups;const n=s.split(";");i=e?"":i;let a=!1;"base64"===n[n.length-1]&&(n.pop(),a=!0);const c=(n.shift()||"").toLowerCase(),h=[...n.map((t=>{let[e,o=""]=t.split("=").map((t=>t.trim()));return"charset"===e&&(o=o.toLowerCase(),"us-ascii"===o)?"":`${e}${o?`=${o}`:""}`})).filter(Boolean)];return a&&h.push("base64"),(h.length>0||c&&"text/plain"!==c)&&h.unshift(c),`data:${h.join(";")},${a?r.trim():r}${i?`#${i}`:""}`})(t,e);if(/^view-source:/i.test(t))throw new Error("`view-source:` is not supported as it is a non-standard protocol");const o=t.startsWith("//");!o&&/^\.*\//.test(t)||(t=t.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,e.defaultProtocol));const s=new URL(t);if(e.forceHttp&&e.forceHttps)throw new Error("The `forceHttp` and `forceHttps` options cannot be used together");if(e.forceHttp&&"https:"===s.protocol&&(s.protocol="http:"),e.forceHttps&&"http:"===s.protocol&&(s.protocol="https:"),e.stripAuthentication&&(s.username="",s.password=""),e.stripHash?s.hash="":e.stripTextFragment&&(s.hash=s.hash.replace(/#?:~:text.*?$/i,"")),s.pathname){const t=/\b[a-z][a-z\d+\-.]{1,50}:\/\//g;let e=0,o="";for(;;){const r=t.exec(s.pathname);if(!r)break;const i=r[0],n=r.index;o+=s.pathname.slice(e,n).replace(/\/{2,}/g,"/"),o+=i,e=n+i.length}o+=s.pathname.slice(e,s.pathname.length).replace(/\/{2,}/g,"/"),s.pathname=o}if(s.pathname)try{s.pathname=decodeURI(s.pathname)}catch{}if(!0===e.removeDirectoryIndex&&(e.removeDirectoryIndex=[/^index\.[a-z]+$/]),Array.isArray(e.removeDirectoryIndex)&&e.removeDirectoryIndex.length>0){let t=s.pathname.split("/");const o=t[t.length-1];y(o,e.removeDirectoryIndex)&&(t=t.slice(0,-1),s.pathname=t.slice(1).join("/")+"/")}if(s.hostname&&(s.hostname=s.hostname.replace(/\.$/,""),e.stripWWW&&/^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(s.hostname)&&(s.hostname=s.hostname.replace(/^www\./,""))),Array.isArray(e.removeQueryParameters))for(const t of[...s.searchParams.keys()])y(t,e.removeQueryParameters)&&s.searchParams.delete(t);if(!0===e.removeQueryParameters&&(s.search=""),e.sortQueryParameters){s.searchParams.sort();try{s.search=decodeURIComponent(s.search)}catch{}}e.removeTrailingSlash&&(s.pathname=s.pathname.replace(/\/$/,""));const r=t;return t=s.toString(),e.removeSingleSlash||"/"!==s.pathname||r.endsWith("/")||""!==s.hash||(t=t.replace(/\/$/,"")),(e.removeTrailingSlash||"/"===s.pathname)&&""===s.hash&&e.removeSingleSlash&&(t=t.replace(/\/$/,"")),o&&!e.normalizeProtocol&&(t=t.replace(/^http:\/\//,"//")),e.stripProtocol&&(t=t.replace(/^(?:https?:)?\/\//,"")),t}class $ extends class{constructor(t){this.safe={},this.tsv={defaultCondition:{},defaultProtection:{},forgeHeaders:{},headerList:{},https:{},locationCondition:{},locationCount:{},locationProtection:{},locationRegexp:{},maintenance:{},port:{},portal:()=>"",vhostAlias:{}},this.localConf=t,t.configStorage||(t.configStorage={}),t.configStorage.localStorage||(t.configStorage.localStorage=t.localStorage),t.configStorage.localStorageOptions||(t.configStorage.localStorageOptions=t.localStorageOptions),this.confAcc=new h.default(t.configStorage);if([this.confAcc.getLocalConf("handler",!0),this.confAcc.getLocalConf("node-handler",!1)].forEach((t=>{Object.keys(t).forEach((e=>{if(!this.localConf)throw new Error("undef");void 0===this.localConf[e]&&(this.localConf[e]=t[e])}))})),void 0===this.localConf.nodeVhosts)throw new Error("No Virtualhosts configured for Node.js");this.vhostList=this.localConf.nodeVhosts.split(/[,\s]+/)}reload(){return new Promise(((t,e)=>{this.confAcc.ready.then((()=>{this.confAcc.getConf({}).then((e=>{if(w.forEach((t=>{this.tsv[t]=e[t]})),Object.keys(this.localConf).forEach((t=>{e[t]=this.localConf[t]})),["https","port","maintenance"].forEach((t=>{if(void 0!==e[t]&&(this.tsv[t]={_:e[t]},e.vhostOptions)){const s=`vhost${o=t,o.charAt(0).toUpperCase()+o.slice(1)}`;Object.keys(e.vhostOptions).forEach((o=>{const r=e.vhostOptions[o][s];r>0&&(this.tsv[t][o]=r)}))}var o})),!e.portal)throw new Error("portal should be defined");if(this.tsv.portal=()=>e.portal,!e.globalStorage||!e.globalStorageOptions)throw new Error("Bad session storage coniguration");try{this.sessionAcc=new l.default({storageModule:e.globalStorage,storageModuleOptions:e.globalStorageOptions})}catch(t){throw new Error(`Unable to load session module: ${t}`)}Object.keys(e.locationRules).forEach((t=>{if(-1==this.vhostList.indexOf(t))return;this.tsv.locationCount[t]=0,["locationRegexp","locationProtection","locationCondition"].forEach((e=>{void 0===this.tsv[e][t]&&(this.tsv[e][t]=[])})),this.safe[t]||(this.safe[t]=new d.default(e));const o=e.locationRules[t];Object.keys(o).forEach((e=>{const[s,r]=this.conditionSub(o[e],this.safe[t]);"default"===e?(this.tsv.defaultCondition[t]=s,this.tsv.defaultProtection[t]=r):(this.tsv.locationCondition[t].push(s),this.tsv.locationProtection[t].push(r),this.tsv.locationRegexp[t].push(new f.default(e.replace(/\(\?#.*?\)/,""))),this.tsv.locationCount[t]++)})),this.tsv.defaultCondition[t]||(this.tsv.defaultCondition[t]=()=>!0,this.tsv.defaultProtection[t]=0)})),void 0!==e.exportedHeaders&&Object.keys(e.exportedHeaders).forEach((t=>{const o=e.exportedHeaders[t];if(-1==this.vhostList.indexOf(t))return;this.tsv.headerList[t]||(this.tsv.headerList[t]=[]);let s="";Object.keys(o).forEach((e=>{this.tsv.headerList[t].push(e),s+=`'${e}': ${this.substitute(o[e])},`})),s=s.replace(/,$/,""),p.default.runInContext(`fg = function(session) {return {${s}};}`,this.safe[t]),this.tsv.forgeHeaders[t]=this.safe[t].fg})),void 0!==e.vhostOptions&&Object.keys(e.vhostOptions).forEach((t=>{e.vhostOptions[t].aliases&&e.vhostOptions[t].aliases.forEach((e=>{this.tsv.vhostAlias[e]=t}))})),this.tsv.cookieDetect=new f.default(`\\b${this.tsv.cookieName}=([^;]+)`),this.sessionAcc.ready.then((()=>{t(!0),u.default(e,!0).then((e=>{this.userLogger=e,t(!0)})).catch((t=>{throw console.error("Logger error",t),new Error(t)}))}))})).catch((t=>{e(`Unable to get configuration: ${t}`)}))}))}))}conditionSub(t,e){const o=()=>!0;if("accept"===t)return[o,0];if("deny"===t)return[()=>!1,0];if("unprotect"===t)return[o,1];if("skip"===t)return[o,2];const s=g.exec(t);if(s&&s[1]){const t=s[1];return t?[e=>(e._logout=t,!1),0]:[t=>(t._logout=this.tsv.portal(),!1),0]}if(t=this.substitute(t),e)return m++,p.default.runInContext(`sub${m.toString()} = function(req,session) {return (${t});}`,e),[e[`sub${m.toString()}`],0];throw new Error("Disabling safeJail is not supported")}substitute(t){return t.replace(/\$date\b/g,"this.date()").replace(/\$vhost\b/g,"this.hostname(req)").replace(/\$ip\b/g,"this.remote_ip(req)").replace(/\$(_*[a-zA-Z]\w*)/g,"session.$1")}}{init(){return this.reload()}run(t,e,o){const s=t.headers.host;if(void 0===s)return this.userLogger.error("Request without Host header"),void this.setError(e,"/",400,"Bad request");const r=new URL(b(s+t.url)).pathname||"/";if(this.tsv.maintenance[s])return this.setError(e,"/",503,"Service Temporarily Unavailable");if(2===this.isUnprotected(t,r))return o();const i=this.fetchId(t);""!==i?this.retrieveSession(i).then((i=>{const n=i[this.tsv.whatToTrace];this.userLogger.debug(`User ${n} identified`),this.grant(t,r,i).then((a=>{a?(this.sendHeaders(t,i),this.hideCookie(t),o(),this.userLogger.info(`${s}: user ${n} was granted access to ${r}`)):(this.forbidden(t,e,i),this.userLogger.notice(`${s}: user ${n} was denied access to ${r}`))})).catch((t=>{console.error(t),this.setError(e,"/",500,"Server error")}))})).catch((t=>{this.goToPortal(e,this.selfUri(s,r))})):this.goToPortal(e,this.selfUri(s,r))}selfUri(t,e){return(this.tsv.https&&this.tsv.https[t]?"https":"http")+"://"+t+e}nginxServer(t){t.mode||(t.mode="fcgi"),t.port||(t.port=9090),t.ip||(t.ip="localhost");("fcgi"===t.mode?require("node-fastcgi"):v.default).createServer(((t,e)=>{this.run(t,e,(()=>{e.writeHead(200,t.headers)}))})).listen(t.port,t.ip)}setError(t,e,o,s){if(this.tsv.useRedirectOnError){const e=this.tsv.portal()+`?lmError=${o.toString()}&url=`;t.redirect?t.redirect(e):t.writeHead(401,{Location:e})}else t.redirect?t.status(o).send(s):t.writeHead(o,s)}isUnprotected(t,e){const o=this.resolveAlias(t);if(!this.tsv.defaultCondition[o])return!1;for(let t=0;t<this.tsv.locationRegexp[o].length;t++)if(this.tsv.locationRegexp[o][t].test(e))return this.tsv.locationProtection[o][t];return this.tsv.defaultProtection[o]}resolveAlias(t){const e=t.headers.host.replace(/:.*$/,"");return this.tsv.vhostAlias[e]||e}fetchId(t){if(t.headers.cookie){const e=this.tsv.cookieDetect.exec(t.headers.cookie);if(e&&"0"!=e[1])return e[1]}return""}retrieveSession(t){return new Promise(((e,o)=>{if(void 0===this.sessionAcc)return o("Server not ready, please wait");this.sessionAcc.get(t).then((s=>{const r=Date.now()/1e3|0;r-s._utime>this.tsv.timeout||this.tsv.timeoutActivity&&s._lastSeen&&r-s._lastSeen>this.tsv.timeoutActivity?o(`Session ${t} expired`):(this.tsv.timeoutActivity&&r-s._lastSeen>60&&(s._lastSeen=r,this.sessionAcc.update(s)),e(s))})).catch((e=>{o(`Session ${t} can't be found in store: ${e}`)}))}))}grant(t,e,o){return new Promise(((s,r)=>{const i=this.resolveAlias(t);if(!this.tsv.defaultCondition[i])return r(`No configuration found for ${i} (or not listed in Node.js virtualHosts)`);if(this.tsv.locationRegexp[i]){let r=0;this.tsv.locationRegexp[i].forEach((n=>{if(n.test(e))return s(this.tsv.locationCondition[i][r](t,o));r++}))}this.tsv.defaultCondition[i](t,o)?s(!0):r("Unauthorized")}))}sendHeaders(t,e){const o=this.resolveAlias(t);try{let s=0;t.headers["Lm-Remote-User"]=e[this.tsv.whatToTrace];const r=this.tsv.forgeHeaders[o](e);Object.keys(r).forEach((e=>{s++,t.headers[e]=r[e],t.rawHeaders.push(e,r[e]),t.redirect||(t.headers[`Headername${s}`]=e,t.headers[`Headervalue${s}`]=r[e])}))}catch(t){return void console.error(`Headers maybe not sent: ${t}`)}}hideCookie(t){t.headers.cookie&&(t.headers.cookie=t.headers.cookie.replace(this.tsv.cookieDetect,""))}forbidden(t,e,o){o._logout?this.goToPortal(e,o._logout,"logout=1"):this.setError(e,"/",403,"Forbidden")}goToPortal(t,e,o=""){if("function"!=typeof this.tsv.portal)return void this.setError(t,e,503,"Waiting for configuration");const s=this.tsv.portal()+(e?"?url="+new Buffer.from(encodeURI(e)).toString("base64"):"")+(o?(e?"&":"?")+o:"");t.redirect?t.redirect(s):t.writeHead(401,{Location:s})}}class x extends ${constructor(t){super(t),this.tsv.lastVhostUpdate={}}grant(t,e,o){const s=this.resolveAlias(t);if(this.tsv.defaultCondition[s]&&Date.now()/1e3-this.tsv.lastVhostUpdate[s]<600)return super.grant(t,e,o);const r=t.cgiParams&&t.cgiParams.RULES_URL?t.cgiParams.RULES_URL:(this.tsv.loopBackUrl||"http://127.0.0.1")+"/rules.json";if(!/^(https?):\/\/([^/:]+)(?::(\d+))?(.*)$/.test(r))return new Promise(((t,e)=>e(`Bad loopBackUrl ${r}`)));const i={prot:RegExp.$1,host:RegExp.$2,path:RegExp.$4,port:RegExp.$3||("https"==RegExp.$1?"443":"80"),lb:!(t.cgiParams&&t.cgiParams.RULES_URL)};return new Promise(((r,n)=>{this.loadVhostConfig(t,s,i).then((()=>{this.grant(t,e,o).then((t=>{r(t)})).catch((t=>n(t)))})).catch((s=>{console.error(s),this.grant(t,e,o).then((t=>{r(t)})).catch((t=>n(t)))}))}))}loadVhostConfig(t,e,o){return new Promise(((t,s)=>{o.lb||(e=o.host),delete o.lb,o.headers={Host:e};const r=require(o.prot);delete o.prot;const i=r.request(o,(o=>{let r="";o.on("data",(t=>{r+=t})),o.on("end",(()=>{if(this.tsv.locationCondition[e]=[],this.tsv.locationProtection[e]=[],this.tsv.locationRegexp[e]=[],this.tsv.locationCount[e]=0,this.tsv.headerList[e]=[],""===r)return this.tsv.defaultCondition[e]=()=>!0,this.tsv.defaultProtection[e]=0,this.tsv.lastVhostUpdate[e]=Date.now()/1e3,t(!0);try{const o=JSON.parse(r);if(this.safe[e]=new d.default({cipher:this.tsv.cipher}),o.rules&&"object"==typeof o.rules&&(Object.keys(o.rules).forEach((t=>{const s=new String(o.rules[t]).valueOf();let r,i;[r,i]=this.conditionSub(s,this.safe[e]),"default"===t?(this.tsv.defaultCondition[e]=r,this.tsv.defaultProtection[e]=i):(this.tsv.locationCondition[e].push(r),this.tsv.locationProtection[e].push(i),this.tsv.locationRegexp[e].push(new f.default(t.replace(/\(\?#.*?\)/,""))),this.tsv.locationCount[e]++)})),this.tsv.defaultCondition[e]||(this.tsv.defaultCondition[e]=()=>!0,this.tsv.defaultProtection[e]=0)),o.headers&&"object"==typeof o.headers){const t=Object.keys(o.headers).map((t=>(this.tsv.headerList[e].push(t),`'${t}': ${this.substitute(o.headers[t])}`))).join(",");p.default.runInContext(`fg = function(session) {return {${t}}}`,this.safe[e]),this.tsv.forgeHeaders[e]=this.safe[e].fg}this.tsv.lastVhostUpdate[e]=Date.now()/1e3,t(!0)}catch(t){s("Unable to getremote config: "+t)}})),i.on("error",(t=>{s(t)})),i.end()}))}))}}class S extends ${fetchId(t){const e=t.cgiParams?t.cgiParams.HTTP_X_LLNG_TOKEN:t.headers["x-llng-token"];if(e){const o=this.tsv.cipher.decrypt(e).split(":");if(!o[2])return console.warn("Bad service token"),"";const s=Date.now()/1e3,r=parseInt(o[0]);if(r<s-30||r>s)return console.warn("Expired service token"),"";const i=this.resolveAlias(t);return o.indexOf(i)<2?(console.warn(`${i} not authorizated in token`),""):o[1]}return super.fetchId(t)}}let P;exports.class=void 0;const E={Main:$,DevOps:x,ServiceToken:S,ServiceTokenST:class extends x{fetchId(t){return S.prototype.fetchId.call(this,t)}}};exports.init=t=>new Promise(((e,o)=>{var s;t.type||(t.type="Main"),E[t.type]?(exports.class=E[t.type],P=new E[t.type](t),P.init().then((()=>e(P))).catch((t=>o(t)))):(s="@lemonldap-ng/handler-"+t.type.toLowerCase(),Promise.resolve().then((function(){return c(require(s))}))).then((o=>{exports.class=o.default,P=new exports.class(t),P.init().then((()=>e(P)))})).catch((t=>o(t)))})),exports.nginxServer=t=>{P.nginxServer(t)},exports.run=(t,e,o)=>P.run(t,e,o);
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/init.ts","../../../node_modules/normalize-url/index.js","../src/handlerMain.ts","../src/handlerDevOps.ts","../src/handlerServiceToken.ts","../src/index.ts","../src/handlerDevOpsST.ts"],"sourcesContent":[null,"// https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs\nconst DATA_URL_DEFAULT_MIME_TYPE = 'text/plain';\nconst DATA_URL_DEFAULT_CHARSET = 'us-ascii';\n\nconst testParameter = (name, filters) => filters.some(filter => filter instanceof RegExp ? filter.test(name) : filter === name);\n\nconst normalizeDataURL = (urlString, {stripHash}) => {\n\tconst match = /^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(urlString);\n\n\tif (!match) {\n\t\tthrow new Error(`Invalid URL: ${urlString}`);\n\t}\n\n\tlet {type, data, hash} = match.groups;\n\tconst mediaType = type.split(';');\n\thash = stripHash ? '' : hash;\n\n\tlet isBase64 = false;\n\tif (mediaType[mediaType.length - 1] === 'base64') {\n\t\tmediaType.pop();\n\t\tisBase64 = true;\n\t}\n\n\t// Lowercase MIME type\n\tconst mimeType = (mediaType.shift() || '').toLowerCase();\n\tconst attributes = mediaType\n\t\t.map(attribute => {\n\t\t\tlet [key, value = ''] = attribute.split('=').map(string => string.trim());\n\n\t\t\t// Lowercase `charset`\n\t\t\tif (key === 'charset') {\n\t\t\t\tvalue = value.toLowerCase();\n\n\t\t\t\tif (value === DATA_URL_DEFAULT_CHARSET) {\n\t\t\t\t\treturn '';\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn `${key}${value ? `=${value}` : ''}`;\n\t\t})\n\t\t.filter(Boolean);\n\n\tconst normalizedMediaType = [\n\t\t...attributes,\n\t];\n\n\tif (isBase64) {\n\t\tnormalizedMediaType.push('base64');\n\t}\n\n\tif (normalizedMediaType.length > 0 || (mimeType && mimeType !== DATA_URL_DEFAULT_MIME_TYPE)) {\n\t\tnormalizedMediaType.unshift(mimeType);\n\t}\n\n\treturn `data:${normalizedMediaType.join(';')},${isBase64 ? data.trim() : data}${hash ? `#${hash}` : ''}`;\n};\n\nexport default function normalizeUrl(urlString, options) {\n\toptions = {\n\t\tdefaultProtocol: 'http:',\n\t\tnormalizeProtocol: true,\n\t\tforceHttp: false,\n\t\tforceHttps: false,\n\t\tstripAuthentication: true,\n\t\tstripHash: false,\n\t\tstripTextFragment: true,\n\t\tstripWWW: true,\n\t\tremoveQueryParameters: [/^utm_\\w+/i],\n\t\tremoveTrailingSlash: true,\n\t\tremoveSingleSlash: true,\n\t\tremoveDirectoryIndex: false,\n\t\tsortQueryParameters: true,\n\t\t...options,\n\t};\n\n\turlString = urlString.trim();\n\n\t// Data URL\n\tif (/^data:/i.test(urlString)) {\n\t\treturn normalizeDataURL(urlString, options);\n\t}\n\n\tif (/^view-source:/i.test(urlString)) {\n\t\tthrow new Error('`view-source:` is not supported as it is a non-standard protocol');\n\t}\n\n\tconst hasRelativeProtocol = urlString.startsWith('//');\n\tconst isRelativeUrl = !hasRelativeProtocol && /^\\.*\\//.test(urlString);\n\n\t// Prepend protocol\n\tif (!isRelativeUrl) {\n\t\turlString = urlString.replace(/^(?!(?:\\w+:)?\\/\\/)|^\\/\\//, options.defaultProtocol);\n\t}\n\n\tconst urlObject = new URL(urlString);\n\n\tif (options.forceHttp && options.forceHttps) {\n\t\tthrow new Error('The `forceHttp` and `forceHttps` options cannot be used together');\n\t}\n\n\tif (options.forceHttp && urlObject.protocol === 'https:') {\n\t\turlObject.protocol = 'http:';\n\t}\n\n\tif (options.forceHttps && urlObject.protocol === 'http:') {\n\t\turlObject.protocol = 'https:';\n\t}\n\n\t// Remove auth\n\tif (options.stripAuthentication) {\n\t\turlObject.username = '';\n\t\turlObject.password = '';\n\t}\n\n\t// Remove hash\n\tif (options.stripHash) {\n\t\turlObject.hash = '';\n\t} else if (options.stripTextFragment) {\n\t\turlObject.hash = urlObject.hash.replace(/#?:~:text.*?$/i, '');\n\t}\n\n\t// Remove duplicate slashes if not preceded by a protocol\n\t// NOTE: This could be implemented using a single negative lookbehind\n\t// regex, but we avoid that to maintain compatibility with older js engines\n\t// which do not have support for that feature.\n\tif (urlObject.pathname) {\n\t\t// TODO: Replace everything below with `urlObject.pathname = urlObject.pathname.replace(/(?<!\\b[a-z][a-z\\d+\\-.]{1,50}:)\\/{2,}/g, '/');` when Safari supports negative lookbehind.\n\n\t\t// Split the string by occurrences of this protocol regex, and perform\n\t\t// duplicate-slash replacement on the strings between those occurrences\n\t\t// (if any).\n\t\tconst protocolRegex = /\\b[a-z][a-z\\d+\\-.]{1,50}:\\/\\//g;\n\n\t\tlet lastIndex = 0;\n\t\tlet result = '';\n\t\tfor (;;) {\n\t\t\tconst match = protocolRegex.exec(urlObject.pathname);\n\t\t\tif (!match) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tconst protocol = match[0];\n\t\t\tconst protocolAtIndex = match.index;\n\t\t\tconst intermediate = urlObject.pathname.slice(lastIndex, protocolAtIndex);\n\n\t\t\tresult += intermediate.replace(/\\/{2,}/g, '/');\n\t\t\tresult += protocol;\n\t\t\tlastIndex = protocolAtIndex + protocol.length;\n\t\t}\n\n\t\tconst remnant = urlObject.pathname.slice(lastIndex, urlObject.pathname.length);\n\t\tresult += remnant.replace(/\\/{2,}/g, '/');\n\n\t\turlObject.pathname = result;\n\t}\n\n\t// Decode URI octets\n\tif (urlObject.pathname) {\n\t\ttry {\n\t\t\turlObject.pathname = decodeURI(urlObject.pathname);\n\t\t} catch {}\n\t}\n\n\t// Remove directory index\n\tif (options.removeDirectoryIndex === true) {\n\t\toptions.removeDirectoryIndex = [/^index\\.[a-z]+$/];\n\t}\n\n\tif (Array.isArray(options.removeDirectoryIndex) && options.removeDirectoryIndex.length > 0) {\n\t\tlet pathComponents = urlObject.pathname.split('/');\n\t\tconst lastComponent = pathComponents[pathComponents.length - 1];\n\n\t\tif (testParameter(lastComponent, options.removeDirectoryIndex)) {\n\t\t\tpathComponents = pathComponents.slice(0, -1);\n\t\t\turlObject.pathname = pathComponents.slice(1).join('/') + '/';\n\t\t}\n\t}\n\n\tif (urlObject.hostname) {\n\t\t// Remove trailing dot\n\t\turlObject.hostname = urlObject.hostname.replace(/\\.$/, '');\n\n\t\t// Remove `www.`\n\t\tif (options.stripWWW && /^www\\.(?!www\\.)[a-z\\-\\d]{1,63}\\.[a-z.\\-\\d]{2,63}$/.test(urlObject.hostname)) {\n\t\t\t// Each label should be max 63 at length (min: 1).\n\t\t\t// Source: https://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_host_names\n\t\t\t// Each TLD should be up to 63 characters long (min: 2).\n\t\t\t// It is technically possible to have a single character TLD, but none currently exist.\n\t\t\turlObject.hostname = urlObject.hostname.replace(/^www\\./, '');\n\t\t}\n\t}\n\n\t// Remove query unwanted parameters\n\tif (Array.isArray(options.removeQueryParameters)) {\n\t\t// eslint-disable-next-line unicorn/no-useless-spread -- We are intentionally spreading to get a copy.\n\t\tfor (const key of [...urlObject.searchParams.keys()]) {\n\t\t\tif (testParameter(key, options.removeQueryParameters)) {\n\t\t\t\turlObject.searchParams.delete(key);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (options.removeQueryParameters === true) {\n\t\turlObject.search = '';\n\t}\n\n\t// Sort query parameters\n\tif (options.sortQueryParameters) {\n\t\turlObject.searchParams.sort();\n\n\t\t// Calling `.sort()` encodes the search parameters, so we need to decode them again.\n\t\ttry {\n\t\t\turlObject.search = decodeURIComponent(urlObject.search);\n\t\t} catch {}\n\t}\n\n\tif (options.removeTrailingSlash) {\n\t\turlObject.pathname = urlObject.pathname.replace(/\\/$/, '');\n\t}\n\n\tconst oldUrlString = urlString;\n\n\t// Take advantage of many of the Node `url` normalizations\n\turlString = urlObject.toString();\n\n\tif (!options.removeSingleSlash && urlObject.pathname === '/' && !oldUrlString.endsWith('/') && urlObject.hash === '') {\n\t\turlString = urlString.replace(/\\/$/, '');\n\t}\n\n\t// Remove ending `/` unless removeSingleSlash is false\n\tif ((options.removeTrailingSlash || urlObject.pathname === '/') && urlObject.hash === '' && options.removeSingleSlash) {\n\t\turlString = urlString.replace(/\\/$/, '');\n\t}\n\n\t// Restore relative protocol, if applicable\n\tif (hasRelativeProtocol && !options.normalizeProtocol) {\n\t\turlString = urlString.replace(/^http:\\/\\//, '//');\n\t}\n\n\t// Remove http/https\n\tif (options.stripProtocol) {\n\t\turlString = urlString.replace(/^(?:https?:)?\\/\\//, '');\n\t}\n\n\treturn urlString;\n}\n",null,null,null,null,null],"names":["condMatch","RE2","sid","requiredFields","testParameter","name","filters","some","filter","RegExp","test","normalizeUrl","urlString","options","defaultProtocol","normalizeProtocol","forceHttp","forceHttps","stripAuthentication","stripHash","stripTextFragment","stripWWW","removeQueryParameters","removeTrailingSlash","removeSingleSlash","removeDirectoryIndex","sortQueryParameters","trim","match","exec","Error","type","data","hash","groups","mediaType","split","isBase64","length","pop","mimeType","shift","toLowerCase","normalizedMediaType","map","attribute","key","value","string","Boolean","push","unshift","join","normalizeDataURL","hasRelativeProtocol","startsWith","replace","urlObject","URL","protocol","username","password","pathname","protocolRegex","lastIndex","result","protocolAtIndex","index","slice","decodeURI","Array","isArray","pathComponents","lastComponent","hostname","searchParams","keys","delete","search","sort","decodeURIComponent","oldUrlString","toString","endsWith","stripProtocol","LemonldapNGHandler","constructor","args","this","safe","tsv","defaultCondition","defaultProtection","forgeHeaders","headerList","https","locationCondition","locationCount","locationProtection","locationRegexp","maintenance","port","portal","vhostAlias","localConf","configStorage","localStorage","localStorageOptions","confAcc","Conf","getLocalConf","forEach","iniSection","Object","k","undefined","nodeVhosts","vhostList","reload","Promise","resolve","reject","ready","then","getConf","conf","_","vhostOptions","s","charAt","toUpperCase","vhost","val","sessionAcc","Session","storageModule","storageModuleOptions","e","locationRules","indexOf","SafeLib","rules","url","cond","prot","conditionSub","exportedHeaders","headers","sub","substitute","vm","runInContext","fg","aliases","alias","cookieDetect","cookieName","Logger","logger","userLogger","catch","console","error","ctx","OK","res","session","_logout","expr","init","run","req","next","host","setError","uri","isUnprotected","id","fetchId","retrieveSession","user","whatToTrace","debug","grant","grantResult","sendHeaders","hideCookie","info","forbidden","notice","goToPortal","selfUri","nginxServer","fcgiOpt","mode","ip","require","http","createServer","writeHead","listen","code","txt","useRedirectOnError","redirect","Location","status","send","resolveAlias","i","cookie","get","now","Date","_utime","timeout","timeoutActivity","_lastSeen","update","regex","rawHeaders","urlc","Buffer","from","encodeURI","LemonldapNGHandlerDevOps","super","lastVhostUpdate","base","cgiParams","RULES_URL","loopBackUrl","lvOpts","$1","$2","path","$4","$3","lb","loadVhostConfig","err","Host","request","resp","str","on","chunk","vhostConfig","JSON","parse","cipher","rule","String","valueOf","end","LemonldapNGHandlerServiceToken","token","HTTP_X_LLNG_TOKEN","tokenElement","decrypt","warn","tokenTime","parseInt","currentHandler","currentClass","knownHandlers","Main","DevOps","ServiceToken","ServiceTokenST","prototype","call","t","_interopNamespace","mod","default"],"mappings":"+pBAeA,MAAMA,EAAY,IAAIC,EAAAA,QAAI,6CAA8C,KAaxE,IAAIC,EAAM,EAEV,MAAMC,EAAiB,CACrB,MACA,mBACA,SACA,aACA,kBACA,WACA,gBACA,UACA,kBACA,qBACA,yBACA,cACA,eC1CF,MAGMC,EAAgB,CAACC,EAAMC,IAAYA,EAAQC,MAAKC,GAAUA,aAAkBC,OAASD,EAAOE,KAAKL,GAAQG,IAAWH,IAqD3G,SAASM,EAAaC,EAAWC,GAqB/C,GApBAA,EAAU,CACTC,gB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