-
-
Notifications
You must be signed in to change notification settings - Fork 763
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Prevent login via credentials when Auth Method is Mealie (#4370)
- Loading branch information
Showing
4 changed files
with
47 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
tests/unit_tests/core/security/providers/test_credentials_provider.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from mealie.core.security.providers.credentials_provider import CredentialsProvider | ||
from mealie.db.models.users.users import AuthMethod | ||
from mealie.schema.user.auth import CredentialsRequest | ||
from tests.utils.fixture_schemas import TestUser | ||
|
||
|
||
def test_login(unique_user: TestUser): | ||
data = {"username": unique_user.username, "password": unique_user.password} | ||
auth_provider = CredentialsProvider(unique_user.repos.session, CredentialsRequest(**data)) | ||
|
||
assert auth_provider.authenticate() is not None | ||
|
||
|
||
def test_login_incorrect_auth_method(unique_user: TestUser): | ||
db = unique_user.repos | ||
user = db.users.get_by_username(unique_user.username) | ||
user.auth_method = AuthMethod.OIDC | ||
db.users.update(unique_user.user_id, user) | ||
|
||
data = {"username": unique_user.username, "password": unique_user.password} | ||
auth_provider = CredentialsProvider(db.session, CredentialsRequest(**data)) | ||
|
||
assert auth_provider.authenticate() is None |