Skip to content
All articles
Protocols7 May 2026·3 min read

JWT best practices: A guide to secure authentication

It is easy to read a specification and conclude the problem is solved.

Paycux engineering

It is easy to read a specification and conclude the problem is solved. It is harder to sit with the twenty implementations that each read the same paragraph differently and still call themselves compliant.

This piece walks through how we think about it at Paycux, what we have changed our minds about, and where the sharp edges are.

JWT 101

JWT 101 is where this gets concrete. Normalization is the whole job. Two providers can be perfectly compliant and still disagree about what a group membership is, whether a logout is meaningful, and which attribute carries the email address.

Normalization is the whole job. Two providers can be perfectly compliant and still disagree about what a group membership is, whether a logout is meaningful, and which attribute carries the email address.

Choose the right signing algorithm

That brings us to choose the right signing algorithm. Normalization is the whole job. Two providers can be perfectly compliant and still disagree about what a group membership is, whether a logout is meaningful, and which attribute carries the email address.

Normalization is the whole job. Two providers can be perfectly compliant and still disagree about what a group membership is, whether a logout is meaningful, and which attribute carries the email address.

  • Validate signature, issuer, audience and expiry as four separate checks
  • Normalize provider attributes into one internal shape
  • Fail loudly when a peer stops meeting a documented assumption
  • Keep a fixture per provider so regressions surface in CI

Validate every claim that matters

That brings us to validate every claim that matters. Version the assumption, not just the code. Write down what you expect from the peer, and make the failure loud when it stops being true, because the alternative is a connection that half works for six weeks.

Normalization is the whole job. Two providers can be perfectly compliant and still disagree about what a group membership is, whether a logout is meaningful, and which attribute carries the email address.

Watch out for hostile header parameters

That brings us to watch out for hostile header parameters. Normalization is the whole job. Two providers can be perfectly compliant and still disagree about what a group membership is, whether a logout is meaningful, and which attribute carries the email address.

Normalization is the whole job. Two providers can be perfectly compliant and still disagree about what a group membership is, whether a logout is meaningful, and which attribute carries the email address.

Version the assumption, not just the code.

Prevent cross-JWT confusion

That brings us to prevent cross-jwt confusion. Treat anything the other side sends as untrusted input until it has been through validation you wrote. Signature checks, issuer checks, audience checks and expiry checks are four separate decisions, and skipping any one of them is a real vulnerability rather than a theoretical one.

Version the assumption, not just the code. Write down what you expect from the peer, and make the failure loud when it stops being true, because the alternative is a connection that half works for six weeks.

Keep access tokens short-lived

Keep access tokens short-lived is where this gets concrete. Version the assumption, not just the code. Write down what you expect from the peer, and make the failure loud when it stops being true, because the alternative is a connection that half works for six weeks.

Version the assumption, not just the code. Write down what you expect from the peer, and make the failure loud when it stops being true, because the alternative is a connection that half works for six weeks.

Storing tokens on the client

Storing tokens on the client deserves its own treatment. Treat anything the other side sends as untrusted input until it has been through validation you wrote. Signature checks, issuer checks, audience checks and expiry checks are four separate decisions, and skipping any one of them is a real vulnerability rather than a theoretical one.

Normalization is the whole job. Two providers can be perfectly compliant and still disagree about what a group membership is, whether a logout is meaningful, and which attribute carries the email address.

Where this leaves us

The pattern repeats across every system we have looked at: the hard part is not the mechanism, it is keeping the mechanism honest as the surrounding assumptions change.

If you are working through the same problem and want to compare notes, the docs cover the mechanics and the console shows the behaviour on your own data.

Everything here, already built

Sign-in, enterprise SSO, directory provisioning, roles and an audit trail behind one API. Start with the quickstart and have a working sign-in this afternoon.

Start selling to enterprise customers

Create an account, point sign-in at Paycux, and get back to the part of the product that is actually yours.