Wilsonator123 / Secure-Blog-Page

DSS Projecy
1 stars 0 forks source link

Router with cookies #56

Closed Wilsonator123 closed 5 months ago

Wilsonator123 commented 6 months ago

Created a middleware in ./client and routes for checking permissions

The thought process:

  1. User Requests Page
  2. The middleware checks to see if page requires any permissions e.g. Account Page, Admin Page
  3. If it does the middleware sends a POST request to /auth/hasPermissions with the permissions required in the body
  4. The backend checks the cookie and JWT is valid and whether permission scope was given in the body
  5. The JWT checks whether the user has the required permission
  6. If the permission is present in the JWT return 200 else return 401
  7. The middleware gets the response. If it returns 200, continue, else redirect to /login or /404

I would like opinions on the process and whether there are 'better' ways to approach this

I have yet to test this end-to-end, but have used postman to test the cookies

We also should looke at what permissions are and what we need where (user:logged_in, user:read) etc.

Wilsonator123 commented 6 months ago

resolves #18