From: liwei Date: Mon, 11 Nov 2019 10:24:41 +0000 (+0800) Subject: [VD] When login in proxy server, check usrname/passwd from vconf X-Git-Tag: accepted/tizen/5.5/unified/20191122.012336~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a71eef43bdd98042a0a11691c95461e6b4908a3a;p=platform%2Fframework%2Fweb%2Fwrtjs.git [VD] When login in proxy server, check usrname/passwd from vconf For TV product, when login in proxy server, get usrname/passwd from vconf(memory/dnet/proxy), if usrname/passwd exist, login proxy server automatically, popup will not be shown anymore. Vconf format: http://ubuntu:123456@109.123.100.175:8899 Native Patch: https://review.tizen.org/gerrit/217425 Change-Id: I042f9f2f8fbe678065a6b76a9e943dfbf7b4db62 Signed-off-by: liwei --- diff --git a/wrt_app/src/web_application.js b/wrt_app/src/web_application.js old mode 100755 new mode 100644 index 3afba33..5c848b3 --- a/wrt_app/src/web_application.js +++ b/wrt_app/src/web_application.js @@ -117,12 +117,26 @@ class WebApplication { } }); app.on('login', function(event, webContents, request, authInfo, callback) { - console.log('Login info is required'); + console.log(`Login info is required, isproxy: ${authInfo.isProxy}`); event.preventDefault(); - const id = ++self.pendingID; - console.log(`Raising a login info request with id: ${id}`); - self.pendingCallbacks.set(id, callback); - wrt.handleAuthRequest(id, webContents); + let usrname = ''; + let passwd = ''; + if (self.isTVProfile && authInfo.isProxy) { + let vconfProxy = wrt.getProxy(); + if (vconfProxy) { + let proxyInfo = new URL(vconfProxy); + usrname = proxyInfo.username; + passwd = proxyInfo.password; + } + } + if (usrname && passwd) { + callback(usrname, passwd); + } else { + const id = ++self.pendingID; + console.log(`Raising a login info request with id: ${id}`); + self.pendingCallbacks.set(id, callback); + wrt.handleAuthRequest(id, webContents); + } }); if (this.isTVProfile) { // TODO. This logic in only for QA verification @@ -141,25 +155,28 @@ class WebApplication { }); } if (this.accessiblePath) { - console.log('accessiblePath : ' + this.accessiblePath); + console.log(`accessiblePath: ${this.accessiblePath}`); protocol.interceptFileProtocol('file', (request, callback) => { - const url = require('url'); - let access_path, parsed_info = url.parse(request.url); - access_path = parsed_info.host + parsed_info.pathname; - console.log("check path: " + access_path); - - for (let p in self.accessiblePath) { - if (access_path.startsWith(self.accessiblePath[p])) { + if (request.url) { + let access_path, parsed_info = new URL(request.url); + access_path = parsed_info.host + parsed_info.pathname; + console.log(`check path: : ${access_path}`); + for (let p in self.accessiblePath) { + if (access_path.startsWith(self.accessiblePath[p])) { + callback(access_path); + return; + } + } + if (access_path.indexOf("/shared/res/") > -1) { callback(access_path); return; } - } - if (access_path.indexOf("/shared/res/") > -1) { - callback(access_path); - return; - } - else { - console.log("invalid access: " + access_path); + else { + console.log(`invalid accesspath: ${access_path}`); + callback(403); + } + } else { + console.log('request url is empty'); callback(403); } }, (error) => {