Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kimai2_users title field length limit will cause error logging in via SAML if SAML provided title is too long. #1562

Closed
timlegge opened this issue Mar 16, 2020 · 7 comments · Fixed by #1580
Labels

Comments

@timlegge
Copy link

Describe the bug

kimai2_users title field length limit will cause error logging in via SAML if SAML provided title is too long.

Probably should truncate and add the row.

To Reproduce
Steps to reproduce the behavior:

  1. Create user in SAML provider with a long tltle
  2. Attempt to login
  3. See error

request.CRITICAL: Uncaught PHP Exception RuntimeException: "Failed creating or hydrating user "[email protected]": An exception occurred while executing 'INSERT INTO kimai2_users (username, username_canonical, email, email_canonical, enabled, salt, password, last_login, confirmation_token, password_requested_at, roles, alias, registration_date, title, avatar, api_token, auth) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' with params ["SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'title' at row 1 at /opt/kimai/src/Saml/Controller/SamlController.php:52)"} []

Logfile

Screenshots
Login says Something is wrong

Desktop/Smartphone
N/A

Additional context
Pre 1.8 with SAML support Commit

@kevinpapst
Copy link
Member

Hm, well the title field was not supposed to hold arbitrary data.

What do you propose?
Cutting off the title?
Adding some parsing logic to the SAML mapping config, to truncate a string at position X?

@timlegge
Copy link
Author

In our case I had the user's title truncated on the AD side.

First maybe a documentation entry on the length of the fields. Then I would be fine with truncating the data to the field size.

I will look into the SAML provider to see whether there is an ability to truncate the field before it is sent to Kimai.

Tim

@kevinpapst
Copy link
Member

There is a missing validator, thanks for the info! A SQL error shouldn't bubble up.

Lengths can be found here:
https://github.com/kevinpapst/kimai2/blob/master/src/Entity/User.php#L72

Maybe truncating needs to be added to the user class directly, which I don't really like (silently changing user data is not a good approach).

But in that case it might okay, as users can come from multi sources and are not necessarily created in Kimai.

@timlegge
Copy link
Author

timlegge commented Mar 16, 2020 via email

@adrianrudnik
Copy link
Contributor

@kevinpapst Regarding the validation constraint: Is there any reason to have it at 50 except to keep the title short for display purposes? Same goes for the $alias which is varchar(60) but the validator triggers at 160 characters.

Maybe have a secure limit through entity constraints (something like 512/1k for varchar) if it comes through APIs or internals and use a different constraint inside forms, to indicate some sensible length towards the user?

@kevinpapst
Copy link
Member

Honestly: I can't remember ... the user entity is from the very early days and wasn't really changed since then. Validators have to be added obviously, they are missing.
Having more eyes on Kimai will help to smooth out such points.

I don't think that there is a real benefit in increasing these field sizes (to more than 100 chars). The display space is limited and both title and alias are "UI goodies", not something that is really required.
If we allow 1024 chars, the UI should not break if they were really used.

@lock
Copy link

lock bot commented May 20, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. If you use Kimai on a daily basis, please consider donating to support further development of Kimai.

@lock lock bot locked and limited conversation to collaborators May 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants