-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DEV-52] Plugins reloaded: Metrics and Diagnostics support (#42)
Added: new Plugin base class for a simpler implementation with diagnostics and metrics support Added: new SubsystemsPlugin base class for a simpler implementation with diagnostics and metrics support Added: PluginDiagnosticsDataCollector to collect all data diags from the plugins Added: automatic license checking if a licence public key is provided. Fixed: Licence test Changed: IPlugableComponent removing CollectTelemetry method and adding other properties like Name and Version Removed: Serilog dependency
- Loading branch information
1 parent
5e4d327
commit eca0063
Showing
42 changed files
with
1,214 additions
and
680 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 0 additions & 35 deletions
35
src/EventStore.Plugins.Tests/ConfigurationReaderTests/LdapsSettings.cs
This file was deleted.
Oops, something went wrong.
32 changes: 0 additions & 32 deletions
32
src/EventStore.Plugins.Tests/ConfigurationReaderTests/when_reading_valid_configuration.cs
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
src/EventStore.Plugins.Tests/EventStore.Plugins.Tests.csproj
This file was deleted.
Oops, something went wrong.
117 changes: 57 additions & 60 deletions
117
src/EventStore.Plugins/Authentication/AuthenticationRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,69 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Security.Claims; | ||
using System.Security.Cryptography.X509Certificates; | ||
using System.Security.Claims; | ||
|
||
namespace EventStore.Plugins.Authentication { | ||
public abstract class AuthenticationRequest { | ||
/// <summary> | ||
/// The Identifier for the source that this request came from | ||
/// </summary> | ||
public readonly string Id; | ||
namespace EventStore.Plugins.Authentication; | ||
|
||
/// <summary> | ||
/// The name of the principal for the request | ||
/// </summary> | ||
public readonly string Name; | ||
public abstract class AuthenticationRequest { | ||
/// <summary> | ||
/// Whether a valid client certificate was supplied with the request | ||
/// </summary> | ||
public readonly bool HasValidClientCertificate; | ||
|
||
/// <summary> | ||
/// The supplied password for the request | ||
/// </summary> | ||
public readonly string SuppliedPassword; | ||
/// <summary> | ||
/// The Identifier for the source that this request came from | ||
/// </summary> | ||
public readonly string Id; | ||
|
||
/// <summary> | ||
/// Whether or not a valid client certificate was supplied with the request | ||
/// </summary> | ||
public readonly bool HasValidClientCertificate; | ||
/// <summary> | ||
/// The name of the principal for the request | ||
/// </summary> | ||
public readonly string Name; | ||
|
||
/// <summary> | ||
/// All supplied authentication tokens for the request | ||
/// </summary> | ||
public readonly IReadOnlyDictionary<string, string> Tokens; | ||
/// <summary> | ||
/// The supplied password for the request | ||
/// </summary> | ||
public readonly string SuppliedPassword; | ||
|
||
protected AuthenticationRequest(string id, IReadOnlyDictionary<string, string> tokens) { | ||
ArgumentNullException.ThrowIfNull(id); | ||
ArgumentNullException.ThrowIfNull(tokens); | ||
/// <summary> | ||
/// All supplied authentication tokens for the request | ||
/// </summary> | ||
public readonly IReadOnlyDictionary<string, string> Tokens; | ||
|
||
Id = id; | ||
Tokens = tokens; | ||
Name = GetToken("uid"); | ||
SuppliedPassword = GetToken("pwd"); | ||
HasValidClientCertificate = GetToken("client-certificate") != null; | ||
} | ||
protected AuthenticationRequest(string? id, IReadOnlyDictionary<string, string>? tokens) { | ||
ArgumentNullException.ThrowIfNull(id); | ||
ArgumentNullException.ThrowIfNull(tokens); | ||
|
||
/// <summary> | ||
/// Gets the token corresponding to <param name="key" />. | ||
/// </summary> | ||
/// <param name="key"></param> | ||
/// <returns></returns> | ||
public string GetToken(string key) => Tokens.TryGetValue(key, out var token) ? token : null; | ||
Id = id; | ||
Tokens = tokens; | ||
Name = GetToken("uid") ?? ""; | ||
SuppliedPassword = GetToken("pwd") ?? ""; | ||
HasValidClientCertificate = GetToken("client-certificate") != null; | ||
} | ||
|
||
/// <summary> | ||
/// The request is unauthorized | ||
/// </summary> | ||
public abstract void Unauthorized(); | ||
/// <summary> | ||
/// Gets the token corresponding to <param name="key" />. | ||
/// </summary> | ||
/// <param name="key"></param> | ||
/// <returns></returns> | ||
public string? GetToken(string key) => Tokens.GetValueOrDefault(key); | ||
|
||
/// <summary> | ||
/// The request was successfully authenticated | ||
/// </summary> | ||
/// <param name="principal">The <see cref="ClaimsPrincipal" /> of the authenticated request</param> | ||
public abstract void Authenticated(ClaimsPrincipal principal); | ||
/// <summary> | ||
/// The request is unauthorized | ||
/// </summary> | ||
public abstract void Unauthorized(); | ||
|
||
/// <summary> | ||
/// An error occurred during authentication | ||
/// </summary> | ||
public abstract void Error(); | ||
/// <summary> | ||
/// The request was successfully authenticated | ||
/// </summary> | ||
/// <param name="principal">The <see cref="ClaimsPrincipal" /> of the authenticated request</param> | ||
public abstract void Authenticated(ClaimsPrincipal principal); | ||
|
||
/// <summary> | ||
/// The authentication provider is not yet ready to service the request | ||
/// </summary> | ||
public abstract void NotReady(); | ||
} | ||
} | ||
/// <summary> | ||
/// An error occurred during authentication | ||
/// </summary> | ||
public abstract void Error(); | ||
|
||
/// <summary> | ||
/// The authentication provider is not yet ready to service the request | ||
/// </summary> | ||
public abstract void NotReady(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 11 additions & 12 deletions
23
src/EventStore.Plugins/Authentication/IAuthenticationPlugin.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
namespace EventStore.Plugins.Authentication { | ||
public interface IAuthenticationPlugin { | ||
string Name { get; } | ||
string Version { get; } | ||
namespace EventStore.Plugins.Authentication; | ||
|
||
string CommandLineName { get; } | ||
public interface IAuthenticationPlugin { | ||
string Name { get; } | ||
string Version { get; } | ||
string CommandLineName { get; } | ||
|
||
/// <summary> | ||
/// Creates an authentication provider factory for the authentication plugin | ||
/// </summary> | ||
/// <param name="authenticationConfigPath">The path to the configuration file for the authentication plugin</param> | ||
IAuthenticationProviderFactory GetAuthenticationProviderFactory(string authenticationConfigPath); | ||
} | ||
} | ||
/// <summary> | ||
/// Creates an authentication provider factory for the authentication plugin | ||
/// </summary> | ||
/// <param name="authenticationConfigPath">The path to the configuration file for the authentication plugin</param> | ||
IAuthenticationProviderFactory GetAuthenticationProviderFactory(string authenticationConfigPath); | ||
} |
Oops, something went wrong.