added checkbox to accept self signed server certificates to credentials
added support for self signed certificates to WebDAV nodes (needs [webdav](https://github.com/perry-mitchell/webdav-client) package to be updated to 1.5.3 or newer)
This commit is contained in:
@ -1,5 +1,11 @@
|
|||||||
# node-red-contrib-nextcloud changelog
|
# node-red-contrib-nextcloud changelog
|
||||||
|
|
||||||
|
## 0.1.1
|
||||||
|
_2018-05-xx_ (work in progress)
|
||||||
|
* added checkbox to accept self signed server certificates to credentials
|
||||||
|
* added support for self signed certificates to WebDAV nodes (needs [webdav](https://github.com/perry-mitchell/webdav-client) package to be updated to 1.5.3 or newer)
|
||||||
|
* removed debug output in node WebDAV list
|
||||||
|
|
||||||
## 0.1.0
|
## 0.1.0
|
||||||
_2018-04-30_
|
_2018-04-30_
|
||||||
* addad missing option to set directory in incoming message for WebDAV list
|
* addad missing option to set directory in incoming message for WebDAV list
|
||||||
@ -14,4 +20,5 @@ _2018-04-29_
|
|||||||
* WebDAV Nodes
|
* WebDAV Nodes
|
||||||
* List directory entries
|
* List directory entries
|
||||||
* upload file to nextcloud server
|
* upload file to nextcloud server
|
||||||
* download file to nextcloud server
|
* download file to nextcloud server
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,8 @@
|
|||||||
category: 'config',
|
category: 'config',
|
||||||
defaults: {
|
defaults: {
|
||||||
cname: {value: '', required: false},
|
cname: {value: '', required: false},
|
||||||
address: {value: 'https://your.server.com', required: true}
|
address: {value: 'https://your.server.com', required: true},
|
||||||
|
insecure: {value: '', required: false}
|
||||||
},
|
},
|
||||||
credentials: {
|
credentials: {
|
||||||
user: {type:'text'},
|
user: {type:'text'},
|
||||||
@ -27,6 +28,12 @@
|
|||||||
<label for="node-config-input-address"><i class="fa fa-server"></i> Server</label>
|
<label for="node-config-input-address"><i class="fa fa-server"></i> Server</label>
|
||||||
<input type="text" id="node-config-input-address">
|
<input type="text" id="node-config-input-address">
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-row">
|
||||||
|
<label for="node-config-input-insecure"><i class="fa fa-server"></i> Security</label>
|
||||||
|
<input type="checkbox" value="1" id="node-config-input-insecure"
|
||||||
|
style="display: inline-block; width: auto; vertical-align: top">
|
||||||
|
<span style="width: 70%">Accept self signed certificates</span>
|
||||||
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-config-input-user"><i class="fa fa-server"></i> Username</label>
|
<label for="node-config-input-user"><i class="fa fa-server"></i> Username</label>
|
||||||
<input type="text" id="node-config-input-user">
|
<input type="text" id="node-config-input-user">
|
||||||
|
|||||||
26
nextcloud.js
26
nextcloud.js
@ -6,6 +6,7 @@ module.exports = function(RED) {
|
|||||||
function NextcloudConfigNode(n) {
|
function NextcloudConfigNode(n) {
|
||||||
RED.nodes.createNode(this, n)
|
RED.nodes.createNode(this, n)
|
||||||
this.address = n.address
|
this.address = n.address
|
||||||
|
this.insecure = n.insecure
|
||||||
}
|
}
|
||||||
RED.nodes.registerType('nextcloud-credentials', NextcloudConfigNode, {
|
RED.nodes.registerType('nextcloud-credentials', NextcloudConfigNode, {
|
||||||
credentials: {
|
credentials: {
|
||||||
@ -140,9 +141,13 @@ module.exports = function(RED) {
|
|||||||
} else if (node.directory && node.directory.length) {
|
} else if (node.directory && node.directory.length) {
|
||||||
directory = '/' + node.directory
|
directory = '/' + node.directory
|
||||||
}
|
}
|
||||||
|
// check option for self signed certs
|
||||||
|
const option = {}
|
||||||
|
if (node.server.insecure) {
|
||||||
|
option.agent = new https.Agent({ rejectUnauthorized: false })
|
||||||
|
}
|
||||||
directory = directory.replace('//', '/')
|
directory = directory.replace('//', '/')
|
||||||
|
client.getDirectoryContents(directory, option)
|
||||||
client.getDirectoryContents(directory)
|
|
||||||
.then(function (contents) {
|
.then(function (contents) {
|
||||||
node.send({'payload': contents})
|
node.send({'payload': contents})
|
||||||
}, function (error) {
|
}, function (error) {
|
||||||
@ -172,8 +177,12 @@ module.exports = function(RED) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
filename = filename.replace('//', '/')
|
filename = filename.replace('//', '/')
|
||||||
|
// check option for self signed certs
|
||||||
client.getFileContents(filename)
|
const option = {}
|
||||||
|
if (node.server.insecure) {
|
||||||
|
option.agent = new https.Agent({ rejectUnauthorized: false })
|
||||||
|
}
|
||||||
|
client.getFileContents(filename, option)
|
||||||
.then(function (contents) {
|
.then(function (contents) {
|
||||||
node.send({'payload': contents})
|
node.send({'payload': contents})
|
||||||
}, function (error) {
|
}, function (error) {
|
||||||
@ -207,11 +216,14 @@ module.exports = function(RED) {
|
|||||||
directory += node.directory + '/'
|
directory += node.directory + '/'
|
||||||
}
|
}
|
||||||
directory = directory.replace('//', '/')
|
directory = directory.replace('//', '/')
|
||||||
|
|
||||||
const webDavUri = node.server.address + '/remote.php/webdav/'
|
const webDavUri = node.server.address + '/remote.php/webdav/'
|
||||||
const client = webdav(webDavUri, node.server.credentials.user, node.server.credentials.pass)
|
const client = webdav(webDavUri, node.server.credentials.user, node.server.credentials.pass)
|
||||||
|
// check option for self signed certs
|
||||||
client.putFileContents(directory + name, file, { format: 'binary' })
|
const option = {}
|
||||||
|
if (node.server.insecure) {
|
||||||
|
option.agent = new https.Agent({ rejectUnauthorized: false })
|
||||||
|
}
|
||||||
|
client.putFileContents(directory + name, file, { format: 'binary' }, option)
|
||||||
.then(function(contents) {
|
.then(function(contents) {
|
||||||
console.log(contents)
|
console.log(contents)
|
||||||
node.send({'payload': JSON.parse(contents)})
|
node.send({'payload': JSON.parse(contents)})
|
||||||
|
|||||||
Reference in New Issue
Block a user