Skip to content

Commit 9cb4c98

Browse files
committed
Switch to DELETE for /logout route to prevent CSRF
Other sites are allowed to make `GET` requests so switchig to `DELETE` to match the destructive nature of the route. If the user navigates to `GET /logout` we now fall back to the default behavior which is to serve up the ember app. Ember then sends a `DELETE` request. Fortunately we already enforce sameorigin for iframes via the `X-FRAME-OPTIONS` header. Fixes: #986
1 parent 5369034 commit 9cb4c98

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

app/routes/logout.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default Route.extend({
77
ajax: service(),
88

99
activate() {
10-
this.get('ajax').request(`/logout`).then(() => {
10+
this.get('ajax').delete(`/logout`).then(() => {
1111
run(() => {
1212
this.session.logoutUser();
1313
this.transitionTo('index');

docs/ARCHITECTURE.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ for another platform.
8787

8888
These files are mostly only relevant when running crates.io's code in development mode.
8989

90+
* `bors.toml` - Configure our instance of [bors-ng][] for continous integration
9091
* `.editorconfig` - Coding style definitions supported by some IDEs // TODO: Reference extensions
9192
for common editors
9293
* `.env` - Environment variables loaded by the backend - (ignored in `.gitignore`)
@@ -101,4 +102,5 @@ These files are mostly only relevant when running crates.io's code in developmen
101102
* `.travis.yml` - Configuration for continous integration at [TravisCI][]
102103
* `.watchmanconfig` - Use by Ember CLI to efficiently watch for file changes if you install watchman
103104

105+
[bors-ng]: https://github.com/bors-ng/bors-ng
104106
[TravisCI]: https://travis-ci.org/rust-lang/crates.io

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ pub fn middleware(app: Arc<App>) -> MiddlewareBuilder {
193193

194194
router.get("/authorize_url", C(user::github_authorize));
195195
router.get("/authorize", C(user::github_access_token));
196-
router.get("/logout", C(user::logout));
196+
router.delete("/logout", C(user::logout));
197197
router.get("/me", C(user::me));
198198
router.get("/me/updates", C(user::updates));
199199
router.get("/me/tokens", C(token::list));

0 commit comments

Comments
 (0)