data-protection | sample code that builders can use | Cloud Functions library
kandi X-RAY | data-protection Summary
kandi X-RAY | data-protection Summary
This sample code is made available under a modified MIT license. See the LICENSE file.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Imports certificate and certificate chain .
data-protection Key Features
data-protection Examples and Code Snippets
Community Discussions
Trending Discussions on data-protection
QUESTION
I refered to this link for session protection in Asp.Net core app (blazor server):
But after injecting IDataProtector to a component, protect and unprotect methods only get byte[] as parameter, I want to use strings for protect and unprotect methods, like it is showed in above link. what namespaces or packages or any other work is required to enable string protection in this library?
...ANSWER
Answered 2021-May-25 at 07:02I am using Microsoft.AspNetCore.DataProtection namespace in my .netcore3.1 app. I see protector.Protect(), protector.Unprotect() under class DataProtectionCommonExtensions accepting string as parameter.
I referred to this before I came across the documentation mentioned in the OP.
QUESTION
Edit The original question I asked was "JsonSerializer.Serialize throws 'Server failed to authenticate the request.' How can I prevent JsonSerializer from using encryption in unit tests?"
Then I realized I used authentication in the model being serialized. Sorry for the poor question. I edited the question. Perhaps someone will find it useful that I found a strange error message and worked through it.
Original Question: I am moving code from on-prem to Azure. At first I removed encryption that used the on-prem certificate. It's time to put it back, but in the Azure way. I am attempting to protect keys with Azure Key Vault as described in https://docs.microsoft.com/en-us/aspnet/core/security/data-protection/configuration/overview?view=aspnetcore-3.1 To get started I added this to ConfigureServices in Startup.cs:
...ANSWER
Answered 2021-May-23 at 16:44This answer was also helpful.
I solved this by adding this code to the test harness startup
QUESTION
I am storing some data in an external key-value store. This data is used as a cache. Because of the nature of the data we need to encrypt/hash the keys as well as values. We are using DataProtection APIs for the encryption and decryption with the default algorithm (AES-256-CBC). As per my knowledge, the encryption of the same plaintext doesn't give you the same cyphertext in this algorithm, so I can't encrypt the keys because next time I won't have the same encrypted key for lookup.
If we hash the keys (using SHA-256) instead of encrypting it, we can actually solve this problem but in some rare scenarios hashing can cause collisions and in our application, due to the nature of data we can't afford to have even a single collision. Code example:
...ANSWER
Answered 2021-Apr-23 at 08:18I don't know about the size of your data. But you can use hashing in this way to reduce the chances of collisions to 0.
- Hash the original key before storing it to your external store.
- You can tweak the value to be a dictionary of key:value, where key is original key and value is original value.
- Encrypt the value (now a dictionary) before storing it to the store.
- Next time onwards, when you want to do the lookup. First hash the original key and check for the match. If it matches then decrypt the dictionary value and do the lookup of original key in the dictionary. If match then good. If the original key is not found then append the new key and value in this dictionary and then encrypt the whole dictionary again and store it on your store.
This reduces the collision to 0 but this will increase the payload size which may not be desired in your case.
QUESTION
Working on a Teams chatbot (V4/Node) and need to address GDPR.
In short, users of the chatbot need to be able to export or delete their personal data stored by the chatbot. Personal data is any information which is related to an identified or identifiable natural person. So also a user-ID in a state object.
I read a blog about GDPR and bots but this one does not address the Teams channel. And it is about V3
- The personal data given by the user in dialogs (written by me) is the easy part. I will write some dialogs to show and delete them (like Bill does in his answer).
- The content in the actual conversations is part of the Teams platform and will\should be adressed in Teams itself.
The bit I don't know how to address is the data for the bot to actually run (Bot state etc). What if a user needs to delete the fact that he or she participated in a certain conversation. That is probably stored in some state objects (in my case in Blob storage). But which ones?
I would appreciate some ideas\guidance in how to address this.
...ANSWER
Answered 2021-Mar-09 at 15:51Disclaimer: I'm not a GDPR expert but I believe the following to be sufficient.
From a bot standpoint the data stored is the same in Teams channel. You have the conversation state and user state data which is typically (and in most of the examples) set up using Blob storage. I use the conversationState
and userState
nomenclature for these items.
In my use case, I am storing account number in userState
and user name/email in conversationState
. Note that there are other things that the bot stores (particularly in conversationState
I believe) around the state of the dialog and other bot specific things that are rather meaningless generally but I don't know if they would be considered part of GDPR. Regardless we will be wiping these entire objects out.
To do that, I created a dialog to manage the user profile which displays the key information stored (I'm specifically accessing account number, user name, and email) and then prompts the user for if they want to delete the information. It looks like this in nodejs.
QUESTION
We use SendGrid to deliver our emails to our customers. We are implementing a light-weight internal infrastructure to handle GDPR requests from our customers. We would like to know how to forward relevant requests to Sendgrid, as our downstream dependency, to ensure complete deletion of our user information. I noticed from the below link that SendGrid is covered by Twilio's Data Protection Addendum, https://sendgrid.com/resource/general-data-protection-regulation-2/. But I could not find any definitive documentation around API support or actual deletion process with respect to GDPR at Twilio.
If someone could point me to any relevant document or API, it would be helpful.
Thanks, Dheeban
...ANSWER
Answered 2021-Mar-02 at 01:28Twilio developer evangelist here.
I'm afraid there is no API to programmatically delete SendGrid information.
The process to get user data deleted under GDPR is as follows:
Because we retain email message activity for only a short time, most deletion requests are handled through our automatic timeout process; however, if you require an earlier deletion, please reach out to us directly at datasubjectrequests@sendgrid.com. Please include the following information:
- Customer Account ID (or subaccount if applicable)
- Recipient email address to be deleted
To ensure correct and timely processing of your request, please include this information in CSV (comma-separated value) format, or in a spreadsheet with two delineated columns. If you are requesting removal of more than one account, please send multiple requests for deletion in a single spreadsheet or CSV file. Your deletion request will be completed within 7 days.
Submissions in an incorrect format may not be processed correctly, may not be processed promptly, and may get lost.
QUESTION
I have an ASP.NET Core 3.1 application that uses cookie authentication and runs on a web farm. I want the application to share authenticated cookies between web servers. The issue is when I log in on Server A through the load balancer the next ajax request from Server B redirects back to the login page. (Status Code 302, Set-Cookie: .AspNet.SharedCookie=;)
If I log in directly to Server A and navigate pages - it works fine. So my suspicions are that Server B does not validate cookies generated by Server A. Here is configuration of DataProtection:
...ANSWER
Answered 2021-Jan-11 at 07:46I found the root cause of the issue, the problem was not in DataProtection, Authentication or Cookies. The problem was with Session, it used memory to store sessions so other servers (except which created) didn't know anything about the session. So I added storing session in database, like this one:
QUESTION
I'm working on a Visual Studio extension package (VSIX) which needs to connect to a database.
I'd also like to take reasonable precautions security-wise when storing sensitive configuration.
At the moment, I'm using a standard property-grid Options page for my plugin, as described in the introductory documentation for Visual Studio extensions.
...ANSWER
Answered 2020-Aug-25 at 01:16For PasswordPropertyTextAttribute
to be effective, it must be "turned on" by setting its Password
property to true
. If the default constructor is used, the Password
property is false
and the attribute has no effect.
The easiest way to make it work is to add the attribute to the property with the line [PasswordPropertyText(true)]
, instead of [PasswordPropertyText]
, to invoke the appropriate non-default constructor.
Persisted options values can be encrypted by overriding the DialogPage
LoadSettingsFromStorage
, SaveSettingsToStorage
, LoadSettingsFromXml
, and SaveSettingsToXml
methods as described in this answer.
Implementing a custom TypeConverter
to handle the encryption/decryption (similar to this approach) isn't useful because the same TypeConverter
is used for converting to/from string values in the PropertyGrid
and also when persisting the value in the Visual Studio registry or XML exports. So if the converter can handle plain text inputs in the PropertyGrid, it will also generate plain text strings when the object is saved to storage or exported to XML.
QUESTION
I'm using ASP.NET Core 3.1, with some custom logic that reuses ASP.NET Core Identity's UserManager
class. I want to reuse its ability to GenerateUserTokenAsync(...)
, the same type of token also used in e.g. e-mail confirmations. For my application's purpose, I need to know the maximum length for generated tokens.
I've done the following research:
UserManager.GenerateUserTokenAsync(...)
callsGenerateAsync
on the injected providerin my case that is the
...DataProtectorTokenProvider
which will generate tokens like this:
ANSWER
Answered 2020-Jul-10 at 05:31By default DPAPI uses AES-256-CBC as encryption algorithm unless you change it via UseCryptographicAlgorithms. As per default algo, the calculation would go like this for your case:
Since it's AES 256, it would work with 32 bytes block. So with CBC padding, you output becomes ((119/32) + 1) * 32 + 16 (IV) = 144. After base64, it becomes 192.
So, having it 352 brings up the question is the stamp really 36 in your case?
36 characters for the security stamp (string representation of a GUID)
Also, in deployed environment, make sure to store data protection key outside app since each instance of the app service needs to point to the same key.
QUESTION
I want to hash passwords before storing them to the database. There are many samples out there on how to hash passwords, the following C# code from the docs relies on the HMACSHA1 algorithm:
...ANSWER
Answered 2020-Jul-03 at 07:40The output of PBKDF2 can be specified. A PBKDF is a password based key derivation function. Generally those have a key expansion phase that allows the output to be specified.
However, if PBKDF2 is used as password hash rather than for key derivation the size of the configured hash is kept; that provides the maximum security that can be retrieved from the algorithm. In this case that's SHA-1 that generates 160 bits / 20 bytes.
Unless you really need text, the output can be stored as static binary of 20 bytes. In your case you should be storing it as base 64 version of the 20 bytes. That should amount to a fixed 28 bytes: ((20 + 2) / 3) * 4 = 28
to calculate the base 64 expansion. However, your code explicitly specifies the output size to be 256 / 8 = 64
bytes. A quick calculation suggests that it always uses 88 base 64 characters for that size.
Producing 64 bytes while using SHA-1 is not a good setting because it requires the inner function of PBKDF2 to run 4 times, giving you no advantage of running it only once to produce 20 bytes, giving advantage to an attacker. An attacker only has to check the first 20 bytes to make sure a password matches, after all, and for that only one of the four runs is required. The method that PBKDF2 uses to expand the key size over the hash size is really inefficient and may be considered a design flaw.
On the other hand, 10.000 iterations is not very high. You should, for PBKDF2:
- specify the output size of the underlying hash as output size (20 bytes instead of 64 bytes for SHA-1) and
- use a higher number of iterations (limited by how much CPU time you can spend in PBKDF2).
The size of the password doesn't have any influence on the size of the password hash.
Beware that some password hashes on other runtimes create a password hash string themselves, more compatible with crypt
on Unix systems. So they would have a larger output that is not directly compatible.
QUESTION
I am developing an authentication in .Net Core. I have api to create a user with login and password.
I hashed the password, but I don't find any way to compare the hashed password, with the new input of the user.
I used the hash method given by microsoft :
...ANSWER
Answered 2020-Jun-16 at 08:49UserInout : plaintext ==> Send to authentication service,
create account: generate salt, hash given plaintext-password with salt, store in account infos
authenticate: read hash from account info in your database, hash the given plaintext password with the read salt and compare that hash with the hash in your database. That is the simplest way of authentication.
Be sure to always use the individual hash that was created for each account, otherwise the hash will always be different and authentication will fail.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install data-protection
You can use data-protection like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page