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

Add new module for OrchardCore.KeyVault.Azure #6422

Merged

Conversation

JoshLefebvre
Copy link
Contributor

Based on conversations had in #6359

@JoshLefebvre
Copy link
Contributor Author

If this looks good, I would be happy to add some further documentation on how to use

@deanmarcussen
Copy link
Member

deanmarcussen commented Jun 14, 2020

Looks great, will take a closer look tomorrow if @jtkech doesn't tonight

  • 1 for some docs :)

Copy link
Member

@jtkech jtkech left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM

@JoshLefebvre JoshLefebvre force-pushed the joshlefebvre/addOrchardCore.KeyVault.Azure branch from ee6030f to 584b72b Compare June 15, 2020 01:48
@JoshLefebvre
Copy link
Contributor Author

Thanks @jtkech. Made all above requested changes and added the documentation.

@jtkech
Copy link
Member

jtkech commented Jun 15, 2020

@JoshLefebvre perfect i approved it

Just one last thing, maybe not the right place for the readme as OrchardCore.KeyVault.Azure is not a module but a core library. It does not bother me but i don't often work on documentation, i'm too lazy ;) so we need a confirmation, @agriffard can you confirm?

@deanmarcussen
Copy link
Member

Looks good @JoshLefebvre

I fixed a couple of typos in the docs.

Can you move it to the core section as @jtkech suggested, and also it needs an entry in the mkdocs.yml or it won't display on readthedocs

@xperiandri
Copy link
Contributor

Is it ready to merge?

src/docs/reference/core/KeyVault.Azure/README.md Outdated Show resolved Hide resolved
Output: "OrchardCore:OrchardCore_Shells_Database:ConnectionString".
See https://github.com/OrchardCMS/OrchardCore/issues/6359.

## Configuration
Copy link
Member

Choose a reason for hiding this comment

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

Can we have a small example that uses directly AzureKeyVaultSecretManager such that standard ASP.NET tutorials can be followrd?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean an example of IConfiguration? I have been using it to retrieve my media and database connection strings. For example in DatabaseShellConfigurationSources.cs:
image

Using the following Keys:
OrchardCore--OrchardCore---Shells---Database--ConnectionString
OrchardCore--OrchardCore---Shells---Database--DatabaseProvider (Not actually a secret, but required to get the section)

Copy link
Member

Choose a reason for hiding this comment

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

What Seb was asking for is something that matches the getting started guides from the ASP.NET docs here https://docs.microsoft.com/en-us/aspnet/core/security/key-vault-configuration?view=aspnetcore-3.1

Where they are using the AzureServiceTokenProvider callbacks and such.

Which makes me also wonder if we should not be using the callback technique, rather than having our own configuration secrets for it?

Copy link
Member

Choose a reason for hiding this comment

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

@deanmarcussen

Here @JoshLefebvre just override the DefaultKeyVaultSecretManager with a new AzureKeyVaultSecretManager and provide an AddOrchardCoreAzureKeyVault() extension that uses it and other config values.

But people can just follow the aspnet documentation and then use new AzureKeyVaultSecretManager() in place of new DefaultKeyVaultSecretManager()

So maybe just remove the AddOrchardCoreAzureKeyVault() that is just an example on how to use the new AzureKeyVaultSecretManager and let people follow the doc and do their own extension if they want.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do I understand your implementation right that you have added replacement of --- to _ along with default -- to : behavior?

Copy link
Member

Choose a reason for hiding this comment

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

@xperiandri Exactly, this is what @JoshLefebvre did ;)

Copy link
Member

Choose a reason for hiding this comment

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

Is that something that is common? Either in OC or ASP.NET with Keyvault?

@agriffard agriffard requested a review from deanmarcussen July 3, 2020 09:30
@xperiandri
Copy link
Contributor

Cool, so is only getting started guide left?

@agriffard
Copy link
Member

Please resolve conflict.

@MarcBruins
Copy link

The preferred way of communicating with the Azure Keyvault for a web app is through Managed identity rather then a service principal with a object id and password. Can we make sure that that scenario is also supported? I can work on this if you like

@Skrypt
Copy link
Contributor

Skrypt commented Aug 27, 2020

@MarcBruins I think that ultimately we should have an external OC Management tool that could be deployed as an Azure Function that would allow to configure all things related with the Azure Portal services. Here, what I don't like is the fact that OC configures it's own Azure Services. This can easily lead to security issues.

Also, I think that it could be a good way to start experiment things with the new Azure SDK.

@agriffard
Copy link
Member

Can you please fix the conflicts @JoshLefebvre?

@JoshLefebvre
Copy link
Contributor Author

@agriffard yes sorry for the hiatus. I have a lot more free time now and hope to actively start contributing to this project again. I will try to get this done today

@JoshLefebvre JoshLefebvre force-pushed the joshlefebvre/addOrchardCore.KeyVault.Azure branch from 4a975dd to f025cdf Compare December 9, 2020 23:31
@JoshLefebvre JoshLefebvre force-pushed the joshlefebvre/addOrchardCore.KeyVault.Azure branch from f025cdf to 837691f Compare December 10, 2020 00:23
@JoshLefebvre JoshLefebvre force-pushed the joshlefebvre/addOrchardCore.KeyVault.Azure branch from 69d8b99 to 8538dc3 Compare December 10, 2020 00:44
@JoshLefebvre
Copy link
Contributor Author

JoshLefebvre commented Dec 10, 2020

@deanmarcussen @agriffard so I've updated the Key Vault package to make use of the new Azure SDK package Azure.Extensions.AspNetCore.Configuration.Secrets to connect to keyvault. I have also added the Azure.Identity package which is now the recommended way to authenticate with Azure resources via Active Directory token authentication and should resolve the issues people were mentioning above .

Azure Identity supports:

  • Service principal authentication
  • Managed identity authentication
  • User principal authentication

@agriffard
Copy link
Member

Can you please review it @deanmarcussen ?

@deanmarcussen
Copy link
Member

Great, thanks for updating this @JoshLefebvre - they've definitely improved the libraries a lot since moving to the new Azure packages.

Couple of thoughts, and I will bring @jtkech in here as well, as he may agree / disagree

Because this is a program level configuration, I don't think it should be using the OrchardCore appsettings section. That would suggest it is configurable at a tenant level, but as it is wholly for the host, it isn't tenant configurable. (please correct me if I'm wrong)

I'm also thinking it's not a module. Because we can't load it modularly, for the same reasons.

Which makes it more like the Shells.Azure configuration, which we did as a seperate nuget package, as part of the OrchardCore folder, rather than as part of modules.

Lastly we need to pick a name. Because it's KeyVault Configuration - rather than KeyVault itself, which would have a read/write option, and we might be using it for read / write (i.e. it'd be good to do a Shells.KeyVault version at some point with read/write, and I'm hoping to do a Secrets KeyVault provider for the Secrets module #7891, again for read/write). Both of those might connection to a different KeyVault - in the case of secrets, it might be a different vault for each tenant (as an option).

Azure have called it Azure.Extensions.AspNetCore.Configuration.Secrets - which is not helpful ;)

Would OrchardCore.Configuration.KeyVault be a good name?
or
OrchardCore.Configuration.Azure (I prefer KeyVault as it seems explicit and more obvious, but naming is hard)

@jtkech
Copy link
Member

jtkech commented Dec 13, 2020

@deanmarcussen okay i will take a look on it this night

@jtkech
Copy link
Member

jtkech commented Dec 13, 2020

@deanmarcussen

Yes i agree, didn't see it was under the OC.Modules folder, need to be under the OrchardCore folder.

Then yes, good to have custom config / settings sources for all tenants and tenant specific, as we did from blob and database, but yes in a separate PR. So we already have OrchardCore_Shells_Azure, maybe rename it to OrchardCore_Shells_Azure_Blob so that we will be able to use OrchardCore_Shells_Azure_KeyVault. But that's okay to keep OrchardCore_Shells_Azure and then use OrchardCore_Shells_KeyVault ;)

Meanwhile for this PR, idem here i would suggest OrchardCore.Configuration.Azure.KeyVault, but maybe too long, in our solution there is no project with more than 3 terms, so i also suggest OrchardCore.Configuration.KeyVault.

@agriffard
Copy link
Member

Please merge dev and solve appsettings.json conflict.

@deanmarcussen
Copy link
Member

@JoshLefebvre sounds like @jtkech and I agree on the name, and to move it out of modules.

I don't think it should be using the OrchardCore appsettings section

I withdraw my comment here, we already hosted the shells settings under OrchardCore so for consistency lets keep that the same. Even if it is only host only, not tenant based.

So just to move the folder, and rename thank you

@jtkech
Copy link
Member

jtkech commented Dec 17, 2020

I agree

@JoshLefebvre
Copy link
Contributor Author

Thanks @jtkech and @deanmarcussen. Yes agreed, makes much more sense in the OrchardCore module now that you explain it. I've also updated the name to OrchardCore.Configuration.KeyVault as suggested :)

@JoshLefebvre JoshLefebvre force-pushed the joshlefebvre/addOrchardCore.KeyVault.Azure branch from fbef147 to 56abadf Compare December 18, 2020 04:16
@agriffard agriffard closed this Dec 19, 2020
@agriffard
Copy link
Member

Build retry

@agriffard agriffard reopened this Dec 19, 2020
@agriffard agriffard requested a review from jtkech December 19, 2020 10:39
@jtkech
Copy link
Member

jtkech commented Dec 19, 2020

LGTM

@agriffard agriffard merged commit 0120108 into OrchardCMS:dev Dec 19, 2020
@agriffard
Copy link
Member

Thank you. 163rd project in the solution.

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.

10 participants