node-red-contrib-nec-baas
Version:
Node-RED nodes for NEC Mobile Backend Platform
221 lines (197 loc) • 9.56 kB
HTML
<!--
Copyright 2013, 2016 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.
-->
<!--
NEC Mobile Backend Platform
Copyright (c) 2014-2017 NEC Corporation
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/x-red" data-template-name="auth">
<div class="form-row">
<label for="node-input-initFlag"><i class="fa fa-check"></i> <span data-i18n="nebula.label.initialize"></span></label>
<input type="checkbox" id="node-input-initFlag" style="width: auto;">
</div>
<div class="form-row node-input-nebulaServer">
<label for="node-input-nebulaServer"><i class="fa fa-tag"></i> <span data-i18n="nebula.label.config"></span></label>
<input type="text" id="node-input-nebulaServer">
</div>
<div class="form-row">
<label for="node-input-action"><i class="fa fa-wrench"></i> <span data-i18n="nebula.label.action"></span></label>
<select type="text" id="node-input-action" style="width: auto;">
<option value="LOGIN" data-i18n="nebula.label.login"></option>
<option value="LOGOUT" data-i18n="nebula.label.logout"></option>
<option value="USE_CLIENT_CERT" data-i18n="nebula.label.use-client-cert"></option>
</select>
</div>
<div class="form-row node-input-userInfo">
<div class="form-row">
<label for="node-input-email"><i class="fa fa-envelope"></i> <span data-i18n="nebula.label.email"></span></label>
<input type="text" id="node-input-email">
</div>
<div class="form-row">
<label for="node-input-userName"><i class="fa fa-user"></i> <span data-i18n="nebula.label.user"></span></label>
<input type="text" id="node-input-userName">
</div>
<div class="form-row">
<label for="node-input-password"><i class="fa fa-lock"></i> <span data-i18n="nebula.label.password"></span></label>
<input type="password" id="node-input-password">
</div>
</div>
<div class="form-row node-input-certType">
<hr align="middle"></hr>
<label><i class="fa fa-file"></i> <span data-i18n="nebula.label.certificate"></span></label>
<label><i class="fa fa-check"></i> <span data-i18n="nebula.label.cert-type"></span></label>
<input type="checkbox" id="node-input-pfxType" style="width: auto;"> <span data-i18n="nebula.label.pfx-type"></span>  
<input type="checkbox" id="node-input-pemType" style="width: auto;"> <span data-i18n="nebula.label.pem-type"></span>  
</div>
<div class="form-row node-input-pfxCert">
<label></label>
<label> <span data-i18n="nebula.label.pfx-cert"></span></label>
<input type="text" id="node-input-pfxCertPath" style="width: auto;" data-i18n="[placeholder]nebula.placeholder.pfx-cert-path">
<div style="margin-bottom:10px;"></div>
<label></label>
<label> <span data-i18n="nebula.label.pass-phrase"></span></label>
<input type="text" id="node-input-passPhrase" style="width: auto;">
<div style="margin-bottom:10px;"></div>
</div>
<div class="form-row node-input-pemCert">
<label></label>
<label> <span data-i18n="nebula.label.pem-cert"></span></label>
<input type="text" id="node-input-pemCertPath" style="width: auto;" data-i18n="[placeholder]nebula.placeholder.pem-cert-path">
<div style="margin-bottom:10px;"></div>
<label></label>
<label> <span data-i18n="nebula.label.pem-key"></span></label>
<input type="text" id="node-input-pemKeyPath" style="width: auto;" data-i18n="[placeholder]nebula.placeholder.pem-key-path">
<div style="margin-bottom:10px;"></div>
</div>
<div class="form-row node-input-caCert">
<!-- <hr align="middle"></hr> -->
<label><i class="fa fa-file"></i> <span data-i18n="nebula.label.ca-cert"></span></label>
<label> <span data-i18n="nebula.label.filename"></span></label>
<input type="text" id="node-input-caCertPath" style="width: auto;" data-i18n="[placeholder]nebula.placeholder.ca-cert-path">
<div style="margin-bottom:10px;"></div>
<hr align="middle"></hr>
</div>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="nebula.label.name"></span></label>
<input type="text" id="node-input-name" data-i18n="[placeholder]nebula.placeholder.name">
</div>
<!-- <div class="form-tips"><span data-i18n="nebula.tip"></span></div> -->
<script>
$("#node-input-initFlag").change(function() {
if ($("#node-input-initFlag").prop("checked")) {
$(".node-input-nebulaServer").show();
} else {
$(".node-input-nebulaServer").hide();
}
});
$("#node-input-action").change(function() {
var action = $("#node-input-action").val();
if (action === "LOGIN") {
$(".node-input-userInfo").show();
uncheckCertType();
hideCertItems();
} else if (action === "LOGOUT") {
$(".node-input-userInfo").hide();
uncheckCertType();
hideCertItems();
} else { // USE_CLIENT_CERT
$(".node-input-userInfo").hide();
$(".node-input-certType").show();
$(".node-input-caCert").show();
}
});
function uncheckCertType() {
$("#node-input-pemType").prop("checked", false);
$("#node-input-pfxType").prop("checked", false);
}
function hideCertItems() {
$(".node-input-certType").hide();
$(".node-input-pfxCert").hide();
$(".node-input-pemCert").hide();
$(".node-input-caCert").hide();
}
$("#node-input-pfxType").change(function() {
if ($("#node-input-pfxType").prop("checked")) {
$("#node-input-pemType").prop("checked", false);
$(".node-input-pemCert").hide();
$(".node-input-pfxCert").show();
$(".node-input-caCert").show();
} else {
$(".node-input-pfxCert").hide();
}
});
$("#node-input-pemType").change(function() {
if ($("#node-input-pemType").prop("checked")) {
$("#node-input-pfxType").prop("checked", false);
$(".node-input-pemCert").show();
$(".node-input-pfxCert").hide();
$(".node-input-caCert").show();
} else {
$(".node-input-pemCert").hide();
}
});
</script>
</script>
<script type="text/x-red" data-help-name="auth">
<p>A function that authenticates to the NEC BaaS Server.</p>
<h4>Incomming messages</h4>
<p>Set the email (or username) and password in the edit dialog. If left blank it should be set
by <code>msg.email</code>,<code>msg.username</code>,<code>msg.password</code> on the incoming message.</p>
<h4>Sending messages</h4>
<p>The function returns the messages<code>msg.result</code>,<code>msg.payload</code> to pass on to the next nodes
in the flow.</p>
<code>msg.payload</code> contains logged-in user info.
<h4>Client certificate authentication</h4>
<p>Select the 'Use client certificate' and set the client certificate in the edit dialog. In that case, no email and password are required.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('auth', {
color:"#c0deed", //"#fdd0a2",
category: 'nec baas',
defaults: {
initFlag: {value: false},
name: {value:"auth"},
nebulaServer: {value: "", type: 'nebula-server', required:false},
action: {value: "LOGIN"},
pfxType: {value: false},
pemType: {value: false},
pfxCertPath: {value:""},
passPhrase: {value:""},
pemCertPath: {value:""},
pemKeyPath: {value:""},
caCertPath: {value:""}
},
credentials: {
email: {type:"text"},
userName: {type:"text"},
password: {type:"password"}
},
inputs:1,
outputs:1,
icon: "arrow-out.png",
align: 'right',
label: function() {
return this.name;
},
oneditsave: function() {
}
});
</script>