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

Token is not invalidated #7236

Open
awkward-minion opened this issue May 4, 2024 · 1 comment
Open

Token is not invalidated #7236

awkward-minion opened this issue May 4, 2024 · 1 comment

Comments

@awkward-minion
Copy link

Bug report

The JWT token is not being invalidated

Describe the bug

The request to protected resources must not be allowed when JWT token is invalidated.

The token invalidation can be done using either of the following ways

  1. curl curl -X DELETE '{backend_url}/store/auth' -H 'Authorization: Bearer {access_token}'
  2. medusa client client.auth.deleteSession()

System information

Medusa version (including plugins):

  1. @medusajs/medusa": "^1.20.4"
  2. @medusajs/medusa-js": "^6.1.8"
    Node.js version: v20.11.0
    Database: postgres
    Operating system: MacOS Ventura
    Browser (if relevant): -

Steps to reproduce the behavior

Pre-reqs: Medusa is installed and configured properly with a database.

  1. Login into app as customer

       curl -X POST '{backend_url}/store/auth' \
       -H 'Content-Type: application/json' \
       --data-raw '{
          "email": "[email protected]",
          "password": "supersecret"
       }'
  2. Logout customer

    curl -X DELETE '{backend_url}/store/auth' \
    -H 'Authorization: Bearer {access_token}'
  3. Try to retrieve the customer details

    curl '{backend_url}/store/auth' \
    -H 'Authorization: Bearer {access_token}'

    This should fail as the token was invalidated in step: 2

Expected behavior

As the token is invalidated, the sub sequent requests to protected entity must throw 401 error.

Screenshots

NA

Code snippets

NA

Additional context

401 is thrown in one case, i.e, when the Authorization header is not present.

@adevinwild
Copy link
Contributor

adevinwild commented May 11, 2024

I think it's the intended behavior based on the description property here :
https://github.com/medusajs/medusa/blob/v1.20.6/packages/medusa/src/api/routes/admin/auth/delete-session.ts

You'll probably have to handle this one yourself

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants