Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added query param support and validation for export request. #438

Merged
merged 12 commits into from
May 14, 2019

Conversation

namadabu
Copy link
Contributor

@namadabu namadabu commented Apr 30, 2019

Description

Added query param support and validation for export request. We support (and require) _destinationType and _destinationConnectionSettings. Added a new ISecretStore and corresponding Azure KeyVault based implementation to store this information.

Related issues

Addresses [issue AB#68715].

Testing

Existing and new UTs, E2E tests. Used KeyVault deployed to Azure to test confirm whether secrets are being stored.

…he code and added corresponding UTs and E2E tests. Added ISecretStore and corresponding Azure KeyVault based implementation.
@namadabu namadabu force-pushed the personal/namadabu/params-support-for-export branch from 50e66f2 to b86bfff Compare April 30, 2019 22:50
@@ -11,5 +13,10 @@ public class ExportConfiguration
/// Determines whether export is enabled or not.
/// </summary>
public bool Enabled { get; set; }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this needs to be explicit. E.g., if we have an interface and list of providers that implement the interface, then we can query the interface and see what detination it supports and it can be automatically registered through IoC container as opposed to register the code in IoC container and also update the settings to enable it.

{
if (!_exportConfig.Enabled)
{
throw new RequestNotValidException(string.Format(Resources.UnsupportedOperation, OperationsConstants.Export));
}

CreateExportResponse response = await _mediator.ExportAsync(_fhirRequestContextAccessor.FhirRequestContext.Uri);
CreateExportResponse response = await _mediator.ExportAsync(_fhirRequestContextAccessor.FhirRequestContext.Uri, destinationType, destinationConnectionString);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could just be passed in as DestinationInfo?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wanted to keep DestinationInfo usage within Fhir.Core and avoid using it in Fhir.Api. I don't think it makes a huge difference either way.

EnsureArg.IsNotNullOrWhiteSpace(secretName, nameof(secretName));
EnsureArg.IsNotNullOrWhiteSpace(secretValue, nameof(secretValue));

SecretBundle result = await _keyVaultClient.SetSecretAsync(_keyVaultUri.AbsoluteUri, secretName, secretValue);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't have to be now but we should also think about how to clean up these secrets after a while.

EnsureArg.IsNotNull(configuration, nameof(configuration));

var keyVaultConfig = new KeyVaultConfiguration();
configuration.GetSection(KeyVaultConfigurationName).Bind(keyVaultConfig);
Copy link
Contributor

@jackliums jackliums May 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole section could be missing (e.g., KeyVault section is not in the config at all).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some comments here. Also renamed InMemorySecretStore to InMemoryKeyVaultSecretStore and moved it to the Fhir.KeyVault project to make things clearer and avoid semantic confusion.

@@ -25,7 +27,8 @@ public ExportJobRecord(Uri exportRequestUri)
SchemaVersion = 1;
Status = OperationStatus.Queued;
Id = Guid.NewGuid().ToString();
QueuedTime = DateTimeOffset.UtcNow;
SecretName = SecretPrefix + Id;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should think about this a bit more. Currently, I am planing to implement the dedup logic in the stored procedure which means in the case where there is matching job, the existing job will be returned, which would contain a different id than the one generated here (I was also going to move the id generation to the stored procedure).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to change this right now in this PR.

return new SecretWrapper(result.Id, result.Value);
}

public async Task<SecretWrapper> DeleteSecretAsync(string secretName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can add the logic in the worker to delete the secret once the job is finished (completed, failed, or cancelled). It could be best effort type of thing so if it fails, it fails. We can think about a separate process to go and clean up afterwards.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be implemented when actually implementing the task.

@jackliums jackliums merged commit 5b343c4 into master May 14, 2019
@namadabu namadabu deleted the personal/namadabu/params-support-for-export branch July 30, 2019 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants