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L,EAAQ,CAAE,SAAU,EAAU,YAAa,MAC3C,EAAK,SAKP,GACD,IACA,EAAI,GAAG,OAAO,SAAS,GACjB,IACJ,EAAQ,MACR,EAAK,SAEP,IAEF,GACD,GACD,EACA,QAAS,WACF,OAAO,KAAK,SAAQ,SAAS,GAGzB,EAAQ,KACZ,GACJ","file":"/npm/node-red-contrib-ldap-auth1@0.0.3/node-red-contrib-ldap-auth.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/node-red-contrib-ldap-auth1@0.0.3/node-red-contrib-ldap-auth.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/**\n * Copyright 2015 IBM Corp.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n **/\nvar when = require(\"when\");\nvar mustache = require(\"mustache\");\nvar ldapjs = require(\"ldapjs\");\n\n\nvar filterTemplate = '';\n\nvar options = {\n};\n\nvar searchOpts = {\n\tscope: 'sub',\n\tsizeLimit: 1\n};\n\nmodule.exports = {\n\tsetup: function(args) {\n\t\toptions.url = args.uri;\n\t\tsearchOpts.base = args.base;\n\t\tfilterTemplate = args.filterTemplate;\n\n\t\treturn this;\n\t},\n\ttype: \"credentials\",\n\tusers: function(username) {\n\t\treturn when.promise(function(resolve) {\n\t\t\tvar ldap = ldapjs.createClient(options);\n\t\t\tvar temp = {};\n\t\t\ttemp.username = username;\n\t\t\tsearchOpts.filter = mustache.render(filterTemplate, temp);\n\t\t\tldap.search(searchOpts.base,searchOpts,function(err, res){\n\t\t\t\tvar found = false;\n\t\t\t\tif (err) {\n\t\t\t\t\tconsole.log(err);\n\t\t\t\t\tresolve(null);\n\t\t\t\t\tldap.unbind();\n\t\t\t\t} else {\n\t\t\t\t\tres.on('searchEntry', function(entry){\n\t\t\t\t\t\tfound = true;\n\t\t\t\t\t\tresolve({ username: username, permissions: \"*\" });\n\t\t\t\t\t\tldap.unbind();\n\t\t\t\t\t});\n\t\t\t\t\tres.on('end', function(status) {\n\t\t\t\t\t\tif (!found) {\n\t\t\t\t\t\t\tresolve(null);\n\t\t\t\t\t\t\tldap.unbind();\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\t\n\t\t\t});\n\t\t});\n\t},\n\tauthenticate: function(username, password) {\n\t\treturn when.promise(function(resolve) {\n\t\t\tvar ldap = ldapjs.createClient(options);\n\t\t\tvar temp = {};\n\t\t\ttemp.username = username;\n\t\t\tsearchOpts.filter = mustache.render(filterTemplate, temp);\n\t\t\tldap.search(searchOpts.base,searchOpts,function(err, res){\n\t\t\t\tvar found = false;\n\t\t\t\tif (err) {\n\t\t\t\t\tconsole.log(err);\n\t\t\t\t\tresolve(null);\n\t\t\t\t\tldap.unbind();\n\t\t\t\t} else {\n\t\t\t\t\tres.on('searchEntry', function(entry){\n\t\t\t\t\t\tfound = true;\n\t\t\t\t\t\tldap.bind(entry.dn, password, function(err){\n\t\t\t\t\t\t\tif (!err) {\n\t\t\t\t\t\t\t\tresolve({ username: username, permissions: \"*\" });\n\t\t\t\t\t\t\t\tldap.unbind();\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tresolve(null);\n\t\t\t\t\t\t\t\tldap.unbind();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t\tres.on('end', function(status){\n\t\t\t\t\t\tif (!found) {\n\t\t\t\t\t\t\tresolve(null);\n\t\t\t\t\t\t\tldap.unbind();\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t},\n\tdefault: function() {\n        return when.promise(function(resolve) {\n            // Resolve with the user object for the default user.\n            // If no default user exists, resolve with null.\n            resolve(null);\n        });\n    }\n};"]}