浏览代码

Added the samesite attribute to prevent breaking changes (#5289)

Dustin Utecht 5 年之前
父节点
当前提交
e722d2624c
共有 2 个文件被更改,包括 16 次插入1 次删除
  1. 13 0
      site/docs/extensions/cookie.md
  2. 3 1
      src/extensions/cookie/bootstrap-table-cookie.js

+ 13 - 0
site/docs/extensions/cookie.md

@@ -142,6 +142,19 @@ toc: true
 
 - **Default:** `null`
 
+### cookieSameSite
+
+- **Attribute:** `data-cookie-same-site`
+
+- **type:** `string`
+
+- **Detail:**
+
+   This property defines the value of the `SameSite` cookie attribute, for more information please check the [SameSite Documentation](https://developer.mozilla.org/de/docs/Web/HTTP/Headers/Set-Cookie/SameSite).
+
+- **Default:** `Lax`
+
+
 ### cookieStorage
 
 - **Attribute:** `data-cookie-storage`

+ 3 - 1
src/extensions/cookie/bootstrap-table-cookie.js

@@ -65,7 +65,8 @@ const UtilsCookie = {
           `; expires=${UtilsCookie.calculateExpiration(that.options.cookieExpire)}`,
           that.options.cookiePath ? `; path=${that.options.cookiePath}` : '',
           that.options.cookieDomain ? `; domain=${that.options.cookieDomain}` : '',
-          that.options.cookieSecure ? '; secure' : ''
+          that.options.cookieSecure ? '; secure' : '',
+          ';SameSite=' + that.options.cookieSameSite
         ].join('')
         break
       case 'localStorage':
@@ -262,6 +263,7 @@ $.extend($.fn.bootstrapTable.defaults, {
   cookiePath: null,
   cookieDomain: null,
   cookieSecure: null,
+  cookieSameSite: 'Lax',
   cookieIdTable: '',
   cookiesEnabled: [
     'bs.table.sortOrder', 'bs.table.sortName',