Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Also remove the user cookie from the server side when user logs out
天舟e248f0c97588
diff --git a/frontend/src/store/modules/auth.ts b/frontend/src/store/modules/auth.tsindex 0eef116382..1a77928162 100644--- a/frontend/src/store/modules/auth.ts+++ b/frontend/src/store/modules/auth.ts@@ -10,7 +10,7 @@ import {unknown,PrincipalId,} from "../../types";-import { getIntCookie, removeCookie } from "../../utils";+import { getIntCookie } from "../../utils";function convert(user: ResourceObject, rootGetters: any): Principal {return rootGetters["principal/principalById"](user.id);@@ -52,7 +52,6 @@ const actions = {async logout({ commit }: any) {await axios.post("/api/auth/logout");- removeCookie("user");commit("setCurrentUser", unknown("PRINCIPAL") as Principal);return unknown("PRINCIPAL") as Principal;},diff --git a/frontend/src/utils/util.ts b/frontend/src/utils/util.tsindex 66c22759ba..2b2051256e 100644--- a/frontend/src/utils/util.ts+++ b/frontend/src/utils/util.ts@@ -124,17 +124,3 @@ export function getStringCookie(name: string): string {return "";}--export function removeCookie(name: string) {- const newList = [];- const list = document.cookie.split(";");- for (var i = 0; i < list.length; i++) {- const parts = list[i].split("=");- if (parts[0].trim() == name) {- newList.push(`${name}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=/`);- } else {- newList.push(list[i]);- }- }- document.cookie = newList.join(";");-}diff --git a/server/auth.go b/server/auth.goindex 7f1d6118fe..f840179780 100644--- a/server/auth.go+++ b/server/auth.go@@ -65,6 +65,7 @@ func (s *Server) registerAuthRoutes(g *echo.Group) {g.POST("/auth/logout", func(c echo.Context) error {removeTokenCookie(c, accessTokenCookieName)removeTokenCookie(c, refreshTokenCookieName)+ removeUserCookie(c)c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)c.Response().WriteHeader(http.StatusOK)diff --git a/server/jwt.go b/server/jwt.goindex 584c8e6bc1..ed52abee07 100644--- a/server/jwt.go+++ b/server/jwt.go@@ -149,6 +149,15 @@ func setUserCookie(c echo.Context, user *api.Principal, expiration time.Time) {c.SetCookie(cookie)}+func removeUserCookie(c echo.Context) {+ cookie := new(http.Cookie)+ cookie.Name = "user"+ cookie.Value = ""+ cookie.Expires = time.Unix(0, 0)+ cookie.Path = "/"+ c.SetCookie(cookie)+}+// JWTMiddleware validates the access token.// If the access token is about to expire or has expired and the request has a valid refresh token, it// will try to generate new access token and refresh token.