dotnet / dotnet/aspnetcore

New event for CookieAuthenticationEvents when authentication cookie is renewed/refreshed

Open
#63,667 2 comments 1 reaction 0 assignees View on GitHub
api-needs-work area-auth
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

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

I am currently issuing an additional cookie based on the authenticated user when they sign in, but the problem is that I can't reliably know when the authentication cookie is refresh to issue the additional cookie again.

I checked the `CookieAuthenticationHandler` and seems like the refresh happens in `FinishResponseAsync` which can be overridden, but doesn't really provide the information when/if the refresh happened. Might be possible to detect it by checking the response `Set-Cookie` but that way I don't know the `AuthenticationProperties` of the new cookie.

### Describe the solution you'd like

A new event `OnRefresh`/`OnRenew` in `CookieAuthenticationEvents` that is fired with the new principal+properties somewhere after `AppendResponseCookie` in `FinishResponseAsync`

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.