Issue a signed JWT when a user logs in and verify it on every protected API request without a database lookup.
Share verified identity claims between microservices using asymmetric RSA or ECDSA keys so each service validates tokens independently.
Migrate a Go app from the deprecated dgrijalva/jwt-go library to the community-maintained v5 using the included migration guide.
Version 5 introduced breaking changes to token validation compared to v4, use the included migration guide when upgrading from an older version.
golang-jwt/jwt is a Go library for creating and verifying JSON Web Tokens, commonly known as JWTs. A JWT is a compact, self-contained piece of data used to prove identity or share verified information between services without requiring a central session store. When a user logs in, a server can issue a JWT that the client sends with future requests. The receiving service checks the token's signature to confirm it was issued by someone holding the right key, without needing to call back to the original server. The token structure is three parts joined by dots. The first part is a header describing which signing method was used. The middle part holds the claims, the actual data being asserted (such as a user ID, a role, or an expiration time). The third part is a cryptographic signature over the first two parts. Tampering with any part invalidates the signature. This library handles both sides of that process. It can create a token by taking a set of claims and signing them with a provided key. It can also parse an incoming token string, verify the signature, and give back the claims if everything checks out. Supported signing algorithms include HMAC-SHA (symmetric, using a shared secret), RSA, RSA-PSS, ECDSA, and EdDSA (each using a public/private key pair). The project is a community-maintained continuation of the original dgrijalva/jwt-go library, which was transferred to this organization after the original author stepped back. The current major version is v5, which made breaking changes to how token validation works compared to v4. A migration guide is included in the repository for anyone upgrading. The README highlights one security point: always confirm that the algorithm in the token header is the one you expected. Accepting any algorithm the token claims to use is a known class of vulnerability in JWT libraries. This library requires the key type to match the algorithm, which prevents the most common version of that mistake. Extensions exist for integrating with signing keys held by Google Cloud KMS, AWS KMS, and hardware security modules.
← golang-jwt on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.