@sammachin/node-red-dragonpbx
Version:
A Node-RED node to append JSON objects to an array in msg.callScript
121 lines (113 loc) • 4.8 kB
HTML
<!-- Javascript -->
<script type="text/javascript">
var mustacheType = {
value: 'mustache',
label: 'mustache',
hasvalue: true
}
RED.nodes.registerType('dragonpbx_auth',{
category: 'function',
color:"#E0E0EE",
defaults: {
name: {value: ''},
password: {},
passwordType: {},
ha1: {},
ha1Type: {},
expires: {value: ''},
expiresType: {},
codecs: {value: ''},
codecsType: {},
dialplan: {value: ''},
dialplanType: {},
},
inputs:1,
outputs:1,
icon: "font-awesome/fa-id-badge",
label: function() { return this.name || 'auth';},
paletteLabel: "auth",
oneditprepare: function() {
$('#node-input-password').typedInput({
types: ['str', 'msg', 'flow', 'global', 'jsonata', 'env', mustacheType],
typeField: $('#node-input-passwordType')
});
$('#node-input-ha1').typedInput({
types: ['str', 'msg', 'flow', 'global', 'jsonata', 'env', mustacheType],
typeField: $('#node-input-ha1Type')
});
$('#node-input-expires').typedInput({
types: ['str', 'msg', 'flow', 'global', 'jsonata', 'env', mustacheType],
typeField: $('#node-input-expiresType')
});
$('#node-input-codecs').typedInput({
types: ['str', 'msg', 'flow', 'global', 'jsonata', 'env', mustacheType],
typeField: $('#node-input-codecsType')
});
$('#node-input-dialplan').typedInput({
types: ['json', 'msg', 'flow', 'global', 'jsonata', 'env', mustacheType],
typeField: $('#node-input-directUserType')
});
$('#node-input-dialplanApp').typedInput({
types: ['json', 'msg', 'flow', 'global', 'jsonata', 'env', mustacheType],
typeField: $('#node-input-directAppType')
});
}
});
</script>
<script type="text/html" data-template-name="dragonpbx_auth">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<fieldset>
<legend>Enter either a plain-text or hashed password</legend>
<div class="form-row">
<label for="node-input-password">Plain text password</label>
<input type="text" id="node-input-password">
<input type="hidden" id="node-input-passwordType">
</div>
<div class="form-row">
<label for="node-input-ha1">Hashed</label>
<input type="text" id="node-input-ha1">
<input type="hidden" id="node-input-ha1Type">
</div>
<div class="form-row">
<label for="node-input-expires">Expires</label>
<input type="text" id="node-input-expires">
<input type="hidden" id="node-input-expiresType">
</div>
<div class="form-row">
<label for="node-input-codecs">Supported Codecs</label>
<input type="text" id="node-input-codecs">
<input type="hidden" id="node-input-codecsType">
</div>
<div class="form-row">
<label for="node-input-dialplan">Dialplan</label>
<input type="text" id="node-input-dialplan">
<input type="hidden" id="node-input-dialplanType">
</div>
</fieldset>
</script>
<!-- Help Text -->
<!-- User Text -->
<script type="text/html" data-help-name="dragonpbx_auth">
<p>Authenticate a user</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>authRequest<span class="property-type">object</span></dt>
<dd>The digest parameters provided by the user</dd>
</dl>
<h3>Outputs</h3>
<dl class="message-properties">
<dt>authRequest<span class="property-type">object</span></dt>
<dd>The digest parameters provided by the user</dd>
<dt>authResponse<span class="property-type">object</span></dt>
<dd>An object containing a status property indicating whether the password provided has successfully authenticated the user</dd>
</dl>
<h3>Details</h3>
The user auth command is used to authenticate a user based on the sip digest they presented and a password retrieved by some means by the application.
You may provide either a plaintext password, or a precomputed hash based on <a href="https://tools.ietf.org/html/rfc2617">RFC 2617</a>, i.e. MD5( username ":" realm ":" password ).<br/><br/>
It is valid to provide neither the plaintext nor hashed password, and in this case the user authentication will fail.
It is useful to do this, for instance, when either the presented domain or username are unrecognized.<br/><br/>
The output of this node is to set <code>msg.authResponse</code> accordingly, and the <code>webhook out</code> node should then be used to send the result back to the server.
</script>