Skip to content

Commit cc3da0c

Browse files
committed
Merge branch 'ip-obfuscation' into 'feat/data-obfuscation'
IP obfuscation See merge request Cantarus-Tools/PolyDeploy!20
2 parents a9a7161 + f74cad7 commit cc3da0c

26 files changed

+471
-175
lines changed

DeployClient/Properties/AssemblyInfo.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("0.9.0.0")]
36-
[assembly: AssemblyFileVersion("0.9.0.0")]
35+
[assembly: AssemblyVersion("0.9.1.0")]
36+
[assembly: AssemblyFileVersion("0.9.1.0")]

DeployClient/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "deploy-client",
3-
"version": "0.9.0",
3+
"version": "0.9.1",
44
"main": "gulpfile.js",
55
"license": "Apache-2.0",
66
"private": true,

DeployClient/project.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = {
2-
MODULE_VERSION: '00.09.00'
2+
MODULE_VERSION: '00.09.01'
33
};

PolyDeploy/Clients/Core/src/js/services/IPSpecDataService.js

+11-5
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,20 @@
1818

1919
// POST
2020
// Create a new IPSpec.
21-
function createSpec(ipAddress) {
21+
function createSpec(name, ipAddress) {
2222

2323
// Make request.
24-
return $http.post(controllerUrl + 'Create?ip=' + ipAddress).then(
24+
return $http.post(controllerUrl + `Create?name=${name}&ip=${ipAddress}`).then(
2525
function (response) {
26-
27-
// Return unpacked data.
28-
return response.data;
26+
return {
27+
err: null,
28+
ipSpec: response.data
29+
}
30+
},
31+
function (response) {
32+
return {
33+
err: response.data.Message
34+
}
2935
});
3036
}
3137

PolyDeploy/Clients/Manage/src/css/main.less

+15
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,21 @@
88

99
#cantarus-poly-deploy {
1010

11+
#menu {
12+
13+
ul {
14+
list-style: none;
15+
margin: 0;
16+
padding: 0;
17+
18+
li {
19+
list-style: inherit;
20+
margin: 0;
21+
padding: 0;
22+
}
23+
}
24+
}
25+
1126
.can-pagination {
1227
position: relative;
1328
height: 20px;

PolyDeploy/Clients/Manage/src/js/controllers/WhitelistController.js

+22-4
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,33 @@
44
// Load specs.
55
refreshSpecs();
66

7+
$scope.newIp = {
8+
name: '',
9+
ipv4Address: ''
10+
};
11+
12+
$scope.errorMessage = null;
13+
14+
// Dismiss error message.
15+
$scope.dismissError = function () {
16+
17+
$scope.errorMessage = null;
18+
};
19+
720
// Create spec.
8-
$scope.createSpec = function (ipAddress) {
21+
$scope.createSpec = function (ipSpec) {
922

1023
// Create the new spec and append it.
11-
IPSpecDataService.createSpec(ipAddress).then(
12-
function (createdSpec) {
24+
IPSpecDataService.createSpec(ipSpec.name, ipSpec.ipv4Address).then(
25+
function (resp) {
26+
27+
if (resp.err) {
28+
$scope.errorMessage = resp.err;
29+
return;
30+
}
1331

1432
// Push on to specs.
15-
$scope.specs.push(createdSpec);
33+
$scope.specs.push(resp.ipSpec);
1634
});
1735
};
1836

PolyDeploy/Clients/Manage/src/js/services/APIUserDataService.js

-66
This file was deleted.

PolyDeploy/Clients/Manage/src/js/templates/menu.html

+10-6
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@
44

55
<!-- Menu -->
66
<div class="col-sm-2">
7-
<ul>
8-
<li><a ui-sref="menu.welcome">Welcome</a></li>
9-
<li><a ui-sref="menu.users">API Users</a></li>
10-
<li><a ui-sref="menu.whitelist">IP Whitelist</a></li>
11-
<li><a ui-sref="menu.events">Event Log</a></li>
12-
</ul>
7+
<div class="panel panel-default">
8+
<div class="panel-body">
9+
<ul>
10+
<li><a ui-sref="menu.welcome">Welcome</a></li>
11+
<li><a ui-sref="menu.users">API Users</a></li>
12+
<li><a ui-sref="menu.whitelist">IP Whitelist</a></li>
13+
<li><a ui-sref="menu.events">Event Log</a></li>
14+
</ul>
15+
</div>
16+
</div>
1317
</div>
1418
<!-- /Menu -->
1519

PolyDeploy/Clients/Manage/src/js/templates/users.html

+7-7
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@ <h3 class="panel-title">New API User</h3>
1414
<div class="form-group">
1515
<label class="col-sm-3 control-label">Name</label>
1616
<div class="col-sm-9">
17-
<input type="text" ng-model="newUser.name" />
17+
<input type="text" ng-model="newUser.name" />
18+
</div>
1819
</div>
19-
</div>
2020
<div class="form-group">
2121
<label class="col-sm-3 control-label">Bypass IP Whitelist</label>
2222
<div class="col-sm-9">
23-
<input type="checkbox" ng-model="newUser.bypassIPWhitelist" />
23+
<input type="checkbox" ng-model="newUser.bypassIPWhitelist" />
24+
</div>
2425
</div>
25-
</div>
26-
<div class="form-group">
26+
<div class="form-group">
2727
<div class="col-sm-offset-3 col-sm-9">
28-
<button type="button" class="btn btn-success" ng-click="createUser(newUser)">Create</button>
28+
<button type="button" class="btn btn-success" ng-click="createUser(newUser)">Create</button>
29+
</div>
2930
</div>
3031
</div>
31-
</div>
3232
<div class="clearfix"></div>
3333
</div>
3434
</div>

PolyDeploy/Clients/Manage/src/js/templates/whitelist.html

+25-12
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,36 @@
1010
<h3 class="panel-title">New Whitelist Entry</h3>
1111
</div>
1212
<div class="panel-body">
13-
14-
<div class="form-group">
15-
<label class="col-sm-2 control-label">IPv4 Address</label>
16-
<div class="col-sm-10">
17-
<input type="text" ng-model="newIpv4Address" />
18-
</div>
13+
<div class="alert alert-danger alert-dismissable" ng-if="errorMessage">
14+
<button type="button" class="close" ng-click="dismissError()">&times</button>
15+
{{ errorMessage }}
1916
</div>
20-
<div class="form-group">
21-
<div class="col-sm-offset-2 col-sm-10">
22-
<button type="button" class="btn btn-success" ng-click="createSpec(newIpv4Address)">Create</button>
17+
<div class="form-horizontal">
18+
<div class="form-group">
19+
<label class="col-sm-3 control-label">Name</label>
20+
<div class="col-sm-9">
21+
<input type="text" ng-model="newIp.name" />
22+
</div>
23+
</div>
24+
<div class="form-group">
25+
<label class="col-sm-3 control-label">IPv4 Address</label>
26+
<div class="col-sm-9">
27+
<input type="text" ng-model="newIp.ipv4Address" />
28+
</div>
29+
</div>
30+
<div class="form-group">
31+
<div class="col-sm-offset-3 col-sm-9">
32+
<button type="button" class="btn btn-success" ng-click="createSpec(newIp)">Create</button>
33+
</div>
2334
</div>
2435
</div>
2536
<div class="clearfix"></div>
2637
</div>
2738
</div>
2839
</div>
29-
<!-- Create User -->
40+
<!-- Create Whitelist Entry -->
3041

31-
<!-- Users Table -->
42+
<!-- Whitelist Table -->
3243
<div class="col-xs-12">
3344
<div class="panel panel-default">
3445
<div class="panel-heading">
@@ -38,12 +49,14 @@ <h3 class="panel-title">Whitelist Entries</h3>
3849
<table class="table table-striped table-bordered">
3950
<thead>
4051
<tr>
52+
<th>Name</th>
4153
<th>IPv4 Address</th>
4254
<th></th>
4355
</tr>
4456
</thead>
4557
<tbody>
4658
<tr ng-repeat="spec in specs">
59+
<td>{{ spec.Name }}</td>
4760
<td>{{ spec.Address }}</td>
4861
<td><button type="button" class="btn btn-sm btn-danger" ng-click="deleteSpec(spec)">Delete</button></td>
4962
</tr>
@@ -52,7 +65,7 @@ <h3 class="panel-title">Whitelist Entries</h3>
5265
</div>
5366
</div>
5467
</div>
55-
<!-- /Users Table -->
68+
<!-- /Whitelist Table -->
5669

5770
</div>
5871
<!-- /Content -->

PolyDeploy/Components/DataAccess/DataControllers/IPSpecDataController.cs

+14-2
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,25 @@ public IPSpec Get(int ipSpecId)
4343
}
4444
}
4545

46-
public IPSpec FindByAddress(string address)
46+
public IPSpec Get(string address)
47+
{
48+
using (IDataContext context = DataContext.Instance())
49+
{
50+
return context.ExecuteSingleOrDefault<IPSpec>(
51+
System.Data.CommandType.StoredProcedure,
52+
"{databaseOwner}[{objectQualifier}Cantarus_PolyDeploy_IPSpecByAddress]",
53+
address
54+
);
55+
}
56+
}
57+
58+
public IPSpec GetByName(string name)
4759
{
4860
using (IDataContext context = DataContext.Instance())
4961
{
5062
var repo = context.GetRepository<IPSpec>();
5163

52-
return repo.Find("WHERE Address = @0", address).FirstOrDefault<IPSpec>();
64+
return repo.Find("WHERE [Name] = @0", name).FirstOrDefault<IPSpec>();
5365
}
5466
}
5567

PolyDeploy/Components/DataAccess/Models/APIUser.cs

+1-30
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace Cantarus.Modules.PolyDeploy.Components.DataAccess.Models
66
{
77
[TableName("Cantarus_PolyDeploy_APIUsers")]
88
[PrimaryKey("APIUserID")]
9-
internal class APIUser
9+
internal class APIUser : Obfuscated
1010
{
1111
private bool prepared;
1212
private string apiKey;
@@ -151,35 +151,6 @@ public bool PrepareForUse(string apiKey)
151151
return prepared;
152152
}
153153

154-
internal static string GenerateHash(string value, string salt)
155-
{
156-
// Hash.
157-
string hash = CryptoUtilities.SHA256HashString(value + salt);
158-
159-
// Return upper case.
160-
return hash.ToUpper();
161-
}
162-
163-
internal static string GenerateSalt()
164-
{
165-
// Salt length of 16 bytes should be fine for now.
166-
int saltLength = 16;
167-
168-
// Generate random bytes.
169-
byte[] bytes = CryptoUtilities.GenerateRandomBytes(saltLength);
170-
171-
// Convert to string.
172-
string salt = "";
173-
174-
for(int i = 0; i < bytes.Length; i++)
175-
{
176-
salt = string.Format("{0}{1:X2}", salt, bytes[i]);
177-
}
178-
179-
// Return upper case.
180-
return salt.ToUpper();
181-
}
182-
183154
private static string GenerateKey()
184155
{
185156
// Get new guid as string.

0 commit comments

Comments
 (0)