Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: refactor (#18680)

p0ny147e4441fa30
diff --git a/backend/api/auth/auth.go b/backend/api/auth/auth.go
index c4862a48c4..0bfba44276 100644
--- a/backend/api/auth/auth.go
+++ b/backend/api/auth/auth.go
@@ -47,6 +47,8 @@ const (
// AccessTokenCookieName is the cookie name of access token.
AccessTokenCookieName = "access-token"
+ // RefreshTokenCookieName is the cookie name of refresh token.
+ RefreshTokenCookieName = "refresh-token"
)
// APIAuthInterceptor is the auth interceptor for gRPC server.
diff --git a/backend/api/auth/header.go b/backend/api/auth/header.go
index 0775159879..d5b2e2b150 100644
--- a/backend/api/auth/header.go
+++ b/backend/api/auth/header.go
@@ -93,8 +93,6 @@ func GetRefreshTokenDuration(ctx context.Context, store *store.Store, licenseSer
return refreshTokenDuration
}
-const RefreshTokenCookieName = "refresh-token"
-
// GetRefreshTokenCookie creates a cookie for the refresh token.
// token="" => unset (clears cookie)
// Path is "/" to allow logout to delete the token from database.
@@ -125,8 +123,8 @@ func GetRefreshTokenFromCookie(header http.Header) string {
for _, cookie := range header.Values("Cookie") {
for _, part := range strings.Split(cookie, ";") {
part = strings.TrimSpace(part)
- if strings.HasPrefix(part, RefreshTokenCookieName+"=") {
- return strings.TrimPrefix(part, RefreshTokenCookieName+"=")
+ if rt, ok := strings.CutPrefix(part, RefreshTokenCookieName+"="); ok {
+ return rt
}
}
}