1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-07-24 15:49:42 +02:00

Feature: Add "Authentication Method" to allow existing users to sign in with LDAP (#2143)

* adds authentication method for users

* fix db migration with postgres

* tests for auth method

* update migration ids

* hide auth method on user creation form

* (docs): Added documentation for the new authentication method

* update migration

* add  to auto-form instead of having hidden fields
This commit is contained in:
Carter 2023-02-26 13:12:16 -06:00 committed by GitHub
parent 39012adcc1
commit 2e6ad5da8e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 213 additions and 24 deletions

View file

@ -3,6 +3,9 @@ from typing import Generator
from pytest import fixture
from starlette.testclient import TestClient
from mealie.db.db_setup import session_context
from mealie.db.models.users.users import AuthMethod
from mealie.repos.all_repositories import get_repositories
from tests import utils
from tests.utils import api_routes
@ -181,3 +184,25 @@ def user_token(admin_token, api_client: TestClient):
# Log in as this user
form_data = {"username": create_data["email"], "password": "useruser"}
return utils.login(form_data, api_client)
@fixture(scope="module")
def ldap_user():
# Create an LDAP user directly instead of using TestClient since we don't have
# a LDAP service set up
with session_context() as session:
db = get_repositories(session)
user = db.users.create(
{
"username": utils.random_string(10),
"password": "mealie_password_not_important",
"full_name": utils.random_string(10),
"email": utils.random_string(10),
"admin": False,
"auth_method": AuthMethod.LDAP,
}
)
yield user
with session_context() as session:
db = get_repositories(session)
db.users.delete(user.id)