I am currently building an application where each user has an unique key stored in the users' session storage. This key is used to decrypt the users data in the database. Since the repository layer of the application handles database queries (using Dapper) I would like the decryption to take place there.
Now the problem: I can retrieve the users key from the session storage, pass it to the controller, then to the service then to the repository using a parameter of name "key" in each method that is chained. Is there a way to pass a key from the controller through to the repository layer without having to include the key manually in every call?
If there is a better solution than to store it in session storage I am open to it, if it is going to make this easier.
The encryption system I am following is as follows (from another SO answer):
