swagger-api / swagger-api/swagger-ui

Allow to use sessionStorage for persisting authorization

Open
#8,711 3 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

Content & configuration

Currently when you use:

SwaggerUI({
  persistAuthorization: true,
})

... then the authorization details will be permanently stored in window.localStorage, as per this line of code, surviving browser restarts, etc.

Describe the solution you'd like

I'd love to be able to do:

SwaggerUI({
  persistAuthorization: true,
  persistAuthorizationInSession: true,
})

... and let it use window.sessionStorage instead, so that i can refresh the page without having to re-authenticate, but wouldn't let the authentication details be available for any page in the same domain, etc.

What do you think?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/core/plugins/auth/actions.js at the linked persistAuthorization logic and trace how the SwaggerUI configuration reaches it. Add the requested sessionStorage option while preserving existing localStorage behavior, then verify that authorization survives a refresh without being persisted across browser restarts.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
authentication, frontend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.