mirror of https://github.com/Xhofe/alist
fix: disallow users with 2FA enabled to access WebDAV
WebDAV server doesn't validate 2FA. This makes 2FA useless to some extent. I think users with 2FA enabled shouldn't access webdav using only password. Although this can be manually solved by changing user permissions, Alist doesn't support to change permissions of admin. BREAKING CHANGE: Users with 2FA enabled will not be able to access WebDAV.pull/7097/head
parent
b910b8917f
commit
51365d066c
|
@ -56,6 +56,10 @@ func (u *User) IsAdmin() bool {
|
|||
return u.Role == ADMIN
|
||||
}
|
||||
|
||||
func (u *User) IsOtpEnabled() bool {
|
||||
return u.OtpSecret != ""
|
||||
}
|
||||
|
||||
func (u *User) ValidateRawPassword(password string) error {
|
||||
return u.ValidatePwdStaticHash(StaticHash(password))
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ func WebDAVAuth(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
user, err := op.GetUserByName(username)
|
||||
if err != nil || user.ValidateRawPassword(password) != nil {
|
||||
if err != nil || user.IsOtpEnabled() || user.ValidateRawPassword(password) != nil {
|
||||
if c.Request.Method == "OPTIONS" {
|
||||
c.Set("user", guest)
|
||||
c.Next()
|
||||
|
|
Loading…
Reference in New Issue