有没有办法限制nodejs electron app只能访问某些网址
Is there any way to restrict nodejs electron app to access to only certain web addresses
我正在用电子创建一个内部应用程序。出于安全原因,我想确保意外信息不会上传到其他一些网址。
有没有办法在电子应用程序中做到这一点?
来自 Electron 文档:
https://electronjs.org/docs/tutorial/security#12-disable-or-limit-navigation
const URL = require('url').URL
app.on('web-contents-created', (event, contents) => {
contents.on('will-navigate', (event, navigationUrl) => {
const parsedUrl = new URL(navigationUrl)
if (parsedUrl.origin !== 'https://my-own-server.com') {
event.preventDefault()
}
})
})
除了限制导航之外,同一页面上还有多个推荐:
https://electronjs.org/docs/tutorial/security
您还可以使用这个很棒的资源:
https://www.blackhat.com/docs/us-17/thursday/us-17-Carettoni-Electronegativity-A-Study-Of-Electron-Security-wp.pdf
一些有趣的技术包括在会话中使用 setPermissionRequestHandler 来设置回调以防止打开外部链接。
我正在用电子创建一个内部应用程序。出于安全原因,我想确保意外信息不会上传到其他一些网址。
有没有办法在电子应用程序中做到这一点?
来自 Electron 文档:
https://electronjs.org/docs/tutorial/security#12-disable-or-limit-navigation
const URL = require('url').URL
app.on('web-contents-created', (event, contents) => {
contents.on('will-navigate', (event, navigationUrl) => {
const parsedUrl = new URL(navigationUrl)
if (parsedUrl.origin !== 'https://my-own-server.com') {
event.preventDefault()
}
})
})
除了限制导航之外,同一页面上还有多个推荐:
https://electronjs.org/docs/tutorial/security
您还可以使用这个很棒的资源: https://www.blackhat.com/docs/us-17/thursday/us-17-Carettoni-Electronegativity-A-Study-Of-Electron-Security-wp.pdf
一些有趣的技术包括在会话中使用 setPermissionRequestHandler 来设置回调以防止打开外部链接。