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 support for encrypted cookies #93

Closed
wants to merge 2 commits into from

Conversation

FadhiliNjagi
Copy link

I'm proposing support for encrypted cookies in Express. I followed an approach similar to the cookie signing code. I created the package symmetric-cipher.js which has the encrypt and decrypt functionality. It uses symmetric encryption ('AES-256-CBC') and creates a sha256 hash of the key if the key length is not 32 bytes (256 bits). Encrypted cookies are also signed, to prevent wasting computing resources on a decryption attempt if the cookie has been tampered with. Encryption happens on top of JSON serialisation for JSON cookies so they should decrypt back to j:. I have opened a PR to add encrypted cookie support to the main express library.

I have also added the secretEncosing option so secrets can be used for encryption in encoding schemes like 'base64' and 'hex'. Since [email protected] only accepts UTF8 strings, the signing and unsigning is done using the secret as a UTF string, and then encryption and decryption use the specified encoding.

@FadhiliNjagi
Copy link
Author

Related to this issue

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.

1 participant