Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
miniflux
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
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
miniflux
Commits
4e07b549
Commit
4e07b549
authored
4 years ago
by
Frédéric Guillot
Browse files
Options
Downloads
Patches
Plain Diff
Fever API: add client IP in middleware logs
parent
019cf797
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fever/middleware.go
+4
-3
4 additions, 3 deletions
fever/middleware.go
with
4 additions
and
3 deletions
fever/middleware.go
+
4
−
3
View file @
4e07b549
...
@@ -24,9 +24,10 @@ func newMiddleware(s *storage.Storage) *middleware {
...
@@ -24,9 +24,10 @@ func newMiddleware(s *storage.Storage) *middleware {
func
(
m
*
middleware
)
serve
(
next
http
.
Handler
)
http
.
Handler
{
func
(
m
*
middleware
)
serve
(
next
http
.
Handler
)
http
.
Handler
{
return
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
return
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
clientIP
:=
request
.
ClientIP
(
r
)
apiKey
:=
r
.
FormValue
(
"api_key"
)
apiKey
:=
r
.
FormValue
(
"api_key"
)
if
apiKey
==
""
{
if
apiKey
==
""
{
logger
.
Info
(
"[Fever] No API key provided"
)
logger
.
Info
(
"[Fever]
[ClientIP=%s]
No API key provided"
,
clientIP
)
json
.
OK
(
w
,
r
,
newAuthFailureResponse
())
json
.
OK
(
w
,
r
,
newAuthFailureResponse
())
return
return
}
}
...
@@ -39,12 +40,12 @@ func (m *middleware) serve(next http.Handler) http.Handler {
...
@@ -39,12 +40,12 @@ func (m *middleware) serve(next http.Handler) http.Handler {
}
}
if
user
==
nil
{
if
user
==
nil
{
logger
.
Info
(
"[Fever] No user found with this API key"
)
logger
.
Info
(
"[Fever]
[ClientIP=%s]
No user found with this API key"
,
clientIP
)
json
.
OK
(
w
,
r
,
newAuthFailureResponse
())
json
.
OK
(
w
,
r
,
newAuthFailureResponse
())
return
return
}
}
logger
.
Info
(
"[Fever] User #%d is authenticated with user agent %q"
,
user
.
ID
,
r
.
UserAgent
())
logger
.
Info
(
"[Fever]
[ClientIP=%s]
User #%d is authenticated with user agent %q"
,
clientIP
,
user
.
ID
,
r
.
UserAgent
())
m
.
store
.
SetLastLogin
(
user
.
ID
)
m
.
store
.
SetLastLogin
(
user
.
ID
)
ctx
:=
r
.
Context
()
ctx
:=
r
.
Context
()
...
...
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