Manage Secrets in DotNet 6

  Рет қаралды 5,898

Data Vids (Data Vids)

Data Vids (Data Vids)

Күн бұрын

Пікірлер: 12
@LindenMikus
@LindenMikus 2 жыл бұрын
Thanks for the vid! How would you deploy this sort of thing to production though? (say you just have an install folder with dlls and executables)
@torreygarland14
@torreygarland14 2 жыл бұрын
Environment variables or azure vaults?
@DataVids
@DataVids 2 жыл бұрын
Microsoft recommends that we use the Azure Key Vault for production (as opposed to just using the secret manager on the server under the user profile that the app pool is running, for example...) Here is the doc: docs.microsoft.com/en-us/aspnet/core/security/key-vault-configuration?view=aspnetcore-6.0 and below is a paste from it (about 3/4 the way down), where it compares dev environment to production: Save the following secrets locally with Secret Manager: .NET CLI **this is dev Copy dotnet user-secrets set "5000-AppSecret" "5.0.0.0_secret_value_dev" dotnet user-secrets set "5100-AppSecret" "5.1.0.0_secret_value_dev" Secrets are saved in Azure Key Vault using the following Azure CLI commands: Azure CLI **this is prod Copy az keyvault secret set --vault-name {KEY VAULT NAME} --name "5000-AppSecret" --value "5.0.0.0_secret_value_prod" az keyvault secret set --vault-name {KEY VAULT NAME} --name "5100-AppSecret" --value "5.1.0.0_secret_value
@a-videoo
@a-videoo Жыл бұрын
Thank you for this. So much of the available documentation seems to be written for .net 5 where you have a Startup.cs etc.
@JayJay-nb1sv
@JayJay-nb1sv 2 жыл бұрын
So after you retrieve the password and store it in secretVar, how would you make it available outside of program.cs?
@DataVids
@DataVids 2 жыл бұрын
Hi @JayJay great question! I actually just did this the other day when trying a sample of the StripeAPI for payments. 1) I created my secrets using powershell (set, etc..) , 2) created a class with variables to match the fields in my secrets, 3) I added to my program.cs so it could be injected later into my controllers and services like this: services.Configure(configuration); (StripeOptions was the class I made with properties matching the secrets set in powershell...), then 4) I injected the secrets configuration which is now loaded into a class from the secrets, INTO my service (which you could do directly into a controller if you wanted to instead of a service, the same way), note the context below is unrelated, it just happens to be another thing I needed to inject to the same method at the same time..: public PaymentService(DataContext context, IOptions stripeOptionsAccessor) { _context = context; _stripeOptions = stripeOptionsAccessor.Value; } Hope that helps! Have a great day.
@gammarage9356
@gammarage9356 2 жыл бұрын
@@DataVids I'm confused. Isn't the video so you can use api keys/secrets in your controller or services? So in the video secrets cannot be used outside of program.cs?
@muttBunch
@muttBunch Жыл бұрын
Thank you for the lesson on this but what I am trying to do is, what if you wanted to makes changes and save to usersecrets.json. For example, a configuration UI that I built in Web API, where the customer can set their own SQL connection parameters for: SQL Server, Database Name, Authentication Type, SQL User, SQL Pass and when they hit save, save the connection string into usersecrets.json. I have it working for saving the customer input fields to appsettings.json but can I do something similar to usersecrets.json? Thanks :D
@jamaicantillidie6626
@jamaicantillidie6626 2 жыл бұрын
Since the secrets are stored on your local machine how do you handle releases?
@DataVids
@DataVids 2 жыл бұрын
In production they can be environment variables that load from a appsettings.Production.json file - I would assume that your production server is in a secure vnet for example, unlike your dev machine most likely. Using secrets on your dev machine keeps them from accidental commit to GIT too. Another popular solution is an Azure Key Vault, but that is not free.
@PIMARINE
@PIMARINE 2 жыл бұрын
Dude, I missed Your voice. Aloha.
@DataVids
@DataVids 2 жыл бұрын
Aloha! My voice was a little scratchy in this one, but if I waited until I didn't have cold or whatever, probably miss a lot of good video windows ;) Good to hear from you though, hope you are well!
How To Keep SECRET Strings REALLY SECRET in ASP.NET Core?
16:32
Codewrinkles
Рет қаралды 10 М.
Accessing AppSettings in Console Apps Including Secrets.json
23:53
人是不能做到吗?#火影忍者 #家人  #佐助
00:20
火影忍者一家
Рет қаралды 20 МЛН
VIP ACCESS
00:47
Natan por Aí
Рет қаралды 30 МЛН
Don’t Choose The Wrong Box 😱
00:41
Topper Guild
Рет қаралды 62 МЛН
“Don’t stop the chances.”
00:44
ISSEI / いっせい
Рет қаралды 62 МЛН
Coding Shorts: Stop Leaking Secrets in ASP.NET Core
14:19
Shawn Wildermuth
Рет қаралды 7 М.
10 Signs Your Software Project Is Heading For FAILURE
17:59
Continuous Delivery
Рет қаралды 33 М.
Managing Secrets in Code with Hashicorp Vault
41:33
PowerShell.org
Рет қаралды 2,4 М.
Compare or Sort any Object (using IComparable or IEquatable) .Net
19:23
Data Vids (Data Vids)
Рет қаралды 4,9 М.
Dockerize .NET 6 in 10 Minutes
13:33
Wes Doyle
Рет қаралды 153 М.
Manage your Cloud Run secrets securely with Secret Manager
6:38
Google Cloud Tech
Рет қаралды 34 М.
Managing User Secrets
22:01
Microsoft Visual Studio
Рет қаралды 31 М.
人是不能做到吗?#火影忍者 #家人  #佐助
00:20
火影忍者一家
Рет қаралды 20 МЛН