| | | 1 | | namespace Elsa.Secrets.Types; |
| | | 2 | | |
| | | 3 | | public class RsaKeySecretTypeProvider : ISecretTypeProvider |
| | | 4 | | { |
| | 62 | 5 | | public SecretTypeDescriptor Descriptor { get; } = new( |
| | 31 | 6 | | SecretTypeNames.RsaKey, |
| | 31 | 7 | | "RSA Key", |
| | 31 | 8 | | "RSA key material stored as encrypted text or referenced from configuration.", |
| | 31 | 9 | | "secret-rsa-key", |
| | 31 | 10 | | [SecretStoreNames.Encrypted, SecretStoreNames.Configuration]); |
| | | 11 | | |
| | 2 | 12 | | public bool Validate(CreateSecretRequest request, out string? error) => ValidatePayload(request.StoreName, request.V |
| | | 13 | | |
| | 0 | 14 | | public bool ValidateRotation(RotateSecretRequest request, string storeName, out string? error) => ValidatePayload(st |
| | | 15 | | |
| | | 16 | | private static bool ValidatePayload(string storeName, string? value, string? configurationKey, out string? error) |
| | | 17 | | { |
| | 2 | 18 | | if (storeName == SecretStoreNames.Encrypted && string.IsNullOrWhiteSpace(value)) |
| | | 19 | | { |
| | 1 | 20 | | error = "RSA key material is required for encrypted secrets."; |
| | 1 | 21 | | return false; |
| | | 22 | | } |
| | | 23 | | |
| | 1 | 24 | | if (storeName == SecretStoreNames.Configuration && string.IsNullOrWhiteSpace(configurationKey)) |
| | | 25 | | { |
| | 1 | 26 | | error = "A configuration key is required for configuration-backed RSA key secrets."; |
| | 1 | 27 | | return false; |
| | | 28 | | } |
| | | 29 | | |
| | 0 | 30 | | error = null; |
| | 0 | 31 | | return true; |
| | | 32 | | } |
| | | 33 | | } |