Skip to content

Commit 66fe3ce

Browse files
authored
Merge pull request #5 from RockSolidKnowledge/rah/add_missing_events
Add IdentityServer events to AdapterFactory
2 parents 10d1bf4 + e739dfd commit 66fe3ce

24 files changed

Lines changed: 560 additions & 29 deletions

azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ variables:
1111
- name: efPackageVersion
1212
value: '2.0.0.0'
1313
- name: identityPackageVersion
14-
value: '2.0.0.0'
14+
value: '3.0.0.0'
1515
- name: RunSqlServerTest
1616
value: 'true'
1717
stages:

src/RSK.IdentityServer4.AuditEventSink/Adapters/GrantsRevokedEventAdapter.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public GrantsRevokedEventAdapter(GrantsRevokedEvent evt)
1212
{
1313
this.evt = evt ?? throw new ArgumentNullException(nameof(evt));
1414
}
15+
1516
public ResourceActor Actor => new ResourceActor(ResourceActor.UserSubjectType, evt.SubjectId, evt.SubjectId);
1617
public string Action => evt.Name;
1718
public AuditableResource Resource => new AuditableResource("Client", evt.ClientId);

src/RSK.IdentityServer4.AuditEventSink/Adapters/UserLoginSuccessEventAdapter.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,8 @@ public UserLoginSuccessEventAdapter(UserLoginSuccessEvent evt)
1414
}
1515

1616
public ResourceActor Actor => new ResourceActor(ResourceActor.UserSubjectType, evt.SubjectId, evt.DisplayName);
17-
1817
public string Action => evt.Name;
19-
2018
public AuditableResource Resource => new AuditableResource("IdentityServer", evt.Endpoint);
21-
2219
public FormattedString Description => evt.ToString().SafeForFormatted();
2320
}
2421
}

src/Rsk.Audit.EF/Rsk.Audit.EF.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<Description>Provides audting API to record audit records and query api to find audit records with EntityFramework Core</Description>
88
<PackageProjectUrl>https://www.identityserver.com/products/adminui</PackageProjectUrl>
99
<PackageReleaseNotes>https://www.identityserver.com/downloads/adminui</PackageReleaseNotes>
10-
<Copyright>Copyright 2021 (c) Rock Solid Knowledge Ltd. All rights reserved.</Copyright>
10+
<Copyright>Copyright 2022 (c) Rock Solid Knowledge Ltd. All rights reserved.</Copyright>
1111
<PackageTags>Audit AdminUI IdentityServer EntityFramework</PackageTags>
1212
<IncludeSymbols>true</IncludeSymbols>
1313
<GenerateDocumentationFile>true</GenerateDocumentationFile>

src/Rsk.Audit/Rsk.Audit.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<Description>Provides audting API to record audit records and query api to find audit records</Description>
99
<PackageProjectUrl>https://www.identityserver.com/products/adminui</PackageProjectUrl>
1010
<PackageReleaseNotes>https://www.identityserver.com/downloads/adminui</PackageReleaseNotes>
11-
<Copyright>Copyright 2021 (c) Rock Solid Knowledge Ltd. All rights reserved.</Copyright>
11+
<Copyright>Copyright 2022 (c) Rock Solid Knowledge Ltd. All rights reserved.</Copyright>
1212
<PackageTags>Audit AdminUI IdentityServer</PackageTags>
1313
<IncludeSymbols>true</IncludeSymbols>
1414
<GenerateDocumentationFile>true</GenerateDocumentationFile>

src/Rsk.DuendeIdentityServer.AuditEventSink/AdapterFactory.cs

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,50 @@ public IAuditEventArguments Create(Event evt)
1212
{
1313
switch (evt)
1414
{
15-
case TokenIssuedSuccessEvent tokenIssuedSuccessEvent:
16-
return new TokenIssuedSuccessEventAdapter(tokenIssuedSuccessEvent);
17-
case UserLoginSuccessEvent userLoginSuccess:
18-
return new UserLoginSuccessEventAdapter(userLoginSuccess);
19-
case UserLoginFailureEvent userLoginFailure:
20-
return new UserLoginFailureEventAdapter(userLoginFailure);
21-
case UserLogoutSuccessEvent userLogoutSuccess:
22-
return new UserLogoutSuccessEventAdapter(userLogoutSuccess);
23-
case ConsentGrantedEvent consentGranted:
24-
return new ConsentGrantedEventAdapter(consentGranted);
25-
case ConsentDeniedEvent consentDenied:
26-
return new ConsentDeniedEventAdapter(consentDenied);
27-
case TokenIssuedFailureEvent tokenIssuedFailure:
28-
return new TokenIssuedFailureEventAdapter(tokenIssuedFailure);
29-
case GrantsRevokedEvent grantsRevoked:
30-
return new GrantsRevokedEventAdapter(grantsRevoked);
15+
case TokenIssuedSuccessEvent e:
16+
return new TokenIssuedSuccessEventAdapter(e);
17+
case UserLoginSuccessEvent e:
18+
return new UserLoginSuccessEventAdapter(e);
19+
case UserLoginFailureEvent e:
20+
return new UserLoginFailureEventAdapter(e);
21+
case UserLogoutSuccessEvent e:
22+
return new UserLogoutSuccessEventAdapter(e);
23+
case ConsentGrantedEvent e:
24+
return new ConsentGrantedEventAdapter(e);
25+
case ConsentDeniedEvent e:
26+
return new ConsentDeniedEventAdapter(e);
27+
case TokenIssuedFailureEvent e:
28+
return new TokenIssuedFailureEventAdapter(e);
29+
case GrantsRevokedEvent e:
30+
return new GrantsRevokedEventAdapter(e);
31+
case DeviceAuthorizationFailureEvent e:
32+
return new DeviceAuthorizationFailureEventAdapter(e);
33+
case DeviceAuthorizationSuccessEvent e:
34+
return new DeviceAuthorizationSuccessEventAdapter(e);
35+
case TokenRevokedSuccessEvent e:
36+
return new TokenRevokedSuccessEventAdapter(e);
37+
case InvalidClientConfigurationEvent e:
38+
return new InvalidClientConfigurationEventAdapter(e);
39+
case TokenIntrospectionFailureEvent e:
40+
return new TokenIntrospectionFailureEventAdapter(e);
41+
case TokenIntrospectionSuccessEvent e:
42+
return new TokenIntrospectionSuccessEventAdapter(e);
43+
case ClientAuthenticationFailureEvent e:
44+
return new ClientAuthenticationFailureEventAdapter(e);
45+
case ClientAuthenticationSuccessEvent e:
46+
return new ClientAuthenticationSuccessEventAdapter(e);
47+
case ApiAuthenticationFailureEvent e:
48+
return new ApiAuthenticationFailureEventAdapter(e);
49+
case ApiAuthenticationSuccessEvent e:
50+
return new ApiAuthenticationSuccessEventAdapter(e);
51+
case UnhandledExceptionEvent e:
52+
return new UnhandledExceptionEventAdapter(e);
53+
case BackchannelAuthenticationSuccessEvent e:
54+
return new BackchannelAuthenticationSuccessEventAdapter(e);
55+
case BackchannelAuthenticationFailureEvent e:
56+
return new BackchannelAuthenticationFailureEventAdapter(e);
57+
case InvalidIdentityProviderConfiguration e:
58+
return new InvalidIdentityProviderConfigurationAdapter(e);
3159
}
3260
}
3361

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System;
2+
using Duende.IdentityServer.Events;
3+
using RSK.Audit;
4+
5+
namespace Rsk.DuendeIdentityServer.AuditEventSink.Adapters
6+
{
7+
public class ApiAuthenticationFailureEventAdapter : IAuditEventArguments
8+
{
9+
private readonly ApiAuthenticationFailureEvent evt;
10+
11+
public ApiAuthenticationFailureEventAdapter(ApiAuthenticationFailureEvent evt)
12+
{
13+
this.evt = evt ?? throw new ArgumentNullException(nameof(evt));
14+
}
15+
16+
public ResourceActor Actor => new ResourceActor(ResourceActor.MachineSubjectType, null, null);
17+
public string Action => evt.Name;
18+
public AuditableResource Resource => new AuditableResource("IdentityServer", evt.ApiName);
19+
public FormattedString Description => evt.ToString().SafeForFormatted();
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System;
2+
using Duende.IdentityServer.Events;
3+
using RSK.Audit;
4+
5+
namespace Rsk.DuendeIdentityServer.AuditEventSink.Adapters
6+
{
7+
public class ApiAuthenticationSuccessEventAdapter : IAuditEventArguments
8+
{
9+
private readonly ApiAuthenticationSuccessEvent evt;
10+
11+
public ApiAuthenticationSuccessEventAdapter(ApiAuthenticationSuccessEvent evt)
12+
{
13+
this.evt = evt ?? throw new ArgumentNullException(nameof(evt));
14+
}
15+
16+
public ResourceActor Actor => new ResourceActor(ResourceActor.MachineSubjectType, null, null);
17+
public string Action => evt.Name;
18+
public AuditableResource Resource => new AuditableResource("IdentityServer", evt.ApiName);
19+
public FormattedString Description => evt.ToString().SafeForFormatted();
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System;
2+
using Duende.IdentityServer.Events;
3+
using RSK.Audit;
4+
5+
namespace Rsk.DuendeIdentityServer.AuditEventSink.Adapters
6+
{
7+
public class BackchannelAuthenticationFailureEventAdapter : IAuditEventArguments
8+
{
9+
private readonly BackchannelAuthenticationFailureEvent evt;
10+
11+
public BackchannelAuthenticationFailureEventAdapter(BackchannelAuthenticationFailureEvent evt)
12+
{
13+
this.evt = evt ?? throw new ArgumentNullException(nameof(evt));
14+
}
15+
16+
public ResourceActor Actor => new ResourceActor(ResourceActor.MachineSubjectType, evt.ClientId, evt.ClientName);
17+
public string Action => evt.Name;
18+
public AuditableResource Resource => new AuditableResource("IdentityServer", evt.Endpoint);
19+
public FormattedString Description => evt.ToString().SafeForFormatted();
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System;
2+
using Duende.IdentityServer.Events;
3+
using RSK.Audit;
4+
5+
namespace Rsk.DuendeIdentityServer.AuditEventSink.Adapters
6+
{
7+
public class BackchannelAuthenticationSuccessEventAdapter : IAuditEventArguments
8+
{
9+
private readonly BackchannelAuthenticationSuccessEvent evt;
10+
11+
public BackchannelAuthenticationSuccessEventAdapter(BackchannelAuthenticationSuccessEvent evt)
12+
{
13+
this.evt = evt ?? throw new ArgumentNullException(nameof(evt));
14+
}
15+
16+
public ResourceActor Actor => new ResourceActor(ResourceActor.MachineSubjectType, evt.ClientId, evt.ClientName);
17+
public string Action => evt.Name;
18+
public AuditableResource Resource => new AuditableResource("IdentityServer", evt.Endpoint);
19+
public FormattedString Description => evt.ToString().SafeForFormatted();
20+
}
21+
}

0 commit comments

Comments
 (0)