Azure / Azure/static-web-apps

Login session duration can be extended from 8 hours

Open
#761 23 comments 16 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
346
Forks
67
PR merge metrics
No merged PRs in 30d

Description

**Is your feature request related to a problem? Please describe.**

When using Static Web App custom authentication, the login session (actually a cookie) expires in 8 hours and cannot be extended using `/.auth/refresh` like the App Service, so I would like to extend the expiration time from 8 hours.

![image](https://user-images.githubusercontent.com/1356444/160165161-e91d6423-77b8-49bf-a767-1d22f5e37d90.png)

Once issued, the `StaticWebAppsAuthCookie` cookie expiration date is not extended and API calls will not work properly once it expires.

In particular, using `responseOverrides` to convert HTTP 401 to HTTP 302 redirects, as described in the following document, leads to CORS errors and makes error handling in the application difficult.

https://docs.microsoft.com/en-us/azure/static-web-apps/configuration#response-overrides

![image](https://user-images.githubusercontent.com/1356444/160165940-4366b9b7-b44b-4394-b54f-f42ec1d866e7.png)

Since SPAs often do not reload entire pages for long periods of time, expiring login sessions in the middle of a page can cause unexpected behavior.

**Describe the solution you'd like**

I would like to be able to change the cookie validity time for custom authentication using `staticwebapp.config.json`. Or, allow session extension using `/.auth/refresh`.

Ideally, the login session would be automatically extended on a sliding when the time remaining in the session becomes too short.

**Describe alternatives you've considered**

None

**Additional context**

In the case of SPA, only the API response status code can determine cookie expiration, so if you are using `responseOverrides` to redirect HTTP `401` to HTTP `302` as in the sample in the official documentation, error handling becomes very difficult.

- Related Issue
- #762

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.