mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-03 20:47:35 +03:00
sec(subsonic): authentication bypass in Subsonic API with non-existent username
Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
parent
70487a09f4
commit
09ae41a2da
4 changed files with 157 additions and 28 deletions
|
@ -50,14 +50,20 @@ func (r *userRepository) Get(id string) (*model.User, error) {
|
|||
sel := r.newSelect().Columns("*").Where(Eq{"id": id})
|
||||
var res model.User
|
||||
err := r.queryOne(sel, &res)
|
||||
return &res, err
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &res, nil
|
||||
}
|
||||
|
||||
func (r *userRepository) GetAll(options ...model.QueryOptions) (model.Users, error) {
|
||||
sel := r.newSelect(options...).Columns("*")
|
||||
res := model.Users{}
|
||||
err := r.queryAll(sel, &res)
|
||||
return res, err
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (r *userRepository) Put(u *model.User) error {
|
||||
|
@ -91,22 +97,29 @@ func (r *userRepository) FindFirstAdmin() (*model.User, error) {
|
|||
sel := r.newSelect(model.QueryOptions{Sort: "updated_at", Max: 1}).Columns("*").Where(Eq{"is_admin": true})
|
||||
var usr model.User
|
||||
err := r.queryOne(sel, &usr)
|
||||
return &usr, err
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &usr, nil
|
||||
}
|
||||
|
||||
func (r *userRepository) FindByUsername(username string) (*model.User, error) {
|
||||
sel := r.newSelect().Columns("*").Where(Expr("user_name = ? COLLATE NOCASE", username))
|
||||
var usr model.User
|
||||
err := r.queryOne(sel, &usr)
|
||||
return &usr, err
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &usr, nil
|
||||
}
|
||||
|
||||
func (r *userRepository) FindByUsernameWithPassword(username string) (*model.User, error) {
|
||||
usr, err := r.FindByUsername(username)
|
||||
if err == nil {
|
||||
_ = r.decryptPassword(usr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return usr, err
|
||||
_ = r.decryptPassword(usr)
|
||||
return usr, nil
|
||||
}
|
||||
|
||||
func (r *userRepository) UpdateLastLoginAt(id string) error {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue