-
Notifications
You must be signed in to change notification settings - Fork 2
feat: merge upstream 2.63.2 #101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
59ca0c3
cfa6c58
4094fb3
24781ba
e7ea1ad
550a73b
785b7ab
1154b49
08c8ede
f0f2f1f
87f1d00
3032a1f
004488c
1053aac
b594d4d
3a08949
87cfead
d441b28
8fee256
a8fe32f
b8da36e
08d7a15
2b82612
b9df030
854e537
942d598
a428901
099dfb0
2957b46
ff2f004
489af40
e193d43
6a76dfe
c94870f
5feaf66
1f7904d
88b97de
f67bccf
e5bc0d3
5e8f5be
b09960e
95e6ed7
804b14b
3cad9a2
63a76ef
0467326
7e78ad9
3169a14
200d501
9940bdd
2470b9e
7b16e2d
e3d00d5
aa80909
31194fb
8dc618a
a40f806
148b3c5
7ed1425
c950a57
4af3f85
177c7cf
d7b00ce
9f56826
a7dc7bf
8598db2
8ee5576
4d9e6b8
cbcf708
c01b6a8
3cb21c7
df63cb5
490e5bb
6700a98
6dcef07
f5f8b60
f04af0c
0542fc0
ef2e999
be8ba18
79875ba
27afbb8
3c5d366
6f772f2
846fb33
2170942
858eb42
c21af07
4bd7d69
a63573b
09a2616
6aea227
fc80f4f
b5f9707
811cf2d
6d44b3a
4812536
ae72f93
432f3e6
0616f68
8f81b77
8d8cd26
2368e46
b6a4fb1
126227b
d9f9460
c406bda
a8fc165
860c19d
0f39bd0
7a16129
2f805de
876cdb3
65a837d
7dbf7a3
8adf127
1e03fea
f13c7c8
29c73ea
871f337
0fadf28
23e84c9
0321415
9b80a9a
dd53644
caabdc1
2a89f1b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -14,6 +14,10 @@ import ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // MethodJSONAuth is used to identify json auth. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const MethodJSONAuth settings.AuthMethod = "json" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // dummyHash is used to prevent user enumeration timing attacks. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // It MUST be a valid bcrypt hash. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const dummyHash = "$2a$10$O4mEMeOL/nit6zqe.WQXauLRbRlzb3IgLHsa26Pf0N/GiU9b.wK1m" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type jsonCred struct { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Password string `json:"password"` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Username string `json:"username"` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -52,7 +56,17 @@ func (a JSONAuth) Auth(r *http.Request, usr users.Store, _ *settings.Settings, s | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| u, err := usr.Get(srv.Root, cred.Username) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if err != nil || !users.CheckPwd(cred.Password, u.Password) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| hash := dummyHash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if err == nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| hash = u.Password | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if !users.CheckPwd(cred.Password, hash) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return nil, os.ErrPermission | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return nil, os.ErrPermission | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
58
to
70
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Store failures are being masked as invalid credentials. Current flow turns all Proposed fix (keep anti-enumeration for not-found, preserve real errors) import (
+ "errors"
"encoding/json"
"net/http"
"net/url"
"os"
"strings"
+ fberrors "github.com/filebrowser/filebrowser/v2/errors"
"github.com/filebrowser/filebrowser/v2/settings"
"github.com/filebrowser/filebrowser/v2/users"
)
@@
u, err := usr.Get(srv.Root, cred.Username)
+ if err != nil && !errors.Is(err, fberrors.ErrNotExist) {
+ return nil, err
+ }
hash := dummyHash
- if err == nil {
+ if err == nil && u != nil {
hash = u.Password
}
if !users.CheckPwd(cred.Password, hash) {
return nil, os.ErrPermission
}
- if err != nil {
+ if err != nil || u == nil {
return nil, os.ErrPermission
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
user.dateFormathook value is currently ignored due to whitelist filtering.Line 237 reads
user.dateFormat, butGetValuesdrops unknown keys andvalidHookFieldsdoes not include this field. So hook-provided date format updates never apply.Proposed fix
var validHookFields = []string{ "hook.action", "user.scope", "user.locale", "user.viewMode", "user.singleClick", "user.redirectAfterCopyMove", "user.sorting.by", "user.sorting.asc", "user.commands", + "user.dateFormat", "user.hideDotfiles", "user.perm.admin", "user.perm.execute", "user.perm.create", "user.perm.rename", "user.perm.modify", "user.perm.delete", "user.perm.share", "user.perm.download", }📝 Committable suggestion
🤖 Prompt for AI Agents