You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Remove isTotp() and setTotp() from UserRepresentation #25727
Both isTotp() and setTotp() have been deprecated for 7+ years since #3258 was landed. They will have to be either removed with a clear migration guide for consumers, or we should un-deprecate this functionality.
I am inclined to remove the deprecation, as this field is part of the public REST API, and therefore it is very likely we have users relying on this feature. Unless there is a recommended way users can use a similar field (not aware of any such field existing).
Hi,
In my project, I have implemented a custom user profile page using org.keycloak:keycloak-admin-client to communicate with Keycloak. Currently, I am using isTotp() method to show the users whether they have enabled 2FA or not. If this method is removed then I will have to use UserResource#credentials method and that means one more reset call. I am already making two reset calls every time I fetch a user's profile. One to fetch user representation and another for fetching the user's groups. If isTotp() is removed I will have to make 3 calls. I believe groups and the status of 2FA are an essential part of a user profile. Therefore one should be able to fetch them using a single reset call.
My vote is to either keep it deprecated or remove it, but not un-deprecate it. This method was introduced at the time when we had totp as the only possible 2-factor mechanism. But since now we have WebAuthn and Recovery-codes (and maybe custom 2-factor authentication providers), this method does not have much value as it is specific only to totp .
So IMO we should either:
Remove this without any replacement
Keep it as it is (but that is not ideal)
Fill the user by default with his credentials when user endpoint GET method is called
Same like (3), but add some parameter to user endpoint GET method (like boolean parameter includeCredentials)
My vote is to either (1), then (2). I would not rather do (3) or (4) as we have dedicated endpoint to retrieve user's credential and the only concern is performance in being able to retrieve everything in single REST call as pointed by @aharpour .
But in general, isn't it better pattern to rather have various data to be returned in multiple REST calls rather than have 1 huge chunk of data returned in the single REST call? Note that single REST call also has performance implications for all those not interested in additional data like credentials.
@aharpour Also note that you can add custom REST extension if performance is really concern for you. In this REST extension, you would be able to return current user together with his credentials.
I would also add that if the concern is making a client simpler, you can (more complexity in the design) add a BFF (backend for frontend) to act as a facade to the server.
@mposolda I apologize for the delay in my response. Among the four options presented, I would vote for (2). But, I would like to propose a fifth alternative. The purpose of this boolean was to convey whether two-factor authentication (2FA) had been activated. Since "TOTP" was the sole form of 2FA supported at the time, they named the boolean "totp." Had they designated it "twoFactorAuthentication" instead, this field would not have required depreciating after more authentication methods were introduced. Instead, it could have been updated to become true so long as any type of 2FA had been activated.
Therefore, I suggest removing the "totp" field and instead introducing a boolean that indicates whether any form of two-factor authentication has been activated.
Activity
jonkoops commentedon Dec 20, 2023
@keycloak/core can someone from the core team pass judgement on this?
jonkoops commentedon Dec 20, 2023
I am inclined to remove the deprecation, as this field is part of the public REST API, and therefore it is very likely we have users relying on this feature. Unless there is a recommended way users can use a similar field (not aware of any such field existing).
aharpour commentedon Dec 20, 2023
Hi,
In my project, I have implemented a custom user profile page using org.keycloak:keycloak-admin-client to communicate with Keycloak. Currently, I am using isTotp() method to show the users whether they have enabled 2FA or not. If this method is removed then I will have to use UserResource#credentials method and that means one more reset call. I am already making two reset calls every time I fetch a user's profile. One to fetch user representation and another for fetching the user's groups. If isTotp() is removed I will have to make 3 calls. I believe groups and the status of 2FA are an essential part of a user profile. Therefore one should be able to fetch them using a single reset call.
mposolda commentedon Jan 11, 2024
My vote is to either keep it deprecated or remove it, but not un-deprecate it. This method was introduced at the time when we had
totpas the only possible 2-factor mechanism. But since now we have WebAuthn and Recovery-codes (and maybe custom 2-factor authentication providers), this method does not have much value as it is specific only tototp.So IMO we should either:
includeCredentials)My vote is to either (1), then (2). I would not rather do (3) or (4) as we have dedicated endpoint to retrieve user's credential and the only concern is performance in being able to retrieve everything in single REST call as pointed by @aharpour .
But in general, isn't it better pattern to rather have various data to be returned in multiple REST calls rather than have 1 huge chunk of data returned in the single REST call? Note that single REST call also has performance implications for all those not interested in additional data like credentials.
@aharpour Also note that you can add custom REST extension if performance is really concern for you. In this REST extension, you would be able to return current user together with his credentials.
pedroigor commentedon Jan 11, 2024
I would also add that if the concern is making a client simpler, you can (more complexity in the design) add a BFF (backend for frontend) to act as a facade to the server.
aharpour commentedon Jan 25, 2024
@mposolda I apologize for the delay in my response. Among the four options presented, I would vote for (2). But, I would like to propose a fifth alternative. The purpose of this boolean was to convey whether two-factor authentication (2FA) had been activated. Since "TOTP" was the sole form of 2FA supported at the time, they named the boolean "totp." Had they designated it "twoFactorAuthentication" instead, this field would not have required depreciating after more authentication methods were introduced. Instead, it could have been updated to become true so long as any type of 2FA had been activated.
Therefore, I suggest removing the "totp" field and instead introducing a boolean that indicates whether any form of two-factor authentication has been activated.
1 remaining item
alexted commentedon Oct 1, 2024
one more year, haha!
pedroigor commentedon Oct 1, 2024
Or a bit more ... We lost this one and we cannot aford more risks now right before releasing 26.
mposolda commentedon Mar 23, 2026
Another related issue (which has also PR): #43587
org.keycloak.representations.idm.UserRepresentation#isTotpmethod #43587 as a duplicate of this issueorg.keycloak.representations.idm.UserRepresentation#isTotpmethod #43587 as a duplicate of this issue