Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
8e742e10
Commit
8e742e10
authored
Jan 05, 2021
by
Igor Wiedler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Propagate remote_ip through ApplicationContext for API requests
parent
f20ee83e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
0 deletions
+4
-0
lib/api/api.rb
lib/api/api.rb
+1
-0
lib/api/internal/base.rb
lib/api/internal/base.rb
+1
-0
spec/requests/api/api_spec.rb
spec/requests/api/api_spec.rb
+2
-0
No files found.
lib/api/api.rb
View file @
8e742e10
...
...
@@ -59,6 +59,7 @@ module API
project:
->
{
@project
},
namespace:
->
{
@group
},
caller_id:
route
.
origin
,
remote_ip:
request
.
ip
,
feature_category:
feature_category
)
end
...
...
lib/api/internal/base.rb
View file @
8e742e10
...
...
@@ -16,6 +16,7 @@ module API
user:
->
{
actor
&
.
user
},
project:
->
{
project
},
caller_id:
route
.
origin
,
remote_ip:
request
.
ip
,
feature_category:
feature_category
)
end
...
...
spec/requests/api/api_spec.rb
View file @
8e742e10
...
...
@@ -102,6 +102,7 @@ RSpec.describe API::API do
Labkit
::
Context
.
current
.
to_h
.
tap
do
|
log_context
|
expect
(
log_context
).
to
match
(
'correlation_id'
=>
an_instance_of
(
String
),
'meta.caller_id'
=>
'/api/:version/projects/:id/issues'
,
'meta.remote_ip'
=>
an_instance_of
(
String
),
'meta.project'
=>
project
.
full_path
,
'meta.root_namespace'
=>
project
.
namespace
.
full_path
,
'meta.user'
=>
user
.
username
,
...
...
@@ -117,6 +118,7 @@ RSpec.describe API::API do
Labkit
::
Context
.
current
.
to_h
.
tap
do
|
log_context
|
expect
(
log_context
).
to
match
(
'correlation_id'
=>
an_instance_of
(
String
),
'meta.caller_id'
=>
'/api/:version/users'
,
'meta.remote_ip'
=>
an_instance_of
(
String
),
'meta.feature_category'
=>
'users'
)
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment