Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
Newspapers Platform
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
labs-team
Newspapers Platform
Commits
f0740218
Commit
f0740218
authored
2 years ago
by
smayer
Browse files
Options
Downloads
Patches
Plain Diff
Add module for allowing requests from Labs domain
parent
128c86ed
No related branches found
Branches containing commit
No related tags found
1 merge request
!2
Merging development into onb as preparation for Annolyzer release
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/controllers/application_controller.rb
+1
-0
1 addition, 0 deletions
app/controllers/application_controller.rb
config/environments/development.rb
+0
-2
0 additions, 2 deletions
config/environments/development.rb
config/initializers/cors.rb
+16
-0
16 additions, 0 deletions
config/initializers/cors.rb
with
17 additions
and
2 deletions
app/controllers/application_controller.rb
+
1
−
0
View file @
f0740218
class
ApplicationController
<
ActionController
::
Base
include
Authentication
include
AddProxyRequestOrigin
def
send_file
File
.
open
(
"tmp/
#{
params
[
:filename
]
}
"
,
"r"
)
do
|
f
|
...
...
This diff is collapsed.
Click to expand it.
config/environments/development.rb
+
0
−
2
View file @
f0740218
...
...
@@ -76,6 +76,4 @@ Rails.application.configure do
# Allow Action Cable access from any origin.
config
.
action_cable
.
url
=
ENV
[
'NEP_CABLE_URL'
]
||
'http://127.0.0.1:3000/cable'
config
.
action_cable
.
allowed_request_origins
=
[
ENV
[
'NEP_LABS_DOMAIN'
],
'http://127.0.0.1:8001'
]
# Allow XHR/Ajax requests from different origin
config
.
action_controller
.
forgery_protection_origin_check
=
false
end
This diff is collapsed.
Click to expand it.
config/initializers/cors.rb
0 → 100644
+
16
−
0
View file @
f0740218
# Allow requests from Labs domain
module
AddProxyRequestOrigin
extend
ActionController
::
RequestForgeryProtection
allowed_request_origins
=
[
ENV
[
'NEP_LABS_DOMAIN'
],
'http://127.0.0.1:8001'
]
def
valid_request_origin?
# :doc:
if
forgery_protection_origin_check
# We accept blank origin headers because some user agents don't send it.
raise
InvalidAuthenticityToken
,
NULL_ORIGIN_MESSAGE
if
request
.
origin
==
"null"
request
.
origin
.
nil?
||
request
.
origin
==
request
.
base_url
||
request
.
origin
in
allowed_request_origins
else
true
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