Skip to content

Commit 83a28ae

Browse files
committed
Changed error response in case of CSRF attak to 403 - forbidden instead of 500
1 parent c2b2d5e commit 83a28ae

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/http_context.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@ void context::dispatch(booster::intrusive_ptr<application> app,std::string url,b
141141
app->context().session().load();
142142
app->main(url);
143143
}
144+
catch(request_forgery_error const &e) {
145+
if(app->get_context() && !app->response().some_output_was_written()) {
146+
app->response().make_error_response(http::response::forbidden);
147+
}
148+
}
144149
catch(std::exception const &e){
145150
BOOSTER_ERROR("cppcms") << "Caught exception ["<<e.what()<<"]\n" << booster::trace(e) ;
146151
if(app->get_context()) {

0 commit comments

Comments
 (0)