]> cat aescling's git repositories - mastodon.git/commitdiff
Fix admin API unconditionally requiring CSRF token (#17975)
authorClaire <claire.github-309c@sitedethib.com>
Wed, 6 Apr 2022 18:57:18 +0000 (20:57 +0200)
committerGitHub <noreply@github.com>
Wed, 6 Apr 2022 18:57:18 +0000 (20:57 +0200)
Fixes #17898

Since #17204, the admin API has only been available through the web
application because of the unconditional requirement to provide a valid CSRF
token.

This commit changes it back to `null_session`, which should make it work
both with session-based authentication (provided a CSRF token) and with a
bearer token.

app/controllers/api/v1/admin/account_actions_controller.rb
app/controllers/api/v1/admin/accounts_controller.rb
app/controllers/api/v1/admin/dimensions_controller.rb
app/controllers/api/v1/admin/measures_controller.rb
app/controllers/api/v1/admin/reports_controller.rb
app/controllers/api/v1/admin/retention_controller.rb
app/controllers/api/v1/admin/trends/links_controller.rb
app/controllers/api/v1/admin/trends/statuses_controller.rb
app/controllers/api/v1/admin/trends/tags_controller.rb

index 15af50822e36c2c082931ad71a6011002f2fbc7c..6c9e04402c99477dd1e2a69c334a2d840365f892 100644 (file)
@@ -1,8 +1,6 @@
 # frozen_string_literal: true
 
 class Api::V1::Admin::AccountActionsController < Api::BaseController
-  protect_from_forgery with: :exception
-
   before_action -> { authorize_if_got_token! :'admin:write', :'admin:write:accounts' }
   before_action :require_staff!
   before_action :set_account
index 4b6dab208191ec6292a7e7842834426262400dbd..dc9d3402fb4ecd4787c16c2b1eabc88e00cf082d 100644 (file)
@@ -1,8 +1,6 @@
 # frozen_string_literal: true
 
 class Api::V1::Admin::AccountsController < Api::BaseController
-  protect_from_forgery with: :exception
-
   include Authorization
   include AccountableConcern
 
index b1f738990190e918feeba6a2fb1ee11e0d91b102..49a5be1c365d92b4b8d4b061e2389f216b27df69 100644 (file)
@@ -1,8 +1,6 @@
 # frozen_string_literal: true
 
 class Api::V1::Admin::DimensionsController < Api::BaseController
-  protect_from_forgery with: :exception
-
   before_action -> { authorize_if_got_token! :'admin:read' }
   before_action :require_staff!
   before_action :set_dimensions
index d64c3cdf704a8e1525a6d6e1467dcda610015b88..da95d34220dc804050bba00cb3f92899da9bd200 100644 (file)
@@ -1,8 +1,6 @@
 # frozen_string_literal: true
 
 class Api::V1::Admin::MeasuresController < Api::BaseController
-  protect_from_forgery with: :exception
-
   before_action -> { authorize_if_got_token! :'admin:read' }
   before_action :require_staff!
   before_action :set_measures
index fbfd0ee128c1bdba8fbff1f7cea29e86c7db78e6..865ba3d23c88248b72c9b2f97853255ecb82a53c 100644 (file)
@@ -1,8 +1,6 @@
 # frozen_string_literal: true
 
 class Api::V1::Admin::ReportsController < Api::BaseController
-  protect_from_forgery with: :exception
-
   include Authorization
   include AccountableConcern
 
index 4af5a5c4dcc23d2f823d9ff6ba954db163d27f75..98d1a3d813fb9c9a1aaf67965f4a61c7cc6983ad 100644 (file)
@@ -1,8 +1,6 @@
 # frozen_string_literal: true
 
 class Api::V1::Admin::RetentionController < Api::BaseController
-  protect_from_forgery with: :exception
-
   before_action -> { authorize_if_got_token! :'admin:read' }
   before_action :require_staff!
   before_action :set_cohorts
index 63b3d9358e0aa3eb4869829bbddba054c4e4e200..0a191fe4b26ffb03ba40c0d5bb3d20d0a7d06072 100644 (file)
@@ -1,8 +1,6 @@
 # frozen_string_literal: true
 
 class Api::V1::Admin::Trends::LinksController < Api::BaseController
-  protect_from_forgery with: :exception
-
   before_action -> { authorize_if_got_token! :'admin:read' }
   before_action :require_staff!
   before_action :set_links
index 86633cc74300295b2d6a731e7fed040a084a0dd7..cb145f165c33b0d0354da7c7593b1a448b660a8a 100644 (file)
@@ -1,8 +1,6 @@
 # frozen_string_literal: true
 
 class Api::V1::Admin::Trends::StatusesController < Api::BaseController
-  protect_from_forgery with: :exception
-
   before_action -> { authorize_if_got_token! :'admin:read' }
   before_action :require_staff!
   before_action :set_statuses
index 5cc4c269d717b99ee14c0956256f2d59dda1ec13..9c28b0412b495d7695d43489ac60e262be263d1e 100644 (file)
@@ -1,8 +1,6 @@
 # frozen_string_literal: true
 
 class Api::V1::Admin::Trends::TagsController < Api::BaseController
-  protect_from_forgery with: :exception
-
   before_action -> { authorize_if_got_token! :'admin:read' }
   before_action :require_staff!
   before_action :set_tags