Skip to content

Commit 1f531c9

Browse files
authored
Whitelist (#73)
Added support for reporting without a shared secret. Enables applications without a .NET backend to report errors directly to a Coderr Server. Requires that the reporting applications is on a domain whitelist.
1 parent 63b0129 commit 1f531c9

File tree

140 files changed

+4850
-293
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+4850
-293
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ Thumbs.db
2626
obj/
2727
[Rr]elease*/
2828
_ReSharper*/
29-
[Tt]est[Rr]esult*
3029
*/packages/*/
3130
**/.vs/*
3231
**/packages/*/

src/Server/Coderr.Server.Api.Client/Coderr.Server.Api.Client.csproj

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<TargetFrameworks>netstandard2.0</TargetFrameworks>
4-
<Version>1.1.0</Version>
4+
<Version>2.1.3</Version>
55
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
66
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\Coderr.Server.Api.Client.xml</DocumentationFile>
7+
<RootNamespace>Coderr.Server.Api.Client</RootNamespace>
8+
<AssemblyName>Coderr.Server.Api.Client</AssemblyName>
79
</PropertyGroup>
810
<PropertyGroup>
911
<PackageId>Coderr.Server.Api.Client</PackageId>
1012
<Authors>1TCompany AB</Authors>
11-
<Description>API client for codeRR Server.</Description>
13+
<Description>API client for Coderr Server.</Description>
1214
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
1315
<PackageReleaseNotes>Converted to vstudio 2017 csproj format</PackageReleaseNotes>
1416
<Copyright>Copyright 2017 © 1TCompany AB. All rights reserved.</Copyright>
1517
<PackageTags>logger exceptions analysis .net-core netstandard</PackageTags>
16-
<PackageIconUrl>http://coderrapp.com/images/nuget_icon.png</PackageIconUrl>
17-
<RepositoryUrl>https://github.com/coderr/coderr.server</RepositoryUrl>
18+
<PackageIconUrl>https://coderr.io/images/nuget_icon.png</PackageIconUrl>
19+
<RepositoryUrl>https://github.com/coderrio/coderr.server</RepositoryUrl>
1820
<RepositoryType>git</RepositoryType>
19-
<PackageLicenseUrl>https://raw.githubusercontent.com/coderr/codeRR.Server/master/LICENSE</PackageLicenseUrl>
20-
<PackageProjectUrl>https://coderrapp.com</PackageProjectUrl>
21-
<RootNamespace>Coderr.Server.Api.Client</RootNamespace>
22-
<AssemblyName>Coderr.Server.Api.Client</AssemblyName>
21+
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
22+
<PackageProjectUrl>https://coderr.io</PackageProjectUrl>
2323
</PropertyGroup>
2424
<ItemGroup>
25-
<PackageReference Include="DotNetCqs" Version="2.0.14" />
25+
<PackageReference Include="DotNetCqs" Version="2.0.15" />
2626
<PackageReference Include="System.ComponentModel.Annotations" Version="4.6.0" />
2727
</ItemGroup>
2828
<ItemGroup>

src/Server/Coderr.Server.Api/Coderr.Server.Api.csproj

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<TargetFramework>netstandard2.0</TargetFramework>
4-
<Version>1.1.0</Version>
4+
<Version>2.1.4</Version>
5+
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\Coderr.Server.Api.xml</DocumentationFile>
6+
<PackageReleaseNotes>Added the whitelist API</PackageReleaseNotes>
7+
</PropertyGroup>
8+
<PropertyGroup>
59
<RootNamespace>Coderr.Server.Api</RootNamespace>
610
<AssemblyName>Coderr.Server.Api</AssemblyName>
711
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
8-
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\codeRR.Server.Api.xml</DocumentationFile>
9-
</PropertyGroup>
10-
<PropertyGroup>
11-
<PackageId>codeRR.Server.Api</PackageId>
12+
<PackageId>Coderr.Server.Api</PackageId>
1213
<Authors>1TCompany AB</Authors>
13-
<Description>CQRS API definition for codeRR Server.</Description>
14+
<Description>API object definitions for Coderr Server, use the ApiClient package to communicate with the Coderr Server.</Description>
1415
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
15-
<PackageReleaseNotes>First release</PackageReleaseNotes>
16-
<Copyright>Copyright 2017 © 1TCompany AB. All rights reserved.</Copyright>
16+
<Copyright>Copyright 2019 © 1TCompany AB. All rights reserved.</Copyright>
1717
<PackageTags>logger exceptions analysis .net-core netstandard</PackageTags>
18-
<PackageIconUrl>http://coderrapp.com/images/nuget_icon.png</PackageIconUrl>
19-
<RepositoryUrl>https://github.com/coderr/coderr.server</RepositoryUrl>
18+
<PackageIconUrl>https://coderr.io/images/nuget_icon.png</PackageIconUrl>
19+
<RepositoryUrl>https://github.com/coderrio/coderr.server</RepositoryUrl>
2020
<RepositoryType>git</RepositoryType>
21-
<PackageLicenseUrl>https://raw.githubusercontent.com/coderr/codeRR.Server/master/LICENSE</PackageLicenseUrl>
22-
<PackageProjectUrl>https://coderrapp.com</PackageProjectUrl>
21+
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
22+
<PackageProjectUrl>https://coderr.io</PackageProjectUrl>
2323
</PropertyGroup>
2424
<PropertyGroup>
2525
<NoWarn>1701;1702;1705;1591</NoWarn>
2626
</PropertyGroup>
2727
<ItemGroup>
28-
<PackageReference Include="DotNetCqs" Version="2.0.14" />
28+
<PackageReference Include="DotNetCqs" Version="2.0.15" />
2929
</ItemGroup>
3030
<ItemGroup Condition="'$(TargetFramework)' == 'net452'">
3131
<Reference Include="System.Net.Http" />
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
namespace Coderr.Server.Api.Modules.Whitelists.Commands
2+
{
3+
/// <summary>
4+
/// Add a domain that may post error reports without using a shared secret (javascript applications)
5+
/// </summary>
6+
[Command]
7+
public class AddEntry
8+
{
9+
/// <summary>
10+
/// Applications that the domain is allowed for.
11+
/// </summary>
12+
public int[] ApplicationIds { get; set; } = new int[0];
13+
14+
/// <summary>
15+
/// For instance <c>yourdomain.com</c>.
16+
/// </summary>
17+
public string DomainName { get; set; }
18+
19+
/// <summary>
20+
/// To manually specify which IP addresses the domain matches.
21+
/// </summary>
22+
public string[] IpAddresses { get; set; } = new string[0];
23+
}
24+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
namespace Coderr.Server.Api.Modules.Whitelists.Commands
2+
{
3+
/// <summary>
4+
/// Edit a domain that may post error reports without using a shared secret (javascript applications)
5+
/// </summary>
6+
[Command]
7+
public class EditEntry
8+
{
9+
/// <summary>
10+
/// PK for the entry being edited.
11+
/// </summary>
12+
public int Id { get; set; }
13+
14+
/// <summary>
15+
/// Applications that the domain is allowed for.
16+
/// </summary>
17+
public int[] ApplicationIds { get; set; } = new int[0];
18+
19+
20+
/// <summary>
21+
/// Only manually specified ip addresses.
22+
/// </summary>
23+
public string[] IpAddresses { get; set; } = new string[0];
24+
}
25+
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
namespace Coderr.Server.ReportAnalyzer.Abstractions.Inbound.Whitelists.Commands
1+
namespace Coderr.Server.Api.Modules.Whitelists.Commands
22
{
33
/// <summary>
44
/// Remove a previously added white list entry
55
/// </summary>
6+
[Command]
67
public class RemoveEntry
78
{
89
/// <summary>
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
4-
using Coderr.Server.Api;
5-
using DotNetCqs;
1+
using DotNetCqs;
62

7-
namespace Coderr.Server.ReportAnalyzer.Abstractions.Inbound.Whitelists.Queries
3+
namespace Coderr.Server.Api.Modules.Whitelists.Queries
84
{
95
/// <summary>
106
/// Get whitelist either by application id or DomainName
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace Coderr.Server.ReportAnalyzer.Abstractions.Inbound.Whitelists.Queries
1+
namespace Coderr.Server.Api.Modules.Whitelists.Queries
22
{
33
/// <summary>
44
/// Result for <see cref="GetWhitelistEntries"/>.
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
namespace Coderr.Server.ReportAnalyzer.Abstractions.Inbound.Whitelists.Queries
1+
namespace Coderr.Server.Api.Modules.Whitelists.Queries
22
{
33
/// <summary>
44
/// Entry for <see cref="GetWhitelistEntriesResult"/>
55
/// </summary>
66
public class GetWhitelistEntriesResultItem
77
{
88
public int Id { get; set; }
9-
public int? ApplicationId { get; set; }
9+
public GetWhitelistEntriesResultItemIp[] IpAddresses { get; set; }
10+
public GetWhitelistEntriesResultItemApp[] Applications { get; set; }
1011
public string DomainName { get; set; }
1112
}
1213
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace Coderr.Server.Api.Modules.Whitelists.Queries
2+
{
3+
public class GetWhitelistEntriesResultItemApp
4+
{
5+
public int ApplicationId { get; set; }
6+
public string Name { get; set; }
7+
}
8+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System;
2+
3+
namespace Coderr.Server.Api.Modules.Whitelists.Queries
4+
{
5+
public class GetWhitelistEntriesResultItemIp
6+
{
7+
public string Address { get; set; }
8+
public DateTime UpdatedAtUtc { get; set; }
9+
public ResultItemIpType Type { get; set; }
10+
}
11+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
namespace Coderr.Server.Api.Modules.Whitelists.Queries
2+
{
3+
/// <summary>
4+
/// Typ of stored IP record.
5+
/// </summary>
6+
public enum ResultItemIpType
7+
{
8+
/// <summary>
9+
/// Added when doing a lookup for the domain
10+
/// </summary>
11+
Lookup = 0,
12+
13+
/// <summary>
14+
/// Manually specified by the user
15+
/// </summary>
16+
Manual = 1,
17+
18+
/// <summary>
19+
/// We got a request from this IP and a lookup didn't match it.
20+
/// </summary>
21+
Denied = 2
22+
}
23+
}

src/Server/Coderr.Server.App/Coderr.Server.App.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@
2121
<PackageReference Include="ColorCode" Version="1.0.1">
2222
<NoWarn>NU1701</NoWarn>
2323
</PackageReference>
24-
<PackageReference Include="DotNetCqs" Version="2.0.14" />
24+
<PackageReference Include="DnsClient" Version="1.2.0" />
25+
<PackageReference Include="DotNetCqs" Version="2.0.15" />
2526
<PackageReference Include="Griffin.Framework" Version="2.1.1" />
2627
<PackageReference Include="log4net" Version="2.0.8" />
27-
<PackageReference Include="Markdig" Version="0.17.1" />
28+
<PackageReference Include="Markdig" Version="0.18.0" />
2829
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
2930
<PackageReference Include="System.Net.Http" Version="4.3.4" />
3031
<PackageReference Include="UAParser" Version="3.1.43" />

src/Server/Coderr.Server.App/Core/Incidents/Commands/CloseIncidentHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public async Task HandleAsync(IMessageContext context, CloseIncident command)
4242
if (command == null) throw new ArgumentNullException("command");
4343

4444
var incident = await _repository.GetAsync(command.IncidentId);
45-
incident.Close(command.UserId, command.Solution);
45+
incident.Close(command.UserId, command.Solution, command.ApplicationVersion);
4646
if (command.ShareSolution)
4747
incident.ShareSolution();
4848

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System.Collections.Generic;
2+
using System.Net;
3+
using System.Threading.Tasks;
4+
5+
namespace Coderr.Server.App.Modules.Whitelists
6+
{
7+
/// <summary>
8+
/// Whitelists is used for reports that don't use a shared secret
9+
/// </summary>
10+
public interface IWhitelistRepository
11+
{
12+
Task<WhitelistedDomainIp> FindIp(int applicationId, IPAddress address);
13+
Task<IReadOnlyList<Whitelist>> FindWhitelists(int applicationId);
14+
15+
Task SaveIp(WhitelistedDomainIp entry);
16+
}
17+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System.Net;
2+
using System.Threading.Tasks;
3+
4+
namespace Coderr.Server.App.Modules.Whitelists
5+
{
6+
/// <summary>
7+
/// Used to validate origin of inbound requests when a shared secret is not used.
8+
/// </summary>
9+
public interface IWhitelistService
10+
{
11+
/// <summary>
12+
/// Is domain white listed?
13+
/// </summary>
14+
/// <param name="appKey">AppKey used when receiving error reports.</param>
15+
/// <param name="remoteAddress">IP address of the client reporting the error.</param>
16+
/// <returns></returns>
17+
Task<bool> Validate(string appKey, IPAddress remoteAddress);
18+
19+
/// <summary>
20+
/// Is domain white listed?
21+
/// </summary>
22+
/// <param name="applicationId">Application that the error is reported for.</param>
23+
/// <param name="remoteAddress">IP address of the client reporting the error.</param>
24+
/// <returns></returns>
25+
Task<bool> Validate(int applicationId, IPAddress remoteAddress);
26+
}
27+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
namespace Coderr.Server.App.Modules.Whitelists
2+
{
3+
/// <summary>
4+
/// Typ of stored IP record.
5+
/// </summary>
6+
public enum IpType
7+
{
8+
/// <summary>
9+
/// Added when doing a lookup for the domain
10+
/// </summary>
11+
Lookup = 0,
12+
13+
/// <summary>
14+
/// Manually specified by the user
15+
/// </summary>
16+
Manual = 1,
17+
18+
/// <summary>
19+
/// We got a request from this IP and a lookup didn't match it.
20+
/// </summary>
21+
Denied = 2
22+
}
23+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
namespace Coderr.Server.App.Modules.Whitelists
2+
{
3+
/// <summary>
4+
/// Domain that is allowed to report errors without
5+
/// </summary>
6+
public class Whitelist
7+
{
8+
/// <summary>
9+
/// Domain name, must be an exact match. Can also be an IP address
10+
/// </summary>
11+
public string DomainName { get; set; }
12+
13+
/// <summary>
14+
/// PK
15+
/// </summary>
16+
public int Id { get; set; }
17+
18+
/// <summary>
19+
/// Addresses that have been stored for this domain
20+
/// </summary>
21+
public WhitelistedDomainIp[] IpAddresses { get; set; }
22+
23+
/// <summary>
24+
/// Applications that this whitelist is allowed for
25+
/// </summary>
26+
public int[] ApplicationIds { get; set; }
27+
}
28+
}

0 commit comments

Comments
 (0)