Browse Source

[dav] configurable auth realm

cgars 7 năm trước cách đây
mục cha
commit
dd545c8b5a
3 tập tin đã thay đổi với 6 bổ sung3 xóa
  1. 2 0
      conf/app.ini
  2. 1 1
      pkg/dav/dav.go
  3. 3 2
      pkg/setting/setting.go

+ 2 - 0
conf/app.ini

@@ -514,6 +514,8 @@ DOI_BASE = 123454/789.gty
 ON = false
 ; is login required for webdav
 LOGGED = true
+; authorisation REALM
+AUTH_REALM = localhost
 
 [cliconfig]
 RSA_HOST_KEY = notset

+ 1 - 1
pkg/dav/dav.go

@@ -345,7 +345,7 @@ func getROwnerID(path string) (int64, error) {
 }
 
 func Webdav401(c *gctx.Context) {
-	c.Header().Add("WWW-Authenticate", fmt.Sprintf("Basic realm=\"%s\"", setting.AppURL))
+	c.Header().Add("WWW-Authenticate", fmt.Sprintf("Basic realm=\"%s\"", setting.WebDav.AuthRealm))
 	c.WriteHeader(http.StatusUnauthorized)
 	return
 }

+ 3 - 2
pkg/setting/setting.go

@@ -335,8 +335,9 @@ var (
 	}
 
 	WebDav struct {
-		On     bool
-		Logged bool
+		On        bool
+		Logged    bool
+		AuthRealm string
 	}
 )