Skip to content

Commit

Permalink
Fix ignoredHosts (#630)
Browse files Browse the repository at this point in the history
  • Loading branch information
turt2live authored Dec 23, 2024
1 parent 24b3ca5 commit ea15250
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
* Ensure the request parameters are correctly set for authenticated media client requests.
* Ensure remote signing keys expire after at most 7 days.
* Fixed parsing of `Authorization` headers for federated servers.
* Ensure `ignoredHosts` is applied to unauthenticated requests.

## [1.3.7] - July 30, 2024

Expand Down
4 changes: 2 additions & 2 deletions api/r0/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ func DownloadMedia(r *http.Request, rctx rcontext.RequestContext, auth _apimeta.
"authServerName": auth.Server.ServerName,
})

if auth.User.UserId != "" {
if !util.IsGlobalAdmin(auth.User.UserId) && util.IsHostIgnored(server) {
if util.IsHostIgnored(server) {
if auth.User.UserId == "" || !util.IsGlobalAdmin(auth.User.UserId) {
rctx.Log.Warn("Request blocked due to domain being ignored.")
return _responses.MediaBlocked()
}
Expand Down
4 changes: 2 additions & 2 deletions api/r0/thumbnail.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ func ThumbnailMedia(r *http.Request, rctx rcontext.RequestContext, auth _apimeta
"authServerName": auth.Server.ServerName,
})

if auth.User.UserId != "" {
if !util.IsGlobalAdmin(auth.User.UserId) && util.IsHostIgnored(server) {
if util.IsHostIgnored(server) {
if auth.User.UserId == "" || !util.IsGlobalAdmin(auth.User.UserId) {
rctx.Log.Warn("Request blocked due to domain being ignored.")
return _responses.MediaBlocked()
}
Expand Down
2 changes: 1 addition & 1 deletion api/unstable/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func MediaInfo(r *http.Request, rctx rcontext.RequestContext, user _apimeta.User
"allowRemote": downloadRemote,
})

if !util.IsGlobalAdmin(user.UserId) && util.IsHostIgnored(server) {
if util.IsHostIgnored(server) && !util.IsGlobalAdmin(user.UserId) {
rctx.Log.Warn("Request blocked due to domain being ignored.")
return _responses.MediaBlocked()
}
Expand Down
2 changes: 1 addition & 1 deletion api/unstable/local_copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func LocalCopy(r *http.Request, rctx rcontext.RequestContext, user _apimeta.User
"allowRemote": downloadRemote,
})

if !util.IsGlobalAdmin(user.UserId) && util.IsHostIgnored(server) {
if util.IsHostIgnored(server) && !util.IsGlobalAdmin(user.UserId) {
rctx.Log.Warn("Request blocked due to domain being ignored.")
return _responses.MediaBlocked()
}
Expand Down

0 comments on commit ea15250

Please sign in to comment.