Skip to content

Commit

Permalink
Remove the existing config flag for auth on download routes
Browse files Browse the repository at this point in the history
Part of #103
  • Loading branch information
turt2live committed Jun 16, 2018
1 parent 44538f4 commit 12c4c78
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 23 deletions.
1 change: 0 additions & 1 deletion config.sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ database:
# not listed here will not be able to upload media.
homeservers:
- name: t2bot.io # This should match the Host header given to the media repo
downloadRequiresAuth: false # Set to true to require auth on downloads and identicons
csApi: "https://t2bot.io/" # The base URL to where the homeserver can actually be reached
backoffAt: 10 # The number of consecutive failures in calling this homeserver before the
# media repository will start backing off. This defaults to 10 if not given.
Expand Down
7 changes: 0 additions & 7 deletions src/github.com/turt2live/matrix-media-repo/api/r0/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/turt2live/matrix-media-repo/api"
"github.com/turt2live/matrix-media-repo/common"
"github.com/turt2live/matrix-media-repo/old_middle_layer/media_cache"
"github.com/turt2live/matrix-media-repo/util"
)

type DownloadMediaResponse struct {
Expand All @@ -21,12 +20,6 @@ type DownloadMediaResponse struct {
}

func DownloadMedia(r *http.Request, log *logrus.Entry, user api.UserInfo) interface{} {
hs := util.GetHomeserverConfig(r.Host)
if hs.DownloadRequiresAuth && user.UserId == "" {
log.Warn("Homeserver requires authenticated downloads - denying request")
return api.AuthFailed()
}

params := mux.Vars(r)

server := params["server"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,13 @@ import (
"github.com/sirupsen/logrus"
"github.com/turt2live/matrix-media-repo/api"
"github.com/turt2live/matrix-media-repo/common/config"
"github.com/turt2live/matrix-media-repo/util"
)

type IdenticonResponse struct {
Avatar io.Reader
}

func Identicon(r *http.Request, log *logrus.Entry, user api.UserInfo) interface{} {
hs := util.GetHomeserverConfig(r.Host)
if hs.DownloadRequiresAuth && user.UserId == "" {
log.Warn("Homeserver requires authenticated downloads - denying request")
return api.AuthFailed()
}

if !config.Get().Identicons.Enabled {
return api.NotFoundError()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,9 @@ import (
"github.com/turt2live/matrix-media-repo/common"
"github.com/turt2live/matrix-media-repo/common/config"
"github.com/turt2live/matrix-media-repo/old_middle_layer/media_cache"
"github.com/turt2live/matrix-media-repo/util"
)

func ThumbnailMedia(r *http.Request, log *logrus.Entry, user api.UserInfo) interface{} {
hs := util.GetHomeserverConfig(r.Host)
if hs.DownloadRequiresAuth && user.UserId == "" {
log.Warn("Homeserver requires authenticated downloads - denying request")
return api.AuthFailed()
}

params := mux.Vars(r)

server := params["server"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ var Runtime = &runtimeConfig{}

type HomeserverConfig struct {
Name string `yaml:"name"`
DownloadRequiresAuth bool `yaml:"downloadRequiresAuth"`
ClientServerApi string `yaml:"csApi"`
BackoffAt int `yaml:"backoffAt"`
}
Expand Down

0 comments on commit 12c4c78

Please sign in to comment.