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
9467b900
Commit
9467b900
authored
8 years ago
by
Eugen Rochko
Browse files
Options
Downloads
Patches
Plain Diff
Make cookies https-only if LOCAL_HTTPS is true, set X-Frame-Options to DENY,
add permissive CORS to API controllers
parent
0a6b5e2c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/controllers/api_controller.rb
+8
-0
8 additions, 0 deletions
app/controllers/api_controller.rb
config/application.rb
+4
-0
4 additions, 0 deletions
config/application.rb
config/initializers/session_store.rb
+1
-1
1 addition, 1 deletion
config/initializers/session_store.rb
with
13 additions
and
1 deletion
app/controllers/api_controller.rb
+
8
−
0
View file @
9467b900
...
...
@@ -4,6 +4,7 @@ class ApiController < ApplicationController
skip_before_action
:verify_authenticity_token
before_action
:set_rate_limit_headers
before_action
:set_cors_headers
rescue_from
ActiveRecord
::
RecordInvalid
do
|
e
|
render
json:
{
error:
e
.
to_s
},
status:
422
...
...
@@ -46,6 +47,13 @@ class ApiController < ApplicationController
response
.
headers
[
'X-RateLimit-Reset'
]
=
(
now
+
(
match_data
[
:period
]
-
now
.
to_i
%
match_data
[
:period
])).
to_s
end
def
set_cors_headers
response
.
headers
[
'Access-Control-Allow-Origin'
]
=
'*'
response
.
headers
[
'Access-Control-Allow-Methods'
]
=
'POST, PUT, DELETE, GET, OPTIONS'
response
.
headers
[
'Access-Control-Request-Method'
]
=
'*'
response
.
headers
[
'Access-Control-Allow-Headers'
]
=
'Origin, X-Requested-With, Content-Type, Accept, Authorization'
end
def
current_resource_owner
User
.
find
(
doorkeeper_token
.
resource_owner_id
)
if
doorkeeper_token
end
...
...
This diff is collapsed.
Click to expand it.
config/application.rb
+
4
−
0
View file @
9467b900
...
...
@@ -36,5 +36,9 @@ module Mastodon
config
.
to_prepare
do
Doorkeeper
::
AuthorizationsController
.
layout
'auth'
end
config
.
action_dispatch
.
default_headers
=
{
'X-Frame-Options'
=>
'DENY'
}
end
end
This diff is collapsed.
Click to expand it.
config/initializers/session_store.rb
+
1
−
1
View file @
9467b900
# Be sure to restart your server when you modify this file.
Rails
.
application
.
config
.
session_store
:cookie_store
,
key:
'_mastodon_session'
Rails
.
application
.
config
.
session_store
:cookie_store
,
key:
'_mastodon_session'
,
secure:
(
ENV
[
'LOCAL_HTTPS'
]
==
'true'
)
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