Git Product home page Git Product logo

dss_gke's People

Contributors

duluong avatar duluong-dss avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

dss_gke's Issues

How to secure JWT on client side

Ref: https://hasura.io/blog/best-practices-of-using-jwt-with-graphql/

1. Where to save JWT on client side

  • Local storage
    This is prone to XSS attacks.

  • Saving it in a cookie
    Creating cookies on the client to save the JWT will also be prone to XSS. If it can be read on the client from Javascript outside of your app - it can be stolen. You might think an HttpOnly cookie (created by the server instead of the client) will help, but cookies are vulnerable to CSRF attacks. It is important to note that HttpOnly and sensible CORS policies cannot prevent CSRF form-submit attacks and using cookies require a proper CSRF mitigation strategy.

  • In memory
    It is still better option in comparing with 2 above options

2. Note solutions for Saving in memory option

  • Expiry time
    Common practice is to keep it around 15 minutes. And refresh token when it get expired.

  • Silent refresh
    Recommend using this method.
    Server need managing refresh token in their database.
    Client need counting down and call refresh token before JWT get expired.

  • Logout
    Client: Delete JWT in memory
    Server: Revoke and delete refresh token in database

  • Logout for all devices
    Client: Delete JWT in memory (could not delete JWT token in other devices, no way. But they will get expired soon)
    Server: Revoke and delete all refresh tokens belong to the user.

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.