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

Removed the long-lived JWT token in favor of new middleware #11024

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

uberbrady
Copy link
Collaborator

This resolves a potential security issue with overly-long-lived temporary cookie-based API tokens.

Since this messes around with auth, we should test it much more thoroughly than I have. We should test that API routes still work with API keys, and that API routes also work with regular Laravel session tokens. We will need to be extra careful to blow out any cookies we might have, as those are still valid tokens.

The approach originally was that I wanted to make a generic 'any' Middleware which could take a comma-separated list of other middleware names, and if any of them pass, then the middleware continues. That didn't work because I couldn't get the middleware resolver to work quite right.

So I backed off and instead hardcoded the two middlewares that we wanted 'any' of - 'auth' and 'auth:api'. It seems to work fine like that.

As a couple of fun side effects - we will end up sending fewer cookies with much less bytes this way. Helps to save the environment! :) And it's much easier to open up an API endpoint in your browser - so long as you're logged in, you see the JSON output right there and most browsers will 'pretty-print' it for you.

@uberbrady uberbrady requested a review from snipe as a code owner May 6, 2022 08:42
Copy link
Collaborator Author

@uberbrady uberbrady left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<comment deleted>

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

Successfully merging this pull request may close these issues.

1 participant