-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a2b93a0
commit cb20ed4
Showing
13 changed files
with
88 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module.exports = function getRealPath(url, locale, localeSource) { | ||
if (localeSource !== 'url') { | ||
const basename = ''; | ||
|
||
return [basename, url]; | ||
} | ||
|
||
const basename = `/${locale}`; | ||
const path = url.substring(locale.length + 1, url.length); | ||
|
||
return [basename, path]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const randomString = require('randomstring'); | ||
|
||
const TOKEN_LENGTH = 32; | ||
|
||
module.exports = function handleCsrfProtection(cookies, config) { | ||
const { protection, cookieName, headerName } = config; | ||
|
||
if (!protection) { | ||
return { | ||
headers: {}, | ||
}; | ||
} | ||
|
||
const cookie = cookies.get(cookieName); | ||
|
||
if (cookie && cookie.length === TOKEN_LENGTH) { | ||
return { | ||
headers: { | ||
[headerName]: cookie, | ||
}, | ||
}; | ||
} | ||
|
||
const token = randomString.generate(TOKEN_LENGTH); | ||
|
||
cookies.set(cookieName, token, { httpOnly: true }); | ||
|
||
return { | ||
headers: { | ||
[headerName]: token, | ||
}, | ||
}; | ||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.