Skip to content
This repository has been archived by the owner on May 17, 2024. It is now read-only.

feat: performing specific preprocess operation to specific endpoint #10

Merged
merged 3 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"editor.formatOnSave": true,
"javascript.preferences.quoteStyle": "auto",
"prettier.singleQuote": true
"editor.tabSize": 2,
}
24 changes: 13 additions & 11 deletions functions/ldap.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,23 @@ const Qs = require('qs');
exports.plugin = {
name: 'ldap',
register: async function (server) {
server.ext('onRequest', (request, h) => {
let { tlsOptions, attributes } = request.query;
server.ext('onPostAuth', (request, h) => {
if (request.path === '/ldap/search') {
let { tlsOptions, attributes } = request.query;

if (tlsOptions) {
tlsOptions = Qs.parse(tlsOptions, {
delimiter: /[;,]/,
});
if (tlsOptions) {
tlsOptions = Qs.parse(tlsOptions, {
delimiter: /[;,]/,
});

request.query.tlsOptions = tlsOptions;
}
request.query.tlsOptions = tlsOptions;
}

if (attributes && !Array.isArray(attributes)) {
attributes = [attributes];
if (attributes && !Array.isArray(attributes)) {
attributes = [attributes];

request.query.attributes = attributes;
request.query.attributes = attributes;
}
}

return h.continue;
Expand Down
Loading