Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mastodon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pierre Boudes
mastodon
Commits
9f81b9f2
Unverified
Commit
9f81b9f2
authored
2 years ago
by
Eugen Rochko
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix suspended users being able to access APIs that don't require a user (#18524)
parent
96129c2f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/controllers/activitypub/base_controller.rb
+1
-0
1 addition, 0 deletions
app/controllers/activitypub/base_controller.rb
app/controllers/api/base_controller.rb
+5
-0
5 additions, 0 deletions
app/controllers/api/base_controller.rb
with
6 additions
and
0 deletions
app/controllers/activitypub/base_controller.rb
+
1
−
0
View file @
9f81b9f2
...
...
@@ -2,6 +2,7 @@
class
ActivityPub::BaseController
<
Api
::
BaseController
skip_before_action
:require_authenticated_user!
skip_before_action
:require_not_suspended!
skip_around_action
:set_locale
private
...
...
This diff is collapsed.
Click to expand it.
app/controllers/api/base_controller.rb
+
5
−
0
View file @
9f81b9f2
...
...
@@ -11,6 +11,7 @@ class Api::BaseController < ApplicationController
skip_before_action
:require_functional!
,
unless: :whitelist_mode?
before_action
:require_authenticated_user!
,
if: :disallow_unauthenticated_api_access?
before_action
:require_not_suspended!
before_action
:set_cache_headers
protect_from_forgery
with: :null_session
...
...
@@ -97,6 +98,10 @@ class Api::BaseController < ApplicationController
render
json:
{
error:
'This method requires an authenticated user'
},
status:
401
unless
current_user
end
def
require_not_suspended!
render
json:
{
error:
'Your login is currently disabled'
},
status:
403
if
current_user
&
.
account
&
.
suspended?
end
def
require_user!
if
!
current_user
render
json:
{
error:
'This method requires an authenticated user'
},
status:
422
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment