🧑‍💻 Kernel serve CardDAV service on path /carddav/ (#12895)

* 🎨 add CardDAV server

* 🎨 change CardDAV principals path

* 🎨 implement load contacts feature

* 🎨 implement save contacts feature

* 🎨 implement address books CURD

* 🐛 fix CardDAV method `OPTIONS`

* 🎨 implement addresses CURD

* 🎨  implement CardDAV `REPORT` method

* 🎨 parse *.vcf file with multiple vCard
This commit is contained in:
Yingyi / 颖逸 2024-11-15 11:19:52 +08:00 committed by GitHub
parent 96194f7dae
commit c110b9ff13
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 1020 additions and 19 deletions

View file

@ -34,6 +34,11 @@ import (
"github.com/steambap/captcha"
)
var (
BasicAuthHeaderKey = "WWW-Authenticate"
BasicAuthHeaderValue = "Basic realm=\"SiYuan Authorization Require\", charset=\"UTF-8\""
)
func LogoutAuth(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
@ -300,8 +305,8 @@ func CheckAuth(c *gin.Context) {
}
// WebDAV BasicAuth Authenticate
if strings.HasPrefix(c.Request.RequestURI, "/webdav") {
c.Header("WWW-Authenticate", "Basic realm=Authorization Required")
if strings.HasPrefix(c.Request.RequestURI, "/webdav") || strings.HasPrefix(c.Request.RequestURI, "/carddav") {
c.Header(BasicAuthHeaderKey, BasicAuthHeaderValue)
c.AbortWithStatus(http.StatusUnauthorized)
return
}