MCPcopy
hub / github.com/gofiber/fiber / DeleteToken

Method DeleteToken

middleware/csrf/csrf.go:328–341  ·  view source on GitHub ↗

DeleteToken removes the token found in the context from the storage and expires the CSRF cookie

(c fiber.Ctx)

Source from the content-addressed store, hash-verified

326// DeleteToken removes the token found in the context from the storage
327// and expires the CSRF cookie
328func (handler *Handler) DeleteToken(c fiber.Ctx) error {
329 // Extract token from the client request cookie
330 cookieToken := c.Cookies(handler.config.CookieName)
331 if cookieToken == "" {
332 return handler.config.ErrorHandler(c, ErrTokenNotFound)
333 }
334 // Remove the token from storage
335 if err := deleteTokenFromStorage(c, cookieToken, &handler.config, handler.sessionManager, handler.storageManager); err != nil {
336 return handler.config.ErrorHandler(c, err)
337 }
338 // Expire the cookie
339 expireCSRFCookie(c, &handler.config)
340 return nil
341}
342
343func validateSecFetchSite(c fiber.Ctx) error {
344 secFetchSite := utils.Trim(c.Get(fiber.HeaderSecFetchSite), ' ')

Calls 4

deleteTokenFromStorageFunction · 0.85
expireCSRFCookieFunction · 0.85
ErrorHandlerMethod · 0.80
CookiesMethod · 0.65