SShortSingh.
Back to feed

JWT Explained: What It Is, What It Is Not, and How to Use It Right

0
·1 views

JWT (JSON Web Token) is simply a signed JSON object used to pass claims between parties — it is not a session store, a database, or a built-in authentication system. The token carries fields like subject and expiration, and its signature ensures it has not been tampered with, but it cannot be revoked before it expires without additional infrastructure. A common pattern for single-page applications uses short-lived access tokens (15 minutes) alongside long-lived refresh tokens stored in secure httpOnly cookies, reducing risk if a token is leaked. When early revocation is required — such as after a password change — developers must implement either a token blocklist in Redis or a database, or a version counter stored on the user record, both of which introduce server-side state. JWT works best for stateless APIs, microservices, and cross-domain authentication, but simpler session cookies may be more appropriate when only a single server consumes the tokens.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

Essential Docker Commands Every Developer Should Know for Daily Use

A practical guide to core Docker commands covers daily essentials such as docker run, exec, logs, ps, and build for working with real containers beyond basic examples. Key flags for docker run include -it for interactive shell access, --rm to auto-remove stopped containers, -e for environment variables, and -v for bind-mounting host directories. The docker ps and docker inspect commands help monitor running containers, while docker stats enables real-time CPU and memory tracking without entering a container. Docker logs, particularly with the -f flag, is highlighted as the go-to first step when diagnosing misbehaving containers, since applications are expected to write output to stdout or stderr. The docker exec command allows developers to run commands or open a shell inside an already-running container, making it useful for debugging in production or staging environments without restarting services.

0
ProgrammingDEV Community ·

AI Product Builder: The Hybrid PM-Developer Role Gaining Traction in 2025

A new job role called 'AI Product Builder' is emerging in tech hiring, describing a single professional who handles both product management and software development using AI coding tools. The role is made possible by advances in AI code assistants, better context and prompt management, and automated quality checks that reduce the traditional idea-to-deployment cycle. However, its success depends heavily on the maturity of the existing codebase, including documentation quality, extensibility, and automated testing coverage. Organisations with well-structured, documented codebases are better positioned to let such hybrid roles thrive, while those with younger or messier code should limit the scope of tasks assigned to these individuals. Demand for the role is expected to grow, but companies must invest in the right engineering foundations to make it viable.

0
ProgrammingDEV Community ·

How a React 19 Kanban Board Was Built for Real-Time, Offline-First Collaboration

A developer has detailed the architecture behind an enterprise-grade, real-time Kanban board built using React 19, Vite, TypeScript, and Tailwind CSS. The application uses client-side virtualization via TanStack Virtual to render thousands of DOM nodes while sustaining 60fps during drag-and-drop interactions. It features an offline-first Progressive Web App setup powered by a Service Worker that keeps the board fully functional without an internet connection. A custom undo/redo state machine built into Zustand handles optimistic UI updates and automatically rolls back failed network requests. The project achieves 99.12% test coverage through Vitest and is positioned as a foundation for future AI-powered, enterprise task management tooling.

0
ProgrammingDEV Community ·

681 AI Sessions Tracked: Repeated File Edits, Not Heavy Use, Drain Your Budget

A developer tracked 681 AI work sessions across 41 projects over four months, from April to August 2026, to understand where subscription costs actually go. The analysis found that 90% of requests cost very little, while just 15% of requests — those where the AI edits the same file three or more times — account for 41% of total output. When the AI loops on a problem without progress, it generates six times more text than a normal request while rarely improving on its second attempt. A key behavioral signal is the phrase 'let me try something else,' which the author identifies as the point where the AI stops reasoning and begins cycling through repeated solutions. The author recommends setting a two-attempt limit per problem in the AI's instruction file and notes that re-explaining project context costs time but not significant money.