Skip to content

You don't need JWT#213

Open
sethherr wants to merge 3 commits intoshieldfy:masterfrom
sethherr:patch-1
Open

You don't need JWT#213
sethherr wants to merge 3 commits intoshieldfy:masterfrom
sethherr:patch-1

Conversation

@sethherr
Copy link

@sethherr sethherr commented Feb 3, 2026

You don't need JWT if you are just authenticating users - just use a bearer token with TLS. Put it in the authorization header or query string.

There are a bunch of people asking in the original issue (#6) "but what should I use instead of JWT?"

The answer is - just a token. If you're using HTTPS, it's secure.

@rdegges wrote a comment that has some additional information but says the important part clearly:

In pretty much every single situation imaginable JWTs are worse than just using a randomly generated API key of some sort (or session ID if we're talking about web apps). There is no benefit to using them, only downsides.

I included a link from another of the comments from the original issue with some additional discussion of alternatives.

Pulled [a link from one of comments](shieldfy#6 (comment)) from the original issue (shieldfy#6).

You don't need JWT if you are just authenticating users - just use TLS.

If you want some other thing from JWT (asymmetric encryption, tamper protection, etc), use [PASETO](https://github.com/paragonie/paseto).
Make alternative suggestions more concise
Copy link
Collaborator

@Maikuolan Maikuolan left a comment

Choose a reason for hiding this comment

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

There's a typo in there (asymetric -> asymmetric) which can just as easily be fixed either before or after merging, so no big deal, but generally, LGTM. 👍

I'm aware I'm submitting this review less than an hour after the pull request was created, so not much time yet for others to be able to comment or review. Accordingly, though approving now, I'll wait a few hours before merging anything, to give others a chance to comment or review according their own viewpoints.

README.md Outdated
## See also:

- [yosriady/api-development-tools](https://github.com/yosriady/api-development-tools) - A collection of useful resources for building RESTful HTTP+JSON APIs.
- You don't need JWT, just use a randomly generated API key. If you need asymetric encryption or tamper prevention [here are some alternatives to JWT](https://kevin.burke.dev/kevin/things-to-use-instead-of-jwt/)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Small typo (asymetric -> asymmetric).

Copy link
Author

Choose a reason for hiding this comment

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

Thanks! Fixed in e208e95

@guest20
Copy link

guest20 commented Feb 3, 2026

I think the JWT recommendations that were there are good, but should be presented in the form of "Don't use JWTs because X, Y, Z, and instead prefer A,B or C. If are stuck with JWTs you do you should..."

Also, you likely want to snip out that line JWT Recommendation at the top of Authentication:

Don't use Basic Auth. Use standard authentication instead ❌(e.g., [JWT](https://jwt.io/)).

@Maikuolan
Copy link
Collaborator

Good points there. I agree, @guest20.

@sethherr
Copy link
Author

sethherr commented Feb 3, 2026

Thanks for the reviews! Removed the line you suggested @guest20 and fixed asymmetric spelling 🙂

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants