Skip to content

Commit

Permalink
Set Lax for the SameSite attribute
Browse files Browse the repository at this point in the history
Signed-off-by: Michal Kolodziejski <michal.kolodziejski@cern.ch>
  • Loading branch information
mic4ael committed Apr 1, 2021
1 parent e00eaa8 commit 9e95173
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 16 deletions.
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
3 changes: 2 additions & 1 deletion public/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1632,7 +1632,8 @@ function toggleNightMode () {
store.set('nightMode', !isActive)
} else {
Cookies.set('nightMode', !isActive, {
expires: 365
expires: 365,
sameSite: 'Lax'
})
}
}
Expand Down
6 changes: 4 additions & 2 deletions public/js/lib/common/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ export function resetCheckAuth () {

export function setLoginState (bool, id) {
Cookies.set('loginstate', bool, {
expires: 365
expires: 365,
sameSite: 'Lax'
})
if (id) {
Cookies.set('userid', id, {
expires: 365
expires: 365,
sameSite: 'Lax'
})
} else {
Cookies.remove('userid')
Expand Down
30 changes: 20 additions & 10 deletions public/js/lib/editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,12 +414,14 @@ export default class Editor {
const setType = () => {
if (this.editor.getOption('indentWithTabs')) {
Cookies.set('indent_type', 'tab', {
expires: 365
expires: 365,
sameSite: 'Lax'
})
type.text('Tab Size:')
} else {
Cookies.set('indent_type', 'space', {
expires: 365
expires: 365,
sameSite: 'Lax'
})
type.text('Spaces:')
}
Expand All @@ -430,11 +432,13 @@ 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'
})
} else {
Cookies.set('space_units', unit, {
expires: 365
expires: 365,
sameSite: 'Lax'
})
}
widthLabel.text(unit)
Expand Down Expand Up @@ -502,7 +506,8 @@ export default class Editor {
const setKeymapLabel = () => {
var keymap = this.editor.getOption('keyMap')
Cookies.set('keymap', keymap, {
expires: 365
expires: 365,
sameSite: 'Lax'
})
label.text(keymap)
this.restoreOverrideEditorKeymap()
Expand Down Expand Up @@ -537,7 +542,8 @@ export default class Editor {
const setTheme = theme => {
this.editor.setOption('theme', theme)
Cookies.set('theme', theme, {
expires: 365
expires: 365,
sameSite: 'Lax'
})
this.statusIndicators.find('.status-theme li').removeClass('active')
this.statusIndicators.find(`.status-theme li[value="${theme}"]`).addClass('active')
Expand Down Expand Up @@ -639,15 +645,17 @@ export default class Editor {
spellcheckToggle.removeClass('active')

Cookies.set('spellcheck', false, {
expires: 365
expires: 365,
sameSite: 'Lax'
})

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

Cookies.set('spellcheck', lang, {
expires: 365
expires: 365,
sameSite: 'Lax'
})

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

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

0 comments on commit 9e95173

Please sign in to comment.