-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path99-ldap.html
166 lines (157 loc) · 6.66 KB
/
99-ldap.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<!--
Copyright 2013,2014 IBM Corp.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<script type="text/html" data-template-name="ldap">
<div class="form-row node-input-server">
<label for="node-config-input-server"><i class="fa fa-globe"> Server</i></label>
<input class="input-append-left" type="text" id="node-config-input-server" placeholder="localhost" style="width: 40%;" >
<label for="node-config-input-port" style="margin-left: 10px; width: 35px; "> Port</label>
<input type="text" id="node-config-input-port" placeholder="Port" style="width:45px">
</div>
<div class="form-row">
<label for="node-config-input-tls" style="margin-left: 22%; width: 60px"><i> Use TLS</i></label>
<input id="node-config-input-tls" style="width: 20px" type="checkbox">
</div>
<div class="form-row" hidden="hidden">
<label for="node-config-input-tlsCert"><i class="fa fa-lock"> Path to TLS cert file (.pem)</i></label>
<input type="text" id="node-config-input-tlsCert">
</div>
<div class="form-row" id="ldap-config-tls" hidden="hidden">
<label style="width: auto; margin-right: 10px;" for="node-config-input-tlsConfig"><i class="fa fa-lock"> TLS Config</i></label>
<input type="text" style="width: 300px" id="node-config-input-tlsConfig">
</div>
<div class="form-row">
<label for="node-config-input-binddn"><i class="fa fa-user"> Bind DN</i></label>
<input type="text" id="node-config-input-binddn">
</div>
<div class="form-row">
<label for="node-config-input-password"><i class="fa fa-lock"> Password</i></label>
<input type="password" id="node-config-input-password">
</div>
<div class="form-row">
<label for="node-config-input-name"><i class="fa fa-tag"> Name</i></label>
<input type="text" id="node-config-input-name">
</div>
</script>
<script type="text/html" data-help-name="ldap">
<p>LDAP Server node</p>
<p>Takes a hostname and port, along with the an optional TLS configuration.</p>
<p>Also optional Bind DN and password if needed to authenticate with the server.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('ldap',{
category: 'config',
defaults: {
server: {value:"localhost", required:true},
port: {value:389,required:true,validate:RED.validators.number()},
tls: {value: false},
tlsCert: {value: ''},
tlsConfig: { type:"tls-config",required: false},
name: {required:false}
},
credentials: {
binddn: {type:"text"},
password: {type: "password"}
},
label: function() {
let protocol = "ldap://"
let p = "";
if (this.tls) {
protocol = "ldaps://"
if (this.port != 636) {
p = ":" + this.port
} else {
p = ""
}
} else {
if (this.port != 389) {
p = ":"+ this.port
}
}
return this.name||protocol + this.server + p;
},
oneditprepare: function() {
$("#node-config-input-tls").change(function() {
var port = $("#node-config-input-port").val();
var tls = $("#node-config-input-tls").is(':checked');
if (tls === true) {
if ($("#node-config-input-tlsCert").val()) {
$("#node-config-input-tlsCert").parent().removeAttr('hidden');
} else {
$("#ldap-config-tls").removeAttr('hidden');
}
if (port == 389) {
$("#node-config-input-port").val(636);
}
} else {
$("#node-config-input-tlsCert").parent().attr('hidden', 'true');
$("#ldap-config-tls").attr('hidden', 'true');
if (port == 636) {
$("#node-config-input-port").val(389);
}
}
});
}
});
</script>
<script type="text/html" data-template-name="ldap out">
<div class="form-row">
<label for="node-input-server"><i class="fa fa-globe"></i> Server</label>
<input type="text" id="node-input-server">
</div>
<div class="form-row">
<label for="node-input-base"><i class="fa fa-tasks"></i> Base DN</label>
<input type="text" id="node-input-base" placeholder="Base DN">
</div>
<div class="form-row">
<label for="node-input-filter"><i class="fa fa-tasks"></i> Filter</label>
<input type="text" id="node-input-filter" placeholder="Filter">
</div>
<div class="form-row">
<label for="node-input-topic"><i class="fa fa-tasks"></i> Topic</label>
<input type="text" id="node-input-topic" placeholder="Topic">
</div>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
</script>
<script type="text/html" data-help-name="ldap out">
<p>LDAP Search node</p>
<p>Filter is a mustache capable field e.g. <i>mail={{payload.email}}</i> will take the email field from the msg.payload and insert it in the correct place</p>
<p>The node returns an array of objects that represent matching records in the LDAP</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('ldap out',{
category: 'storage-output',
defaults: {
name: {value:""},
topic: {value:""},
base: {value:""},
filter: {value:""},
server: {type:"ldap", required:true}
},
color: "rgb(218, 196, 180)",
inputs:1,
outputs:1,
icon: "watch.png",
label: function() {
var server = RED.nodes.node(this.server)
server.label()
return this.name||(server?server.label():"ldap search");
},
labelStyle: function() {
return this.name?"node_label_italic":"";
},
paletteLabel: "ldap Search"
});
</script>