Audit.SignalR
25.0.7
See the version list below for details.
dotnet add package Audit.SignalR --version 25.0.7
NuGet\Install-Package Audit.SignalR -Version 25.0.7
<PackageReference Include="Audit.SignalR" Version="25.0.7" />
paket add Audit.SignalR --version 25.0.7
#r "nuget: Audit.SignalR, 25.0.7"
// Install Audit.SignalR as a Cake Addin #addin nuget:?package=Audit.SignalR&version=25.0.7 // Install Audit.SignalR as a Cake Tool #tool nuget:?package=Audit.SignalR&version=25.0.7
Audit.SignalR
SignalR Auditing Extension for Audit.NET library.
Automatically generates Audit Logs for ASP.NET SignalR or Asp Net Core SignalR invokations.
Audit.SignalR provides a configurable Hub Pipeline Module/Filter that intercepts the hub processing to generate an audit trail.
It generate logs for the following events:
Event Name | Description | ASP.NET SignalR | ASP.NET Core SignalR |
---|---|---|---|
Connect | Client is connecting to the server | ✅ | ✅ |
Disconnect | Client disconnect from the server | ✅ | ✅ |
Incoming | Client invoking server-side method | ✅ | ✅ |
Reconnect | Client reconnecting to the server | ✅ | ❌ |
Outgoing | Server invoking client-side method | ✅ | ❌ |
Error | An error has occurred | ✅ | ❌ |
Install
NuGet Package
To install the package run the following command on the Package Manager Console:
PM> Install-Package Audit.SignalR
SignalR Version
This library supports:
Usage - ASP.NET SignalR
On your ASP.NET startup logic, call the extension method AddAuditModule()
defined on namespace Microsoft.AspNet.SignalR.GlobalHost.HubPipeline
, to setup the audit pipeline. This must be called before IAppBuilder.MapSignalR()
.
This method provides a fluent API to configure the audit module.
For example:
using Audit.SignalR;
using Microsoft.AspNet.SignalR;
//...
public class Startup
{
public void Configuration(IAppBuilder app)
{
GlobalHost.HubPipeline.AddAuditModule(config => config
.IncludeHeaders()
.Filters(f => f
.IncludeOutgoingEvent(og => og.HubName == "myHub")
.IncludeReconnectEvent(false));
app.MapSignalR();
}
}
This will create an AuditPipelineModule
(that inherits from HubPipelineModule)
and will add it to the hub pipeline.
Alternatively, you can create an instance of the module and add it to the pipeline, with the exact same effect:
using Audit.SignalR;
using Microsoft.AspNet.SignalR;
//...
var module = new AuditPipelineModule()
{
IncludeHeaders = true,
ReconnectEventsFilter = _ => false,
OutgoingEventsFilter = og => og.HubName == "myHub"
};
GlobalHost.HubPipeline.AddModule(module);
Or create the module using the factory method AuditPipelineModule.Create()
that provides the fluent API for the configuration:
var module = AuditPipelineModule.Create(config => config
.IncludeHeaders()
...
);
GlobalHost.HubPipeline.AddModule(module);
Usage - ASP.NET Core SignalR
On your ASP.NET Core startup logic, call the extension method AddAuditFilter()
defined on namespace Audit.SignalR
when adding the SignalR service.
This method provides a fluent API to configure the audit filter.
For example:
using Audit.SignalR;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddSignalR(c =>
{
c.AddAuditFilter(cfg => cfg
.IncludeHeaders()
.IncludeQueryString()
.Filters(f => f
.IncludeIncomingEvent(true)
.IncludeConnectEvent(false)
.IncludeDisconnectEvent(false))
);
});
This will create an Audit HubFilter
and add it to the hub pipeline.
Configuration
Settings
The following settings can be configured on the module/filter:
- AuditEventType: To indicate the event type to use on the audit event. (Default is the event name). Can contain the following placeholders:
- {event}: replaced with the SignalR event name (Connect, Reconnect, Disconnect, Incoming, Outgoing, Error).
- IncludeHeaders: To indicate if the audit should include the request headers (Valid for events Connect, Reconnect, Disconnect, Incoming and Error). Default is false.
- IncludeQueryString: To indicate if the audit should include the request Query String (Valid for events Connect, Reconnect, Disconnect, Incoming and Error). Default is false.
- AuditDisabled: Set to true to disable the audit log generation (bypass). Default is false.
- CreationPolicy: To indicate the event creation policy to use. Default is NULL to use the globally configured creation policy.
- AuditDataProvider: To indicate the Audit Data Provider to use. Default is NULL to use the globally configured data provider.
Filter settings
The module allows to configure filtering of events. By default it will log all the events.
- IncomingEventsFilter: Allows to filter Incoming events (invoking server-side methods) with a custom function that given the incoming event info, returns true if the event should be logged and false otherwise.
- OutgoingEventsFilter: Allows to filter Outgoing events (invoking client-side methods).
- ConnectEventsFilter: Allows to filter Connect events.
- DisconnectEventsFilter: Allows to filter Disconnect events.
- ReconnectEventsFilter: Allows to filter Reconnect events.
- ErrorEventsFilter: Allows to filter Error events.
Extension Methods
You can access the current Audit Scope
for the incoming event inside server-side methods, by calling the Hub extension method GetIncomingAuditScope()
/ GetAuditScope()
,
for example:
public class MyHub : Hub
{
public int Send(string name, string message)
{
var scope = this.GetAuditScope();
if (someCondition)
{
scope.Discard()
}
else
{
scope.SetCustomField("UserType", user.UserType);
}
//...
}
The SignalR specific event information on the AuditScope can be accessed as follows:
var scope = this.GetIncomingAuditScope();
var signalrEventIncoming = scope.Event.GetSignalrEvent<SignalrEventIncoming>();
Event Output
To configure the output persistence mechanism please see Configuration and Data Providers sections.
Output
Audit.SignalR output includes:
- Execution time and duration (when applicable)
- Environment information such as user, machine, domain and locale.
- ConnectionId
- Hub name, Method name and Arguments
- Exception details
- HTTP request details (optional)
Output details
The following tables describes the Audit.SignalR output fields per event type:
Field Name | Type | Description |
---|---|---|
EventType | SignalrEventType | "Connect" |
ConnectionId | string | The connection ID |
Headers | Dictionary<string, string> | The HTTP headers of the associated request (when IncludeHeaders is set to true) |
QueryString | Dictionary<string, string> | The query string of the associated request (when IncludeQueryString is set to true) |
LocalPath | string | The local path |
IdentityName | string | The identity name associated |
Field Name | Type | Description |
---|---|---|
EventType | SignalrEventType | "Disconnect" |
ConnectionId | string | The connection ID |
Headers | Dictionary<string, string> | The HTTP headers of the associated request (when IncludeHeaders is set to true) |
QueryString | Dictionary<string, string> | The query string of the associated request (when IncludeQueryString is set to true) |
LocalPath | string | The local path |
IdentityName | string | The identity name associated |
StopCalled | boolean | Set to true if the client explicitly closed the connection |
Field Name | Type | Description |
---|---|---|
EventType | SignalrEventType | "Incoming" |
ConnectionId | string | The connection ID |
Headers | Dictionary<string, string> | The HTTP headers of the associated request (when IncludeHeaders is set to true) |
QueryString | Dictionary<string, string> | The query string of the associated request (when IncludeQueryString is set to true) |
LocalPath | string | The local path |
IdentityName | string | The identity name associated |
HubName | string | The hub name |
HubType | string | The hub type name |
MethodName | string | The name of the invoked method |
Args | List<Object> | The arguments passed in the invokation |
Result | Object | The invoked method return value |
Exception | string | Exception information when the hub method fails |
Field Name | Type | Description |
---|---|---|
EventType | SignalrEventType | "Outgoing" |
HubName | string | The hub name |
Signal | string | The signal (ConnectionId, hub type name or hub type name + "." + group name) belonging to clients that receive the method invocation |
MethodName | string | The invoked method name |
Args | List<Object> | The arguments passed in the invokation |
SignalrEventError : SignalrEventConnect
Field Name | Type | Description |
---|---|---|
EventType | SignalrEventType | "Error" |
ConnectionId | string | The connection ID |
Headers | Dictionary<string, string> | The HTTP headers of the associated request (when IncludeHeaders is set to true) |
QueryString | Dictionary<string, string> | The query string of the associated request (when IncludeQueryString is set to true) |
LocalPath | string | The local path |
IdentityName | string | The identity name associated |
HubName | string | The hub name |
HubType | string | The hub type name |
Exception | string | Detailed information about the exception |
MethodName | string | The name of the invoked method |
Args | List<Object> | The arguments passed in the invokation |
Customization
Custom fields
You can add extra information as custom fields to the events by calling the method AddAuditCustomField
on your Hub
. For example:
public class MyHub : Hub
{
public int Send(string name, string message)
{
this.AddCustomField("User", user);
}
Another way to customize the output is by using global custom actions, please see custom actions for more information.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Framework | net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
-
.NETFramework 4.6.2
- Audit.NET (>= 25.0.7)
- Microsoft.AspNet.SignalR.Core (>= 2.4.3)
-
net7.0
- Audit.NET (>= 25.0.7)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
27.3.2 | 365 | 12/11/2024 |
27.3.1 | 151 | 12/10/2024 |
27.3.0 | 262 | 12/8/2024 |
27.2.0 | 1,347 | 11/23/2024 |
27.1.1 | 1,520 | 10/28/2024 |
27.1.0 | 190 | 10/24/2024 |
27.0.3 | 1,275 | 9/25/2024 |
27.0.2 | 158 | 9/19/2024 |
27.0.1 | 516 | 9/4/2024 |
27.0.0 | 761 | 9/3/2024 |
26.0.1 | 386 | 8/22/2024 |
26.0.0 | 1,682 | 7/19/2024 |
25.0.7 | 1,007 | 7/4/2024 |
25.0.6 | 113 | 6/24/2024 |
25.0.5 | 118 | 6/18/2024 |
25.0.4 | 2,724 | 3/24/2024 |
25.0.3 | 157 | 3/13/2024 |
25.0.2 | 140 | 3/12/2024 |
25.0.1 | 148 | 2/28/2024 |
25.0.0 | 136 | 2/16/2024 |
24.0.1 | 150 | 2/12/2024 |
24.0.0 | 131 | 2/12/2024 |
23.0.0 | 3,553 | 12/14/2023 |
22.1.0 | 121 | 12/9/2023 |
22.0.2 | 1,572 | 12/1/2023 |
22.0.1 | 163 | 11/16/2023 |
22.0.0 | 126 | 11/14/2023 |
21.1.0 | 1,147 | 10/9/2023 |
21.0.4 | 1,319 | 9/15/2023 |
21.0.3 | 2,907 | 7/9/2023 |
21.0.2 | 185 | 7/6/2023 |
21.0.1 | 178 | 5/27/2023 |
21.0.0 | 921 | 4/15/2023 |
20.2.4 | 521 | 3/27/2023 |
20.2.3 | 431 | 3/17/2023 |
20.2.2 | 251 | 3/14/2023 |
20.2.1 | 242 | 3/11/2023 |
20.2.0 | 246 | 3/7/2023 |
20.1.6 | 277 | 2/23/2023 |
20.1.5 | 303 | 2/9/2023 |
20.1.4 | 353 | 1/28/2023 |
20.1.3 | 344 | 12/21/2022 |
20.1.2 | 336 | 12/14/2022 |
20.1.1 | 323 | 12/12/2022 |
20.1.0 | 356 | 12/4/2022 |
20.0.4 | 371 | 11/30/2022 |
20.0.3 | 689 | 10/28/2022 |
20.0.2 | 452 | 10/26/2022 |
20.0.1 | 497 | 10/21/2022 |
20.0.0 | 598 | 10/1/2022 |
19.4.1 | 573 | 9/10/2022 |
19.4.0 | 500 | 9/2/2022 |
19.3.0 | 512 | 8/23/2022 |
19.2.2 | 565 | 8/11/2022 |
19.2.1 | 530 | 8/6/2022 |
19.2.0 | 601 | 7/24/2022 |
19.1.4 | 524 | 5/23/2022 |
19.1.3 | 502 | 5/22/2022 |
19.1.2 | 478 | 5/18/2022 |
19.1.1 | 519 | 4/28/2022 |
19.1.0 | 511 | 4/10/2022 |
19.0.7 | 523 | 3/13/2022 |
19.0.6 | 553 | 3/7/2022 |
19.0.5 | 566 | 1/28/2022 |
19.0.4 | 544 | 1/23/2022 |
19.0.3 | 395 | 12/14/2021 |
19.0.2 | 379 | 12/11/2021 |
19.0.1 | 745 | 11/20/2021 |
19.0.0 | 390 | 11/11/2021 |
19.0.0-rc.net60.2 | 160 | 9/26/2021 |
19.0.0-rc.net60.1 | 207 | 9/16/2021 |
18.1.6 | 452 | 9/26/2021 |
18.1.5 | 424 | 9/7/2021 |
18.1.4 | 425 | 9/6/2021 |
18.1.3 | 2,911 | 8/19/2021 |
18.1.2 | 523 | 8/8/2021 |
18.1.1 | 446 | 8/5/2021 |
18.1.0 | 491 | 8/1/2021 |
18.0.1 | 498 | 7/30/2021 |
18.0.0 | 511 | 7/26/2021 |
17.0.8 | 469 | 7/7/2021 |
17.0.7 | 511 | 6/16/2021 |
17.0.6 | 473 | 6/5/2021 |
17.0.5 | 496 | 5/28/2021 |
17.0.4 | 482 | 5/4/2021 |
17.0.3 | 458 | 5/1/2021 |
17.0.2 | 478 | 4/22/2021 |
17.0.1 | 460 | 4/18/2021 |
17.0.0 | 517 | 3/26/2021 |
16.5.6 | 509 | 3/25/2021 |
16.5.5 | 452 | 3/23/2021 |
16.5.4 | 506 | 3/9/2021 |
16.5.3 | 473 | 2/26/2021 |
16.5.2 | 544 | 2/23/2021 |
16.5.1 | 482 | 2/21/2021 |
16.5.0 | 466 | 2/17/2021 |
16.4.5 | 470 | 2/15/2021 |
16.4.4 | 465 | 2/5/2021 |
16.4.3 | 466 | 1/27/2021 |
16.4.2 | 484 | 1/22/2021 |
16.4.1 | 526 | 1/21/2021 |
16.4.0 | 508 | 1/11/2021 |
16.3.3 | 519 | 1/8/2021 |
16.3.2 | 511 | 1/3/2021 |
16.3.1 | 532 | 12/31/2020 |
16.3.0 | 462 | 12/30/2020 |
16.2.1 | 507 | 12/27/2020 |
16.2.0 | 575 | 10/13/2020 |
16.1.5 | 578 | 10/4/2020 |
16.1.4 | 589 | 9/17/2020 |
16.1.3 | 695 | 9/13/2020 |
16.1.2 | 567 | 9/9/2020 |
16.1.1 | 585 | 9/3/2020 |
16.1.0 | 602 | 8/19/2020 |
16.0.3 | 634 | 8/15/2020 |
16.0.2 | 594 | 8/9/2020 |
16.0.1 | 681 | 8/8/2020 |
16.0.0 | 571 | 8/7/2020 |
15.3.0 | 638 | 7/23/2020 |
15.2.3 | 605 | 7/14/2020 |
15.2.2 | 1,029 | 5/19/2020 |
15.2.1 | 588 | 5/12/2020 |
15.2.0 | 626 | 5/9/2020 |
15.1.1 | 591 | 5/4/2020 |
15.1.0 | 636 | 4/13/2020 |
15.0.5 | 642 | 3/18/2020 |
15.0.4 | 604 | 2/28/2020 |
15.0.3 | 591 | 2/26/2020 |
15.0.2 | 782 | 1/20/2020 |
15.0.1 | 651 | 1/10/2020 |
15.0.0 | 644 | 12/17/2019 |
14.9.1 | 654 | 11/30/2019 |
14.9.0 | 639 | 11/29/2019 |
14.8.1 | 651 | 11/26/2019 |
14.8.0 | 644 | 11/20/2019 |
14.7.0 | 667 | 10/9/2019 |
14.6.6 | 664 | 10/8/2019 |
14.6.5 | 658 | 9/27/2019 |
14.6.4 | 662 | 9/21/2019 |
14.6.3 | 681 | 8/12/2019 |
14.6.2 | 723 | 8/3/2019 |
14.6.1 | 695 | 8/3/2019 |
14.6.0 | 665 | 7/26/2019 |
14.5.7 | 704 | 7/18/2019 |
14.5.6 | 704 | 7/10/2019 |
14.5.5 | 697 | 7/1/2019 |
14.5.4 | 702 | 6/17/2019 |
14.5.3 | 727 | 6/5/2019 |
14.5.2 | 707 | 5/30/2019 |
14.5.1 | 699 | 5/28/2019 |
14.5.0 | 718 | 5/24/2019 |
14.4.0 | 740 | 5/22/2019 |
14.3.4 | 751 | 5/14/2019 |
14.3.3 | 704 | 5/9/2019 |
14.3.2 | 750 | 4/30/2019 |
14.3.1 | 741 | 4/27/2019 |
14.3.0 | 762 | 4/24/2019 |
14.2.3 | 757 | 4/17/2019 |
14.2.2 | 726 | 4/10/2019 |
14.2.1 | 714 | 4/5/2019 |
14.2.0 | 720 | 3/16/2019 |
14.1.1 | 720 | 3/8/2019 |
14.1.0 | 830 | 2/11/2019 |
14.0.4 | 811 | 1/31/2019 |
14.0.3 | 836 | 1/22/2019 |
14.0.2 | 854 | 12/15/2018 |
14.0.1 | 873 | 11/29/2018 |
14.0.0 | 897 | 11/19/2018 |
13.3.0 | 907 | 11/16/2018 |
13.2.2 | 886 | 11/15/2018 |
13.2.1 | 885 | 11/13/2018 |
13.2.0 | 912 | 10/31/2018 |
13.1.5 | 903 | 10/31/2018 |
13.1.4 | 926 | 10/25/2018 |
13.1.3 | 914 | 10/18/2018 |
13.1.2 | 968 | 9/12/2018 |
13.1.1 | 967 | 9/11/2018 |
13.1.0 | 982 | 9/11/2018 |
13.0.0 | 995 | 8/29/2018 |
12.3.6 | 977 | 8/29/2018 |
12.3.5 | 995 | 8/22/2018 |
12.3.4 | 996 | 8/21/2018 |
12.3.3 | 25,751 | 8/21/2018 |
12.3.2 | 1,053 | 8/20/2018 |
12.3.1 | 1,067 | 8/20/2018 |
12.3.0 | 1,021 | 8/20/2018 |
12.2.2 | 1,053 | 8/15/2018 |
12.2.1 | 1,101 | 8/9/2018 |
12.2.0 | 1,025 | 8/8/2018 |
12.1.11 | 1,033 | 7/30/2018 |
12.1.10 | 987 | 7/20/2018 |
12.1.9 | 1,119 | 7/10/2018 |
12.1.8 | 1,148 | 7/2/2018 |
12.1.7 | 1,177 | 6/7/2018 |
12.1.6 | 1,063 | 6/4/2018 |
12.1.5 | 1,105 | 6/2/2018 |
12.1.4 | 1,053 | 5/25/2018 |
12.1.3 | 1,238 | 5/16/2018 |
12.1.2 | 1,105 | 5/15/2018 |
12.1.1 | 1,196 | 5/14/2018 |
12.1.0 | 1,128 | 5/9/2018 |
12.0.7 | 1,460 | 5/5/2018 |
12.0.6 | 1,199 | 5/4/2018 |
12.0.5 | 1,162 | 5/3/2018 |
12.0.4 | 1,237 | 4/30/2018 |
12.0.3 | 1,211 | 4/30/2018 |
12.0.2 | 1,126 | 4/27/2018 |
12.0.1 | 1,120 | 4/25/2018 |
12.0.0 | 1,063 | 4/22/2018 |
11.2.0 | 1,206 | 4/11/2018 |
11.1.0 | 1,127 | 4/8/2018 |
11.0.8 | 1,137 | 3/26/2018 |
11.0.7 | 1,123 | 3/20/2018 |
11.0.6 | 1,138 | 3/7/2018 |
11.0.5 | 1,083 | 2/22/2018 |
11.0.4 | 1,140 | 2/14/2018 |
11.0.3 | 1,173 | 2/12/2018 |
11.0.2 | 1,151 | 2/9/2018 |
11.0.1 | 1,074 | 1/29/2018 |
11.0.0 | 1,166 | 1/15/2018 |
10.0.3 | 1,088 | 12/29/2017 |
10.0.2 | 1,160 | 12/26/2017 |
10.0.1 | 1,238 | 12/18/2017 |
10.0.0 | 1,049 | 12/18/2017 |
9.3.0 | 1,186 | 12/17/2017 |
9.2.0 | 1,173 | 12/17/2017 |