diff options
| author | Pliable Pixels <pliablepixels@gmail.com> | 2018-04-18 09:44:08 -0400 |
|---|---|---|
| committer | Pliable Pixels <pliablepixels@gmail.com> | 2018-04-18 09:44:08 -0400 |
| commit | 36e20e38dd557381ad4a42cdc1053cc2d7e92cd9 (patch) | |
| tree | be2cf7116a571b7f80e8d9253795fb0ef0e505ba /www/js | |
| parent | 634fee8d84d60dea9593e4f5095ed91e84712ef0 (diff) | |
#613 move basic auth to its own setting
Diffstat (limited to 'www/js')
| -rwxr-xr-x | www/js/DataModel.js | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/www/js/DataModel.js b/www/js/DataModel.js index a7badad8..05daf5f0 100755 --- a/www/js/DataModel.js +++ b/www/js/DataModel.js @@ -109,6 +109,9 @@ angular.module('zmApp.controllers') 'useSSL': false, // "1" if HTTPS --> not used #589 'keepAwake': true, // don't dim/dim during live view 'isUseAuth': true, // true if user wants ZM auth + 'isUseBasicAuth': false, + 'basicAuthUser': '', + 'basicAuthPassword': '', 'isUseEventServer': false, // true if you configure the websocket event server 'disablePush': false, // true if only websocket mode is desired 'eventServerMonitors': '', // list of monitors to notify from ES @@ -772,6 +775,52 @@ angular.module('zmApp.controllers') loginData.persistMontageOrder = true; loginData.enableh264 = true; + if (typeof loginData.isUseBasicAuth === 'undefined') { + loginData.isUseBasicAuth = false; + loginData.basicAuthUser = ''; + loginData.basicAuthPassword = ''; + $rootScope.basicAuthHeader=''; + } + + if (loginData.url.indexOf('@') != -1) { + log (">> "+loginData.url); + log (">>User/Password detected in URL, changing to new auth handling..."); + loginData.isUseBasicAuth = true; + + var components = URI.parse(loginData.url); + loginData.url = components.scheme + "://" + components.host; + if (components.port) loginData.url = loginData.url + ":" + components.port; + if (components.path) loginData.url = loginData.url + components.path; + + components = URI.parse(loginData.streamingurl); + loginData.streamingurl = components.scheme + "://" + components.host; + if (components.port) loginData.streamingurl = loginData.streamingurl + ":" + components.port; + if (components.path) loginData.streamingurl = loginData.streamingurl + components.path; + + + components = URI.parse(loginData.apiurl); + loginData.apiurl = components.scheme + "://" + components.host; + if (components.port) loginData.apiurl = loginData.apiurl + ":" + components.port; + if (components.path) loginData.apiurl = loginData.apiurl + components.path; + + $rootScope.basicAuthHeader = 'Basic ' + btoa(components.userinfo); + //console.log (">>>> SET BASIC AUTH TO " + $rootScope.basicAuthHeader); + + var up = components.userinfo.split(':'); + loginData.basicAuthPassword = up[1]; + loginData.basicAuthUser = up[0]; + console.log ("SETTING "+loginData.basicAuthUser+" "+loginData.basicAuthPassword); + + } + + if (loginData.isUseBasicAuth) { + $rootScope.basicAuthHeader = 'Basic ' + btoa(loginData.basicAuthUser+':'+loginData.basicAuthPassword); + + console.log ("BASIC AUTH SET TO:"+$rootScope.basicAuthHeader); + + } + + if (typeof loginData.enableAlarmCount === 'undefined') { debug("enableAlarmCount does not exist, setting to true"); loginData.enableAlarmCount = true; |
