You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The need for auditing already exists in projects, the requirement to log information to prove something happened, but also to capture who, what and when a business action happened.
@@ -15,156 +23,28 @@ The need for auditing already exists in projects, the requirement to log informa
15
23
- capture who with the `IPrincipal` or `IClaimsPrincipal`
16
24
- Supports tracing, using the `OpenTelemerty/W3C` specification
| Use | Proof of a business action, with who did it, against what and when. | To understand what is happening with a service, and ensure it can be keep up and running |
| Fails | Loudly (excpetions are thrown) | Sliently (exceptions are swallowed) |
28
-
| Process style | Sync | Async |
29
-
| (typically) Stored for<br>(really depends on your<br>requirements) | possibly years (depending on your regulators and law) | possibly weeks to months (depending on your requirements) |
40
+
## Patch / feature releases
30
41
42
+
We use a variant of Githubflow, so all feature branches have their own pre-release packages
31
43
32
44
33
-
# Code teaser
34
45
35
-
Lets take ASPNET Core, please consider using the OpenTelemetry package to get all the data.
46
+
# Docs and examples
36
47
37
-
## 1. Builder
48
+
check out our docs for examples and more information
38
49
39
-
```
40
-
var builder = Host
41
-
.CreateDefaultBuilder()
42
-
.ConfigureAuditable(conf =>
43
-
{
44
-
conf.Use<AspNet>(); //this is registering the ASPNET dependencies
45
-
conf.UseWriter<File>(); //note the default writer is console
46
-
})
47
-
.ConfigureWebHostDefaults(x =>
48
-
{
49
-
x.UseStartup<TStartup>().UseTestServer();
50
-
});
51
-
```
52
-
53
-
## 2. AspNET startup
54
-
55
-
```
56
-
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
57
-
{
58
-
app.UseRouting();
59
-
60
-
app.UseAuthentication();
61
-
app.UseAuthorization();
62
-
63
-
//ensure its after auth*
64
-
app.UseAuditable();
65
-
66
-
app.UseEndpoints(endpoints =>
67
-
{
68
-
endpoints.MapControllers();
69
-
});
70
-
71
-
}
72
-
```
73
-
74
-
## 3. add some auditable logs
75
-
76
-
imagine you want to load an account instance from the db and update it.
77
-
78
-
```
79
-
[Route("/Account")]
80
-
[Authorize]
81
-
public class AccountController : Controller
82
-
{
83
-
private readonly DocumentSession _session;
84
-
private readonly IAuditable _auditable;
85
-
private readonly ILogger<TestController> _logger;
86
-
87
-
public AccountController(
88
-
DocumentSession session,
89
-
IAuditable auditable,
90
-
ILogger<TestController> logger)
91
-
{
92
-
_session = session;
93
-
_auditable = auditable;
94
-
_logger = logger;
95
-
}
96
-
97
-
98
-
[HttpPut]
99
-
public async Task<ActionResult> Put(AccountResource updatedAccount)
100
-
{
101
-
if (updatedAccount == null) throw new ArgumentNullException(nameof(updatedAccount));
102
-
await using var auditContext = _auditable.CreateContext("Account.Update");
103
-
104
-
var account = await _session.GetById(updatedAccount.Id);
105
-
auditContext.WatchTargets(account); //watch for detla's
106
-
107
-
//modify
108
-
account.Name = updatedAccount.Name;
109
-
110
-
_logger.LogInformation("log out system information as normal");
111
-
return new OkResult();
112
-
113
-
//as we are within a using block, this will write the auditable entry
All the information we are capturing is to support an Audit from an Auditor (typically external). They will look over the Auditable Entries during their Audit. Once the External Audit of an Application is complete, they will produce an Audit Report.
0 commit comments