Fix #339: Subsonic API login is now case insensitive
This commit is contained in:
parent
002f3a9507
commit
281bef48bf
|
@ -19,7 +19,7 @@ def authenticate(username, password):
|
||||||
password = password.replace("enc:", "", 1)
|
password = password.replace("enc:", "", 1)
|
||||||
password = binascii.unhexlify(password).decode("utf-8")
|
password = binascii.unhexlify(password).decode("utf-8")
|
||||||
user = User.objects.get(
|
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):
|
except (User.DoesNotExist, binascii.Error):
|
||||||
raise exceptions.AuthenticationFailed("Wrong username or password.")
|
raise exceptions.AuthenticationFailed("Wrong username or password.")
|
||||||
|
|
|
@ -63,3 +63,15 @@ def test_auth_with_inactive_users(api_request, factories):
|
||||||
authenticator = authentication.SubsonicAuthentication()
|
authenticator = authentication.SubsonicAuthentication()
|
||||||
with pytest.raises(exceptions.AuthenticationFailed):
|
with pytest.raises(exceptions.AuthenticationFailed):
|
||||||
authenticator.authenticate(request)
|
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
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Subsonic API login is now case insensitive (#339)
|
Loading…
Reference in New Issue