Skip to content
Snippets Groups Projects
Verified Commit 281bef48 authored by Eliot Berriot's avatar Eliot Berriot
Browse files

Fix #339: Subsonic API login is now case insensitive

parent 002f3a95
No related branches found
No related tags found
No related merge requests found
......@@ -19,7 +19,7 @@ def authenticate(username, password):
password = password.replace("enc:", "", 1)
password = binascii.unhexlify(password).decode("utf-8")
user = User.objects.get(
username=username, is_active=True, subsonic_api_token=password
username__iexact=username, is_active=True, subsonic_api_token=password
)
except (User.DoesNotExist, binascii.Error):
raise exceptions.AuthenticationFailed("Wrong username or password.")
......
......@@ -63,3 +63,15 @@ def test_auth_with_inactive_users(api_request, factories):
authenticator = authentication.SubsonicAuthentication()
with pytest.raises(exceptions.AuthenticationFailed):
authenticator.authenticate(request)
def test_auth_case_insensitive(api_request, factories):
user = factories["users.User"](username="Hello")
user.subsonic_api_token = "password"
user.save()
request = api_request.get("/", {"u": "hello", "p": "password"})
authenticator = authentication.SubsonicAuthentication()
u, _ = authenticator.authenticate(request)
assert user == u
Subsonic API login is now case insensitive (#339)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment