Skip to content
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

Set Lax for the SameSite attribute on cookies #1670

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 3 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ app.use(morgan('combined', {
}))

// socket io
var io = require('socket.io')(server)
var io = require('socket.io')(server, { cookie: false })
io.engine.ws = new (require('ws').Server)({
noServer: true,
perMessageDeflate: false
Expand Down Expand Up @@ -148,7 +148,8 @@ app.use(session({
saveUninitialized: true, // always create session to ensure the origin
rolling: true, // reset maxAge on every response
cookie: {
maxAge: config.sessionLife
maxAge: config.sessionLife,
sameSite: 'lax'
},
store: sessionStore
}))
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
"jquery": "~3.4.1",
"jquery-mousewheel": "~3.1.13",
"jquery-ui": "~1.12.1",
"js-cookie": "~2.2.0",
"js-cookie": "^3.0.0",
"js-yaml": "~3.13.1",
"jsonlint": "~1.6.2",
"keymaster": "~1.6.2",
Expand Down
4 changes: 3 additions & 1 deletion public/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1600,7 +1600,9 @@ function toggleNightMode () {
store.set('nightMode', !isActive)
} else {
Cookies.set('nightMode', !isActive, {
expires: 365
expires: 365,
sameSite: 'Lax',
secure: window.location.protocol === 'https:'
})
}
}
Expand Down
8 changes: 6 additions & 2 deletions public/js/lib/common/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ export function resetCheckAuth () {

export function setLoginState (bool, id) {
Cookies.set('loginstate', bool, {
expires: 365
expires: 365,
sameSite: 'Lax',
secure: window.location.protocol === 'https:'
})
if (id) {
Cookies.set('userid', id, {
expires: 365
expires: 365,
sameSite: 'Lax',
secure: window.location.protocol === 'https:'
})
} else {
Cookies.remove('userid')
Expand Down
40 changes: 30 additions & 10 deletions public/js/lib/editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,12 +450,16 @@ export default class Editor {
const setType = () => {
if (this.editor.getOption('indentWithTabs')) {
Cookies.set('indent_type', 'tab', {
expires: 365
expires: 365,
sameSite: 'Lax',
secure: window.location.protocol === 'https:'
})
type.text('Tab Size:')
} else {
Cookies.set('indent_type', 'space', {
expires: 365
expires: 365,
sameSite: 'Lax',
secure: window.location.protocol === 'https:'
})
type.text('Spaces:')
}
Expand All @@ -466,11 +470,15 @@ export default class Editor {
var unit = this.editor.getOption('indentUnit')
if (this.editor.getOption('indentWithTabs')) {
Cookies.set('tab_size', unit, {
expires: 365
expires: 365,
sameSite: 'Lax',
secure: window.location.protocol === 'https:'
})
} else {
Cookies.set('space_units', unit, {
expires: 365
expires: 365,
sameSite: 'Lax',
secure: window.location.protocol === 'https:'
})
}
widthLabel.text(unit)
Expand Down Expand Up @@ -538,7 +546,9 @@ export default class Editor {
const setKeymapLabel = () => {
var keymap = this.editor.getOption('keyMap')
Cookies.set('keymap', keymap, {
expires: 365
expires: 365,
sameSite: 'Lax',
secure: window.location.protocol === 'https:'
})
label.text(keymap)
this.restoreOverrideEditorKeymap()
Expand Down Expand Up @@ -573,7 +583,9 @@ export default class Editor {
const setTheme = theme => {
this.editor.setOption('theme', theme)
Cookies.set('theme', theme, {
expires: 365
expires: 365,
sameSite: 'Lax',
secure: window.location.protocol === 'https:'
})
this.statusIndicators.find('.status-theme li').removeClass('active')
this.statusIndicators.find(`.status-theme li[value="${theme}"]`).addClass('active')
Expand Down Expand Up @@ -675,15 +687,19 @@ export default class Editor {
spellcheckToggle.removeClass('active')

Cookies.set('spellcheck', false, {
expires: 365
expires: 365,
sameSite: 'Lax',
secure: window.location.protocol === 'https:'
})

self.editor.setOption('mode', defaultEditorMode)
} else {
spellcheckToggle.addClass('active')

Cookies.set('spellcheck', lang, {
expires: 365
expires: 365,
sameSite: 'Lax',
secure: window.location.protocol === 'https:'
})

self.editor.setOption('mode', 'spell-checker')
Expand All @@ -704,7 +720,9 @@ export default class Editor {
this.editor.setOption('gutters', [lintGutter, ...gutters])
}
Cookies.set('linter', true, {
expires: 365
expires: 365,
sameSite: 'Lax',
secure: window.location.protocol === 'https:'
})
} else {
this.editor.setOption('gutters', gutters.filter(g => g !== lintGutter))
Expand Down Expand Up @@ -753,7 +771,9 @@ export default class Editor {
)
if (overrideBrowserKeymap.is(':checked')) {
Cookies.set('preferences-override-browser-keymap', true, {
expires: 365
expires: 365,
sameSite: 'Lax',
secure: window.location.protocol === 'https:'
})
this.restoreOverrideEditorKeymap()
} else {
Expand Down
4 changes: 3 additions & 1 deletion public/js/locale.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ $('select.ui-locale option[value="' + lang + '"]').attr('selected', 'selected')

locale.change(function () {
Cookies.set('locale', $(this).val(), {
expires: 365
expires: 365,
sameSite: 'Lax',
secure: window.location.protocol === 'https:'
})
window.location.reload()
})