Coder Social home page Coder Social logo

node-restify-jwt-sample's People

Contributors

dependabot[bot] avatar supermamon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

node-restify-jwt-sample's Issues

Password in token

In case the user sends its password during registration, the register example just adds the password to the base64 token.
I know this is just an example and you don't pretend to provide an introduction to good security practices, but considering that a lot of newbies will just copypasta your code, this point should be at least explained.

const token = jwt.sign(req.body, config.JWT_SECRET)

should become something like :

// Only put the username in the token, please read about JWT
let user = {name: req.body.name}
const token = jwt.sign(user, config.JWT_SECRET)

Any user can access the admin-protected routes

I registered an user with somerandomrole.

image

/api/home works as expected.

image

However, it's allowed to access the admin-protected route /api/admin.

image

The expected result would be {"code":"Forbidden","message":"You don't have sufficient priviledges."}.

Postman can bypass protection and access admin-protected routes

I created a user with Postman and role : test .

Then I made a request with curl:

image

It works as expected: access denied.

Then I made exactly the same request again, with exactly the same token, but with Postman:

image

It bypasses protection and now I can access the admin-protected route with a test role.

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.