Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mastodon
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
6d43b632
Commit
6d43b632
authored
1 year ago
by
Emelia Smith
Committed by
Claire
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Disable administrative doorkeeper routes (#29187)
parent
ae2dce81
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
config/initializers/doorkeeper.rb
+7
-2
7 additions, 2 deletions
config/initializers/doorkeeper.rb
spec/requests/disabled_oauth_endpoints_spec.rb
+83
-0
83 additions, 0 deletions
spec/requests/disabled_oauth_endpoints_spec.rb
with
90 additions
and
2 deletions
config/initializers/doorkeeper.rb
+
7
−
2
View file @
6d43b632
...
...
@@ -21,9 +21,14 @@ Doorkeeper.configure do
user
unless
user
&
.
otp_required_for_login?
end
# If you want to restrict access to the web interface for adding oauth authorized applications, you need to declare the block below.
# Doorkeeper provides some administrative interfaces for managing OAuth
# Applications, allowing creation, edit, and deletion of applications from the
# server. At present, these administrative routes are not integrated into
# Mastodon, and as such, we've disabled them by always return a 403 forbidden
# response for them. This does not affect the ability for users to manage
# their own OAuth Applications.
admin_authenticator
do
current_user
&
.
admin?
||
redirect_to
(
new_user_session_url
)
head
403
end
# Authorization Code expiration time (default 10 minutes).
...
...
This diff is collapsed.
Click to expand it.
spec/requests/disabled_oauth_endpoints_spec.rb
0 → 100644
+
83
−
0
View file @
6d43b632
# frozen_string_literal: true
require
'rails_helper'
describe
'Disabled OAuth routes'
do
# These routes are disabled via the doorkeeper configuration for
# `admin_authenticator`, as these routes should only be accessible by server
# administrators. For now, these routes are not properly designed and
# integrated into Mastodon, so we're disabling them completely
describe
'GET /oauth/applications'
do
it
'returns 403 forbidden'
do
get
oauth_applications_path
expect
(
response
).
to
have_http_status
(
403
)
end
end
describe
'POST /oauth/applications'
do
it
'returns 403 forbidden'
do
post
oauth_applications_path
expect
(
response
).
to
have_http_status
(
403
)
end
end
describe
'GET /oauth/applications/new'
do
it
'returns 403 forbidden'
do
get
new_oauth_application_path
expect
(
response
).
to
have_http_status
(
403
)
end
end
describe
'GET /oauth/applications/:id'
do
let
(
:application
)
{
Fabricate
(
:application
,
scopes:
'read'
)
}
it
'returns 403 forbidden'
do
get
oauth_application_path
(
application
)
expect
(
response
).
to
have_http_status
(
403
)
end
end
describe
'PATCH /oauth/applications/:id'
do
let
(
:application
)
{
Fabricate
(
:application
,
scopes:
'read'
)
}
it
'returns 403 forbidden'
do
patch
oauth_application_path
(
application
)
expect
(
response
).
to
have_http_status
(
403
)
end
end
describe
'PUT /oauth/applications/:id'
do
let
(
:application
)
{
Fabricate
(
:application
,
scopes:
'read'
)
}
it
'returns 403 forbidden'
do
put
oauth_application_path
(
application
)
expect
(
response
).
to
have_http_status
(
403
)
end
end
describe
'DELETE /oauth/applications/:id'
do
let
(
:application
)
{
Fabricate
(
:application
,
scopes:
'read'
)
}
it
'returns 403 forbidden'
do
delete
oauth_application_path
(
application
)
expect
(
response
).
to
have_http_status
(
403
)
end
end
describe
'GET /oauth/applications/:id/edit'
do
let
(
:application
)
{
Fabricate
(
:application
,
scopes:
'read'
)
}
it
'returns 403 forbidden'
do
get
edit_oauth_application_path
(
application
)
expect
(
response
).
to
have_http_status
(
403
)
end
end
end
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