SAML SSO with Authentik → Kimai: “Failed creating or hydrating user” for existing local users; attribute values replaced by schema URIs #5629
Replies: 2 comments 1 reply
-
|
Facing this issue. Existing users should be matched based on ID, and same user should be reused. |
Beta Was this translation helpful? Give feedback.
-
ObjectiveI already have some users existing in the DB. I want them to now use SAML Authentication using Authentik. ProblemI can't seem to be able to link them as-is, I may be forced to clean my database hence losing all my data. ErrorMy error code: [2025-12-10T20:09:20.696396+00:00] request.INFO: Matched route "saml_acs". {"route":"saml_acs","route_parameters":{"_route":"saml_acs","_controller":"App\\Controller\\Auth\\SamlController::assertionConsumerServiceAction"},"request_uri":"http://kimai.coldpeak.co/auth/saml/acs","method":"POST"} {"channel":"request"}
[2025-12-10T20:09:20.711444+00:00] app.CRITICAL: SAML login failed: Signature validation failed. SAML Response rejected [] {"channel":"app"}
[2025-12-10T20:09:20.712058+00:00] security.INFO: Authenticator failed. {"exception":"[object] (Symfony\\Component\\Security\\Core\\Exception\\AuthenticationException(code: 0): Signature validation failed. SAML Response rejected at /opt/kimai/src/Saml/SamlAuthenticator.php:92)","authenticator":"App\\Saml\\SamlAuthenticator"} {"channel":"security"}
[2025-12-10T20:09:44.348123+00:00] request.INFO: Matched route "saml_acs". {"route":"saml_acs","route_parameters":{"_route":"saml_acs","_controller":"App\\Controller\\Auth\\SamlController::assertionConsumerServiceAction"},"request_uri":"http://kimai.coldpeak.co/auth/saml/acs","method":"POST"} {"channel":"request"}
[2025-12-10T20:09:44.384996+00:00] app.ERROR: Validation Failed [] {"channel":"app"}
[2025-12-10T20:09:44.385315+00:00] security.INFO: Authenticator failed. {"exception":"[object] (Symfony\\Component\\Security\\Core\\Exception\\AuthenticationException(code: 0): Failed creating or hydrating user \"bazaz@grayhat.studio\": Validation Failed at /opt/kimai/src/Saml/SamlProvider.php:56)","authenticator":"App\\Saml\\SamlAuthenticator"} {"channel":"security"}Solutions triedI've followed all the steps in the docs for Kimai + Authentik integration. I've even tried workarounds from the GitHub issues. Possible solutionI did some light digging in the code... kimai/src/Saml/SamlProvider.php Line 53 in 07ac6c3 The error is thrown in the above codeblock, possibly in the "validateUser" function. kimai/src/User/UserService.php Line 110 in 07ac6c3 I suspect it's got something to do with groups.
Maybe I have to change something in Authentik? cc @kevinpapst |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary (one line)
When using Authentik as IdP for Kimai SAML SSO, both linking existing users and provisioning new users fail with
Failed creating or hydrating user/AuthenticationException. Attribute mappings sometimes send literal schema URIs (e.g.http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name) instead of actual values.Full problem description
I integrated Authentik (IdP) with Kimai (SP) using SAML. Problems observed:
Two distinct failure modes (both produce the same exception):
Existing local user (linking failure)
Scenario: a user already exists in Kimai (created earlier by local sign-up or import).
Behavior: SAML login fails with Kimai logs showing:
or
Workaround observed: delete the local Kimai user; then log in via SAML — Kimai creates a fresh user from the assertion and authentication succeeds.
Admin-created user workaround: Deleting the user and having an administrator create a new user (with the desired username/email) before trying SSO will often allow authentication to succeed, but this is inconsistent — sometimes the admin-created account works for SSO, and sometimes it still fails with the same exception. This inconsistency makes the workaround unreliable in production.
Impact: cannot safely migrate existing users to SAML; admins must delete or re-create users (risking data/link loss) to allow SSO.
New user provisioning failure (inconsistent)
Failed creating or hydrating user/AuthenticationExceptionand does not create the account.Additional symptom — attribute-as-URI:
http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name) instead of the user’s name.Other note: earlier
Signature validation failederrors occurred until IdP cert was added to Kimai; included for context.Logs (representative)
Kimai:
Earlier:
Authentik test output example:
{ "username": "muhammad.hashim", "pk": 21, "email": "muhammad.hashim*****@gmail.com" }Config snippets
Kimai
local.yaml(example):Authentik — SAML Provider Property Mappings (exact):
Username mapping
SAML Attribute Name:
http://schemas.goauthentik.io/2021/02/saml/usernameExpression:
Email mapping
SAML Attribute Name:
http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddressExpression:
Display name mapping
SAML Attribute Name:
http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameExpression:
Authentik provider settings:
return request.user.email .)x509certfrom Authentik is in Kimai config.What I tried (summary)
return request.user.username.php bin/console cache:clear) and tested in incognito.SAMLResponse(via DevTools) to inspect<NameID>and<AttributeStatement>.Important operational question (please answer explicitly):
We have a lot of existing employee data in Kimai. Can we sync existing local Kimai accounts to SAML identities so users keep their current Kimai accounts (names, emails, timesheets, project links) and do not need to be deleted or re-created? If yes, provide the exact, safe procedure (preferred: an idempotent SQL migration or admin UI steps) including:
I already tried
Kimai version
2.38.0
How do you run Kimai?
Docker
Which PHP version are you using?
8.1
Beta Was this translation helpful? Give feedback.
All reactions