This repository has been archived by the owner on May 17, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor to simplify csrf protection and expose enhancer API (#157)
- Loading branch information
Showing
12 changed files
with
1,136 additions
and
605 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#### Update API to use enhancer pattern | ||
|
||
This change updates the API from a plugin to an enhancer, and greatly simplifies the configuration. | ||
The following tokens are removed: | ||
|
||
- `CsrfExpireToken` | ||
- `FetchForCsrfToken` | ||
- `SessionToken` | ||
|
||
Instead of registering this plugin on the `FetchToken`, you can now use this as an enhancer on the `FetchToken`. | ||
|
||
```diff | ||
import CsrfProtection from 'fusion-plugin-csrf-protection'; | ||
-app.register(SessionToken, Session); | ||
-app.register(FetchForCsrfToken, fetch); | ||
-app.register(FetchToken, CsrfProtection); | ||
-if (__BROWSER__) { | ||
- app.register(FetchForCsrfToken, fetch); | ||
-} | ||
-app.register(CsrfExpireToken, 60 * 60 * 24); | ||
+app.register(FetchToken, fetch); | ||
+app.enhance(FetchToken, CsrfProtection) | ||
``` | ||
|
||
NOTE: There will be a codemod released for this |
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
Oops, something went wrong.