Bug 54431 - [Kelvin] Token request with authorized user and wrong password leads to AttributeError -> HTTP 500
Summary: [Kelvin] Token request with authorized user and wrong password leads to Attri...
Status: CLOSED FIXED
Alias: None
Product: UCS@school
Classification: Unclassified
Component: HTTP-API (Kelvin)
Version: UCS@school 5.0
Hardware: Other Linux
: P5 normal
Target Milestone: ---
Assignee: Daniel Tröder
QA Contact: Felix Botner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-02-08 18:16 CET by Daniel Tröder
Modified: 2022-03-03 16:09 CET (History)
2 users (show)

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 3: Simply Wrong: The implementation doesn't match the docu
Who will be affected by this bug?: 1: Will affect a very few installed domains
How will those affected feel about the bug?: 2: A Pain – users won’t like this once they notice it
User Pain: 0.034
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Customer ID:
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Tröder univentionstaff 2022-02-08 18:16:06 CET
When a token is requested from the Kelvin REST API and the user is authorized (member of the Kelvin admin group) but the password is wrong, a HTTP 500 happens, because of an AttributeError.

Fix the AttributeError. HTTP 401 should be returned for a wrong password.
Comment 1 Daniel Tröder univentionstaff 2022-02-08 19:03:18 CET
Fixed the bug.

Additionally changed the order to only retrieve the admin group members, when the users password has been verified.

[feature/kelvin a12dbcc53] Bug #54431: fix token request with authorized user and wrong password leading to AttributeError (HTTP 500)

The Docker image build failed because the versions of bacl in the container and in the pre-commmit configuration mismatched. They are now the same:

[feature/kelvin 272c784eb] Bug #54431: use same versions of black, isort and flake8 in Docker container build and on dev machine

A new Docker image (c4b7099bb691) has been built for version 1.5.3 and a new app version (1.5.3) was created in the test appcenter: http://appcenter-test.software-univention.de/univention-repository/4.4/maintained/component/ucsschool-kelvin-rest-api_20220208185832/
Comment 2 Felix Botner univentionstaff 2022-02-11 12:38:38 CET
> curl  -X 'POST'  "https://$(hostname -f)/ucsschool/kelvin/token" -d 'username=Administrator' -d 'password=wrong'
< HTTP/1.1 500 Internal Server Error

after the update to

> curl   -X 'POST'  "https://$(hostname -f)/ucsschool/kelvin/token" -d 'username=Administrator' -d 'password=wrong'
{"detail":"Incorrect username or password"}
< HTTP/1.1 401 Unauthorized

OK - 401 Unauthorized for wrong password or username
OK - get token with correct password
OK - app update
OK - changelog

looks good to me
Comment 3 Tobias Wenzel univentionstaff 2022-03-03 16:09:10 CET
Released with version 1.5.3

If error occurs again, please clone this bug.