Skip to content

Updates the salt hashing example in passwordhasher.cs for dotnet 6#26233

Merged
Rick-Anderson merged 3 commits into
dotnet:mainfrom
viniciusmorgado:update-hashing-example-dotnet6
Jun 29, 2022
Merged

Updates the salt hashing example in passwordhasher.cs for dotnet 6#26233
Rick-Anderson merged 3 commits into
dotnet:mainfrom
viniciusmorgado:update-hashing-example-dotnet6

Conversation

@viniciusmorgado
Copy link
Copy Markdown
Contributor

Updates the salt hashing example in passwordhasher.cs for dotnet 6 using RandomNumberGenerator instead RNGCryptoServiceProvider (outdated).

…ing RandomNumberGenerator instead RNGCryptoServiceProvider (outdated)
@guardrex
Copy link
Copy Markdown
Collaborator

guardrex commented Jun 26, 2022

Hello @viniciusmorgado ... Thanks for sending this in.

This change must be versioned, so inside this folder ...

https://github.com/dotnet/AspNetCore.Docs/tree/main/aspnetcore/security/data-protection/consumer-apis/password-hashing/samples

... create 5.x and 6.x folders. Leave the existing file as it is and place it in the 5.x folder. Make your changes to a copy of the file and place it into the 6.x folder. In the article at ...

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/security/data-protection/consumer-apis/password-hashing.md

... structure the markdown for Lines 22-24 like this (and I'm adding in a little INCLUDE that we use now for reference source to help devs find the right version of ref source code) ...

:::moniker range=">= aspnetcore-6.0"

[!code-csharp[](password-hashing/samples/6.x/passwordhasher.cs)]

:::moniker-end

:::moniker range="< aspnetcore-6.0"

[!code-csharp[](password-hashing/samples/5.x/passwordhasher.cs)]

:::moniker-end

See the [source code](https://github.com/dotnet/AspNetCore/blob/main/src/Identity/Extensions.Core/src/PasswordHasher.cs) for ASP.NET Core Identity's `PasswordHasher` type for a real-world use case.

[!INCLUDE[](~/includes/aspnetcore-repo-ref-source-links.md)]

However, you might need to duplicate all of the content in the article if this change requires some or all of the earlier content (the paragraphs above the code link prior to Line 22) to change (i.e., the existing content is incorrect for 6.0 or later and/or the guidance needs to call out what's going on with the RandomNumberGenerator use). If that's the case, ping me back here, and I'll give you a new content versioning plan for the article.

@guardrex guardrex self-assigned this Jun 26, 2022
@guardrex
Copy link
Copy Markdown
Collaborator

guardrex commented Jun 26, 2022

One more little thing ... GH prefers an LF at the ends of files ...

image

... so for the last line of passwordhasher.cs, tap the enter/return key to get on a new line. You'll see the warning indicator on the diff go away after you make that change to the file.

@guardrex
Copy link
Copy Markdown
Collaborator

guardrex commented Jun 27, 2022

@viniciusmorgado ... I'd prefer not to submit a commit to your PR to resolve this (I'm OOF until Friday); so if you feel like you'd like to leave the versioning updates to the team, then we'll either ping one of the other doc authors to commit to your branch or they'll close this and submit a new PR with all of the updates. Let me know how you would like to proceed. 👂

Comment on lines +32 to +34
* Salt: SqSBFnfUBCRpH/yd9soRDQ==
* Hashed: rWc4HTeqV7SA5eGWUEx7t4n5N8gyHgB4sVLTxtpsZNc=
*/ No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sample output shouldn't be changed.

@Rick-Anderson
Copy link
Copy Markdown
Contributor

@viniciusmorgado @guardrex I'll get this cleaned up.

@Rick-Anderson Rick-Anderson self-assigned this Jun 27, 2022
@guardrex
Copy link
Copy Markdown
Collaborator

Thx @Rick-Anderson 🍻!

@guardrex guardrex removed their assignment Jun 27, 2022
@dnfadmin
Copy link
Copy Markdown

dnfadmin commented Jun 28, 2022

CLA assistant check
All CLA requirements met.

@viniciusmorgado
Copy link
Copy Markdown
Contributor Author

viniciusmorgado commented Jun 28, 2022

@viniciusmorgado ... I'd prefer not to submit a commit to your PR to resolve this (I'm OOF until Friday); so if you feel like you'd like to leave the versioning updates to the team, then we'll either ping one of the other doc authors to commit to your branch or they'll close this and submit a new PR with all of the updates. Let me know how you would like to proceed. 👂

Thanks @guardrex

Hi @Rick-Anderson, I commit an update with the versioning of the passwordhasher.cs file, for the update of the content in password-hashing.md I need to duplicate all the content in the article, should I versioning the file as well? And can the file be versioned directly on aspnetcore\security\data-protection\consumer-apis? with two folders 5.x and 6.x as the passwordhasher.cs?

Edit1: Sorry I don´t answer @guardrex question, If someone on the team wants to close this request and submit a new PR with all of the updates it ´s ok to me.

@Rick-Anderson Rick-Anderson merged commit 2fa6861 into dotnet:main Jun 29, 2022
@Rick-Anderson
Copy link
Copy Markdown
Contributor

Thanks for the contribution. Be sure to check out your name as a contributor about the 3rd of next month on the What's new page in the Community contributors section at the bottom.

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.

4 participants