Coder Social home page Coder Social logo

Add cookie protection about cookies HOT 8 CLOSED

samdark avatar samdark commented on June 12, 2024
Add cookie protection

from cookies.

Comments (8)

armpogart avatar armpogart commented on June 12, 2024

Would you accept PR for PSR-15 cookie encryption middleware? I have a baked solution for our project already on yii3.

from cookies.

samdark avatar samdark commented on June 12, 2024

Encryption isn't the same as MAC-signing. What's the use case for encrypting a cookie?

from cookies.

armpogart avatar armpogart commented on June 12, 2024

Yep, it's true. But they are two things that are sometimes used exclusively for the same purpose, or even as a best practice used both together. Encryption is used when you have somewhat sensitive data you need to store in cookies (by saying somewhat I mean the data that is still ok to store in cookies as really sensitive data must not be stored in cookies). Also encryption of cookies can be sometimes be used as an alternative of signing, as the data will be malformed if somebody tampers it on client side. But ideally they are used together first the data is encrypted and then the data is signed. Cookie encryption middleware can also have a key exclusion map, to define the keys to be excluded during encryption, so that they are available unencrypted on client side while still having other more sensitive values encrypted.

As they are very similar in purpose and functionally, I will be happy to implement both cookie signing and encryption PSR-15 middlewares and try to document their usage (right order).

from cookies.

samdark avatar samdark commented on June 12, 2024

OK.

from cookies.

samdark avatar samdark commented on June 12, 2024

Discussed internally. Decided not to have both HMAC signing (usually it's fine just to set HttpOnly) and encryption (usually it results in storing too much in the cookies and transferring too much each request of each image, CSS or JS). At least initially.

from cookies.

samdark avatar samdark commented on June 12, 2024

Reopened because of yiisoft/user#30

from cookies.

samdark avatar samdark commented on June 12, 2024

Need to consider having a middleware for signing/verifying and encrypting/decrypting cookies.

from cookies.

samdark avatar samdark commented on June 12, 2024

Implemented.

from cookies.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.