Skip to content

PLAT-137 Pentest: Change /auth/with-token to use short-lived tokens #7750

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update admin/server/auth/middleware.go
Co-authored-by: Benjamin Egelund-Müller <b@egelund-muller.com>
  • Loading branch information
NamanMahor and begelundmuller authored Aug 6, 2025
commit 22f5ac77be6001ea40988878cc4fb443f09094ab
6 changes: 4 additions & 2 deletions admin/server/auth/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@ func (a *Authenticator) HTTPMiddlewareLenient(next http.Handler) http.Handler {
return a.httpMiddleware(next, true)
}

// HTTPMiddlewareWithCookieRefresh is a middleware that refreshes the auth cookie
func (a *Authenticator) HTTPMiddlewareWithCookieRefresh(next http.Handler) http.Handler {
// CookieRefreshMiddleware is a middleware that refreshes the auth cookie.
// This enables us to do rolling cookie refreshes so we can have a relatively short cookie max age.
// Note that it does not update the auth token encrypted inside the cookie.
func (a *Authenticator) CookieRefreshMiddleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
sess := a.cookies.Get(r, cookieName)
if authToken, ok := sess.Values[cookieFieldAccessToken].(string); ok && authToken != "" {
Expand Down
Loading