Merge branch 'force-vpn' into 'master'

Add always on VPN policy

See merge request entgra/carbon-device-mgt-plugins!41
revert-dabc3590
Inosh Perara 6 years ago
commit fcd69d6ec4

@ -418,7 +418,8 @@ var generatePayload = function (operationCode, operationData, deviceList) {
payload = { payload = {
"operation": { "operation": {
"type": operationData["type"], "type": operationData["type"],
"openvpn_config": operationData["openvpn_config"] "openvpn_config": operationData["openvpn_config"],
"packageName": operationData["packageName"]
} }
}; };
break; break;

@ -167,7 +167,8 @@ var androidOperationModule = function () {
case androidOperationConstants["VPN_OPERATION_CODE"]: case androidOperationConstants["VPN_OPERATION_CODE"]:
payload = { payload = {
"type": operationPayload["type"], "type": operationPayload["type"],
"openvpn_config": operationPayload["openvpn_config"] "openvpn_config": operationPayload["openvpn_config"],
"packageName": operationPayload["packageName"]
}; };
break; break;
case androidOperationConstants["APPLICATION_OPERATION_CODE"]: case androidOperationConstants["APPLICATION_OPERATION_CODE"]:
@ -425,7 +426,8 @@ var androidOperationModule = function () {
payload = { payload = {
"operation": { "operation": {
"type": operationData["type"], "type": operationData["type"],
"openvpn_config": operationData["openvpn_config"] "openvpn_config": operationData["openvpn_config"],
"packageName": operationData["packageName"]
} }
}; };
break; break;
@ -1213,4 +1215,4 @@ var androidOperationModule = function () {
}; };
return publicMethods; return publicMethods;
}(); }();

@ -590,14 +590,34 @@ var validatePolicyProfile = function () {
// initializing continueToCheckNextInputs to true // initializing continueToCheckNextInputs to true
continueToCheckNextInputs = true; continueToCheckNextInputs = true;
var openvpnConfig = $("#openvpn-config").val(); let openVpnConfigEnabled = document.getElementById('vpn-body').classList.contains('in');
if (!openvpnConfig || openvpnConfig === '') { if (openVpnConfigEnabled) {
validationStatus = { var openvpnConfig = $("textarea#openvpn-config").val();
"error": true, if (!openvpnConfig || openvpnConfig === '') {
"subErrorMsg": "ovpn config required. You cannot proceed.", validationStatus = {
"erroneousFeature": operation "error": true,
}; "subErrorMsg": "ovpn config file is required. You cannot proceed.",
continueToCheckNextInputs = false; "erroneousFeature": operation
};
continueToCheckNextInputs = false;
}
}
if (validationStatus) {
validationStatusArray.push(validationStatus);
}
let alwaysOnVpnEnabled = document.getElementById('always-on-vpn-body').classList.contains('in');
if (alwaysOnVpnEnabled) {
var alwaysOnConfig = $("input#vpn-client-app").val();
if (!alwaysOnConfig || alwaysOnConfig === '') {
validationStatus = {
"error": true,
"subErrorMsg": "Add a valid package name for the VPN client",
"erroneousFeature": "always-on-vpn"
};
continueToCheckNextInputs = false;
}
} }
// at-last, if the value of continueToCheckNextInputs is still true // at-last, if the value of continueToCheckNextInputs is still true
@ -1317,4 +1337,4 @@ $(document).ready(function () {
$(this).removeClass("child-input"); $(this).removeClass("child-input");
}); });
}); });
}); });

@ -1246,6 +1246,62 @@
<input id="vpn-type" class="form-control operationDataKeys" type="hidden" data-key="type" value="OpenVPN" /> <input id="vpn-type" class="form-control operationDataKeys" type="hidden" data-key="type" value="OpenVPN" />
</div> </div>
</div> </div>
<!-- Always on VPN connection settings -->
<div id="always-on-vpn-heading" class="panel-heading" role="tab">
<h2 class="sub-title panel-title">
Always On VPN Settings
<label class="wr-input-control switch" data-toggle="collapse" data-target="#always-on-vpn-body">
<input type="checkbox"/>
<span class="helper"></span>
<span class="text"></span>
</label>
</h2>
<div class="panel-title-description">
Configure an always-on VPN connection through a specific VPN client application
</div>
</div>
<div id="always-on-vpn-body" class="panel-collapse panel-body collapse" role="tabpanel"
aria-labelledby="vpn-body">
<hr/>
<div class="always-on-vpn-message">
<ul class="message message-info">
<i class="icon fw fw-info"></i>
<a id="always-on-vpn-status-msg"> Below configurations are valid only when the Agent is
<b>work-profile owner</b> or <b>device owner</b>.</a>
</ul>
</div>
<br/>
<div class="wr-input-control">
<label class="wr-input-label" for="vpn-client-app">
VPN Client Application Package Name*
<span class="helper" title="Package name of the VPN client application to be configured.">
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
</span>
</label>
<input id="vpn-client-app" type="text" class="form-control operationDataKeys"
data-key="packageName" maxlength="200" placeholder="[ Should be a valid package name ]"/>
</div>
<!--<div class="wr-input-control">-->
<!--<label class="wr-input-control checkbox">-->
<!--<input id="vpn-lock-down" type="checkbox" class="operationDataKeys"-->
<!--data-key="lockDownEnable" checked="checked"/>-->
<!--<span class="helper"-->
<!--title="True to disallow networking when the VPN is not connected or false otherwise">-->
<!--Lock Down VPN-->
<!--<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>-->
<!--</span>-->
<!--</label>-->
<!--</div>-->
</div>
<!-- Always on VPN connection settings -->
</div> </div>
</div> </div>
<!-- /VPN --> <!-- /VPN -->

@ -2142,6 +2142,62 @@
data-key="openvpn_config" style="height: 400px;" disabled></textarea> data-key="openvpn_config" style="height: 400px;" disabled></textarea>
</div> </div>
</div> </div>
<!-- Always on VPN connection settings -->
<div id="always-on-vpn-heading" class="panel-heading" role="tab">
<h2 class="sub-title panel-title">
Always On VPN Settings
<label class="wr-input-control switch" data-toggle="collapse" data-target="#always-on-vpn-body">
<input type="checkbox"/>
<span class="helper"></span>
<span class="text"></span>
</label>
</h2>
<div class="panel-title-description">
Configure an always-on VPN connection through a specific VPN client application
</div>
</div>
<div id="always-on-vpn-body" class="panel-collapse panel-body collapse" role="tabpanel"
aria-labelledby="vpn-body">
<hr/>
<div class="always-on-vpn-message">
<ul class="message message-info">
<i class="icon fw fw-info"></i>
<a id="always-on-vpn-status-msg"> Below configurations are valid only when the Agent is
<b>work-profile owner</b> or <b>device owner</b>.</a>
</ul>
</div>
<br/>
<div class="wr-input-control">
<label class="wr-input-label" for="vpn-client-app">
VPN Client Application Package Name
<span class="helper" title="Package name of the VPN client application to be configured.">
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
</span>
</label>
<input id="vpn-client-app" type="text" class="form-control operationDataKeys"
data-key="packageName" maxlength="200" placeholder="[ Should be a valid package name ]"/>
</div>
<!--<div class="wr-input-control">-->
<!--<label class="wr-input-control checkbox">-->
<!--<input id="vpn-lock-down" type="checkbox" class="operationDataKeys"-->
<!--data-key="lockDownEnable" checked="checked"/>-->
<!--<span class="helper"-->
<!--title="True to disallow networking when the VPN is not connected or false otherwise">-->
<!--Lock Down VPN-->
<!--<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>-->
<!--</span>-->
<!--</label>-->
<!--</div>-->
</div>
<!-- Always on VPN connection settings -->
</div> </div>
</div> </div>
<!-- /VPN --> <!-- /VPN -->
@ -2810,4 +2866,4 @@
<!--/enrolment-app-install--> <!--/enrolment-app-install-->
</div> </div>
<script type="text/javascript">applyDataTable();</script> <script type="text/javascript">applyDataTable();</script>
</div> </div>

@ -524,17 +524,35 @@ var validatePolicyProfile = function () {
operation = androidOperationConstants["VPN_OPERATION"]; operation = androidOperationConstants["VPN_OPERATION"];
// initializing continueToCheckNextInputs to true // initializing continueToCheckNextInputs to true
continueToCheckNextInputs = true; continueToCheckNextInputs = true;
let openVpnConfigEnabled = document.getElementById('vpn-body').classList.contains('in');
if (openVpnConfigEnabled) {
var openvpnConfig = $("input#openvpn-config").val();
if (!openvpnConfig || openvpnConfig === '') {
validationStatus = {
"error": true,
"subErrorMsg": "ovpn config file is required. You cannot proceed.",
"erroneousFeature": operation
};
continueToCheckNextInputs = false;
}
}
var openvpnConfig = $("input#openvpn-config").val(); if (validationStatus) {
if (!openvpnConfig || openvpnConfig === '') { validationStatusArray.push(validationStatus);
validationStatus = {
"error": true,
"subErrorMsg": "ovpn config file is required. You cannot proceed.",
"erroneousFeature": operation
};
continueToCheckNextInputs = false;
} }
let alwaysOnVpnEnabled = document.getElementById('always-on-vpn-body').classList.contains('in');
if (alwaysOnVpnEnabled) {
var alwaysOnConfig = $("input#vpn-client-app").val();
if (!alwaysOnConfig || alwaysOnConfig === '') {
validationStatus = {
"error": true,
"subErrorMsg": "Add a valid package name for the VPN client",
"erroneousFeature": "always-on-vpn"
};
continueToCheckNextInputs = false;
}
}
// at-last, if the value of continueToCheckNextInputs is still true // at-last, if the value of continueToCheckNextInputs is still true
// this means that no error is found // this means that no error is found
if (continueToCheckNextInputs) { if (continueToCheckNextInputs) {
@ -1294,4 +1312,4 @@ $(document).ready(function () {
$(this).removeClass("child-input"); $(this).removeClass("child-input");
}); });
}); });
}); });

@ -2160,7 +2160,67 @@
<input id="openvpn-config" class="form-control operationDataKeys" type="hidden" data-key="openvpn_config" /> <input id="openvpn-config" class="form-control operationDataKeys" type="hidden" data-key="openvpn_config" />
<input id="vpn-type" class="form-control operationDataKeys" type="hidden" data-key="type" value="OpenVPN" /> <input id="vpn-type" class="form-control operationDataKeys" type="hidden" data-key="type" value="OpenVPN" />
</div> </div>
<br/>
</div>
<!-- Always on VPN connection settings -->
<div id="always-on-vpn-heading" class="panel-heading" role="tab">
<h2 class="sub-title panel-title">
Always On VPN Settings
<label class="wr-input-control switch" data-toggle="collapse" data-target="#always-on-vpn-body">
<input type="checkbox"/>
<span class="helper"></span>
<span class="text"></span>
</label>
</h2>
<div class="panel-title-description">
Configure an always-on VPN connection through a specific VPN client application
</div>
</div>
<div id="always-on-vpn-body" class="panel-collapse panel-body collapse" role="tabpanel"
aria-labelledby="vpn-body">
<hr/>
<div class="always-on-vpn-message">
<ul class="message message-info">
<i class="icon fw fw-info"></i>
<a id="always-on-vpn-status-msg"> Below configurations are valid only when the Agent is
<b>work-profile owner</b> or <b>device owner</b>.</a>
</ul>
</div>
<br/>
<div id="always-on-vpn-feature-error-msg" class="alert alert-danger hidden" role="alert">
<i class="icon fw fw-error"></i><span></span>
</div>
<div class="wr-input-control">
<label class="wr-input-label" for="vpn-client-app">
VPN Client Application Package Name
<span class="helper" title="Package name of the VPN client application to be configured.">
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
</span>
</label>
<input id="vpn-client-app" type="text" class="form-control operationDataKeys"
data-key="packageName" maxlength="200" placeholder="[ Should be a valid package name ]"/>
</div>
<!--<div class="wr-input-control">-->
<!--<label class="wr-input-control checkbox">-->
<!--<input id="vpn-lock-down" type="checkbox" class="operationDataKeys"-->
<!--data-key="lockDownEnable" checked="checked"/>-->
<!--<span class="helper"-->
<!--title="True to disallow networking when the VPN is not connected or false otherwise">-->
<!--Lock Down VPN-->
<!--<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>-->
<!--</span>-->
<!--</label>-->
<!--</div>-->
</div> </div>
<!-- Always on VPN connection settings -->
</div> </div>
</div> </div>
<!-- /VPN --> <!-- /VPN -->
@ -2763,4 +2823,4 @@
<!--/enrolment-app-install--> <!--/enrolment-app-install-->
</div> </div>
<script type="text/javascript">applyDataTable();</script> <script type="text/javascript">applyDataTable();</script>
</div> </div>

Loading…
Cancel
Save