Skip to content

Commit f1501a7

Browse files
committed
Add basic auth support to rss/atom feeds
1 parent e94f37f commit f1501a7

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

services/auth/auth.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ func isAttachmentDownload(req *http.Request) bool {
3232
return strings.HasPrefix(req.URL.Path, "/attachments/") && req.Method == "GET"
3333
}
3434

35+
// isFeed checks if the request targets a rss/atom feed
36+
func isFeed(req *http.Request) bool {
37+
return strings.HasSuffix(req.URL.Path, ".rss") || strings.HasSuffix(req.URL.Path, ".atom")
38+
}
39+
3540
// isContainerPath checks if the request targets the container endpoint
3641
func isContainerPath(req *http.Request) bool {
3742
return strings.HasPrefix(req.URL.Path, "/v2/")

services/auth/basic.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ func (b *Basic) Name() string {
4848
// name/token on successful validation.
4949
// Returns nil if header is empty or validation fails.
5050
func (b *Basic) Verify(req *http.Request, w http.ResponseWriter, store DataStore, sess SessionStore) (*user_model.User, error) {
51-
// Basic authentication should only fire on API, Download or on Git or LFSPaths
52-
if !middleware.IsAPIPath(req) && !isContainerPath(req) && !isAttachmentDownload(req) && !isGitRawOrAttachOrLFSPath(req) {
51+
// Basic authentication should only fire on API, rss/atom feeds, Download or on Git or LFSPaths
52+
if !middleware.IsAPIPath(req) && !isFeed(req) && !isContainerPath(req) && !isAttachmentDownload(req) && !isGitRawOrAttachOrLFSPath(req) {
5353
return nil, nil
5454
}
5555

0 commit comments

Comments
 (0)