Go to file
Lincoln Stein 01c67c5468
Fix (multiuser): Ask user to log back in when security token has expired (#9017)
* Initial plan

* Warn user when credentials have expired in multiuser mode

Agent-Logs-Url: https://github.com/lstein/InvokeAI/sessions/f0947cda-b15c-475d-b7f4-2d553bdf2cd6

Co-authored-by: lstein <111189+lstein@users.noreply.github.com>

* Address code review: avoid multiple localStorage reads in base query

Agent-Logs-Url: https://github.com/lstein/InvokeAI/sessions/f0947cda-b15c-475d-b7f4-2d553bdf2cd6

Co-authored-by: lstein <111189+lstein@users.noreply.github.com>

* bugfix(multiuser): ask user to log back in when authentication token expires

* feat: sliding window session expiry with token refresh

Backend:
- SlidingWindowTokenMiddleware refreshes JWT on each mutating request
  (POST/PUT/PATCH/DELETE), returning a new token in X-Refreshed-Token
  response header. GET requests don't refresh (they're often background
  fetches that shouldn't reset the inactivity timer).
- CORS expose_headers updated to allow X-Refreshed-Token.

Frontend:
- dynamicBaseQuery picks up X-Refreshed-Token from responses and
  updates localStorage so subsequent requests use the fresh expiry.
- 401 handler only triggers sessionExpiredLogout when a token was
  actually sent (not for unauthenticated background requests).
- ProtectedRoute polls localStorage every 5s and listens for storage
  events to detect token removal (e.g. manual deletion, other tabs).

Result: session expires after TOKEN_EXPIRATION_NORMAL (1 day) of
inactivity, not a fixed time after login. Any user-initiated action
resets the clock.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* chore(backend): ruff

* fix: address review feedback on auth token handling

Bug fixes:
- ProtectedRoute: only treat 401 errors as session expiry, not
  transient 500/network errors that should not force logout
- Token refresh: use explicit remember_me claim in JWT instead of
  inferring from remaining lifetime, preventing silent downgrade of
  7-day tokens to 1-day when <24h remains
- TokenData: add remember_me field, set during login

Tests (6 new):
- Mutating requests (POST/PUT/DELETE) return X-Refreshed-Token
- GET requests do not return X-Refreshed-Token
- Unauthenticated requests do not return X-Refreshed-Token
- Remember-me token refreshes to 7-day duration even near expiry
- Normal token refreshes to 1-day duration
- remember_me claim preserved through refresh cycle

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* chore(backend): ruff

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: lstein <111189+lstein@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Jonathan <34005131+JPPhoto@users.noreply.github.com>
2026-04-05 23:11:44 -04:00
.dev_scripts Apply black 2023-07-27 10:54:01 -04:00
.github chore(CI/CD): add pfannkuchensack to codeowners for backend (#8915) 2026-02-25 21:30:49 -05:00
coverage combine pytest.ini with pyproject.toml 2023-03-05 17:00:08 +00:00
docker bugfix(docker) Ensure the correct extra install. 2025-07-17 04:19:22 +00:00
docs docs: Fix typo in contributing guide - remove extra 'the' (#8949) 2026-03-09 18:03:32 +00:00
invokeai Fix (multiuser): Ask user to log back in when security token has expired (#9017) 2026-04-05 23:11:44 -04:00
scripts Feature(backend): Add a command-line utility for running gallery maintenance (#8827) 2026-02-16 23:44:19 +00:00
tests Fix (multiuser): Ask user to log back in when security token has expired (#9017) 2026-04-05 23:11:44 -04:00
.dockerignore refactor Dockerfile; get rid of multi-stage build; upgrade to python 3.12 2025-04-04 18:42:13 +11:00
.editorconfig Merge dev into main for 2.2.0 (#1642) 2022-11-30 16:12:23 -05:00
.git-blame-ignore-revs Git blame ignore revs 2025-03-26 12:56:04 +11:00
.gitattributes refactor: model manager v3 (#8607) 2025-10-15 10:18:53 +11:00
.gitignore Chore: Fix weblate merge conflicts (#8744) 2026-01-08 15:25:11 -05:00
.gitmodules remove src directory, which is gumming up conda installs; addresses issue #77 2022-08-25 10:43:05 -04:00
.nvmrc update nodes schema / typegen 2025-04-04 18:42:13 +11:00
.pre-commit-config.yaml chore: update pre-commit syntax; add check for uv.lock needing an update 2025-04-15 07:41:32 +10:00
.prettierrc.yaml feat: automated releases via github action 2024-02-29 21:57:20 -05:00
flake.lock update flake (#7032) 2024-10-08 10:55:49 +11:00
flake.nix update flake (#7032) 2024-10-08 10:55:49 +11:00
InvokeAI_Statement_of_Values.md Add @ebr to Contributors (#2095) 2022-12-21 14:33:08 -05:00
LICENSE Update LICENSE 2023-07-05 23:46:27 -04:00
LICENSE-SD1+SD2.txt updated LICENSE files and added information about watermarking 2023-07-26 17:27:33 -04:00
LICENSE-SDXL.txt updated LICENSE files and added information about watermarking 2023-07-26 17:27:33 -04:00
Makefile Run vitest during frontend build (#9022) 2026-04-05 19:18:24 -04:00
mkdocs.yml feat(multiuser mode): Support multiple isolated users on same backend (#8822) 2026-02-26 23:47:25 -05:00
pins.json chore: bump torch to 2.7.0 2025-05-19 12:29:51 +10:00
pyproject.toml feat(multiuser mode): Support multiple isolated users on same backend (#8822) 2026-02-26 23:47:25 -05:00
README.md docs: Fix typo in README.md - 'easy' should be 'ease' (#8948) 2026-03-09 18:01:54 +00:00
SECURITY.md Create SECURITY.md 2024-11-25 04:10:03 -08:00
Stable_Diffusion_v1_Model_Card.md Global replace [ \t]+$, add "GB" (#1751) 2022-12-19 16:36:39 +00:00
USER_ISOLATION_IMPLEMENTATION.md feat(multiuser mode): Support multiple isolated users on same backend (#8822) 2026-02-26 23:47:25 -05:00
uv.lock Upgrade spandrel version (#8996) 2026-04-05 14:28:15 -04:00

project hero

Invoke - Professional Creative AI Tools for Visual Media

discord badge latest release badge github stars badge github forks badge CI checks on main badge latest commit to main badge github open issues badge github open prs badge translation status badge

Invoke is a leading creative engine built to empower professionals and enthusiasts alike. Generate and create stunning visual media using the latest AI-driven technologies. Invoke offers an industry leading web-based UI, and serves as the foundation for multiple commercial products.

  • Free to use under a commercially-friendly license
  • Download and install on compatible hardware
  • Generate, refine, iterate on images, and build workflows

Highlighted Features - Canvas and Workflows


📣 Are you a new or returning InvokeAI user?

Take our first annual User's Survey


Documentation

Quick Links
Installation and Updates - Documentation and Tutorials - Bug Reports - Contributing

Installation

To get started with Invoke, Download the Launcher.

Troubleshooting, FAQ and Support

Please review our FAQ for solutions to common installation problems and other issues.

For more help, please join our Discord.

Features

Full details on features can be found in our documentation.

Web Server & UI

Invoke runs a locally hosted web server & React UI with an industry-leading user experience.

Unified Canvas

The Unified Canvas is a fully integrated canvas implementation with support for all core generation capabilities, in/out-painting, brush tools, and more. This creative tool unlocks the capability for artists to create with AI as a creative collaborator, and can be used to augment AI-generated imagery, sketches, photography, renders, and more.

Workflows & Nodes

Invoke offers a fully featured workflow management solution, enabling users to combine the power of node-based workflows with the ease of a UI. This allows for customizable generation pipelines to be developed and shared by users looking to create specific workflows to support their production use-cases.

Invoke features an organized gallery system for easily storing, accessing, and remixing your content in the Invoke workspace. Images can be dragged/dropped onto any Image-base UI element in the application, and rich metadata within the Image allows for easy recall of key prompts or settings used in your workflow.

Other features

  • Support for both ckpt and diffusers models
  • SD1.5, SD2.0, SDXL, and FLUX support
  • Upscaling Tools
  • Embedding Manager & Support
  • Model Manager & Support
  • Workflow creation & management
  • Node-Based Architecture

Contributing

Anyone who wishes to contribute to this project - whether documentation, features, bug fixes, code cleanup, testing, or code reviews - is very much encouraged to do so.

Get started with contributing by reading our contribution documentation, joining the #dev-chat or the GitHub discussion board.

We hope you enjoy using Invoke as much as we enjoy creating it, and we hope you will elect to become part of our community.

Thanks

Invoke is a combined effort of passionate and talented people from across the world. We thank them for their time, hard work and effort.

Original portions of the software are Copyright © 2024 by respective contributors.