mirror of
https://github.com/open-webui/open-webui
synced 2025-02-20 20:07:28 +00:00
Fixed security vulnerability: now LDAP password hashes are not stored, same as trusted header auth.
LDAP users role now getting DEFAULT_USER_ROLE, not "pending".
This commit is contained in:
parent
6088acf36d
commit
b1237cf389
@ -238,10 +238,20 @@ async def ldap_auth(request: Request, response: Response, form_data: LdapForm):
|
||||
|
||||
user = Users.get_user_by_email(mail)
|
||||
if not user:
|
||||
|
||||
try:
|
||||
hashed = get_password_hash(form_data.password)
|
||||
user = Auths.insert_new_auth(mail, hashed, cn)
|
||||
role = (
|
||||
"admin"
|
||||
if Users.get_num_users() == 0
|
||||
else request.app.state.config.DEFAULT_USER_ROLE
|
||||
)
|
||||
|
||||
user = Auths.insert_new_auth(
|
||||
mail,
|
||||
str(uuid.uuid4()),
|
||||
cn,
|
||||
None,
|
||||
role,
|
||||
)
|
||||
|
||||
if not user:
|
||||
raise HTTPException(
|
||||
@ -253,7 +263,7 @@ async def ldap_auth(request: Request, response: Response, form_data: LdapForm):
|
||||
except Exception as err:
|
||||
raise HTTPException(500, detail=ERROR_MESSAGES.DEFAULT(err))
|
||||
|
||||
user = Auths.authenticate_user(mail, password=str(form_data.password))
|
||||
user = Auths.authenticate_user_by_trusted_header(mail)
|
||||
|
||||
if user:
|
||||
token = create_token(
|
||||
|
Loading…
Reference in New Issue
Block a user