ory.sh: Could not find they TOTP key in the internal context
Preflight checklist
- [X] I could not find a solution in the existing issues, docs, nor discussions.
- [X] I agree to follow this project's Code of Conduct.
- [X] I have read and am following this repository's Contribution Guidelines.
- [ ] I have joined the Ory Community Slack.
- [ ] I am signed up to the Ory Security Patch Newsletter.
Ory Network Project
No response
Describe the bug
Not very impressive !
Received this error when I tried to enable 2FA on Ory's own website !
An error occured An unexpected error has occurred. If the problem persists please contact [email protected]. Could not find they TOTP key in the internal context. This is a code bug and should be reported to https://github.com/ory/kratos/.
Reproducing the bug
- Create new account
- Scan QR code
- Click submit/save
- Observe error
Relevant log output
No response
Relevant configuration
No response
Version
Ory website
On which operating system are you observing this issue?
None
In which environment are you deploying?
None
Additional Context
No response
Hi, thanks for the report. In which browser did you observe the issue?
Hi
Brave (a.k.a. Chrome)
I was not able to reproduce this issue with the steps you provided. Can you please provide a reproducible case? Thank you!
We're seeing this error as well, with some users. Microsoft Edge-browser. Attached the screenshot given user sent.
Today the same as @dirksierd mentioned, an other client:
"error": {
"code": 500,
"message": "An internal server error occurred, please contact the
system administrator",
"reason": "Could not find they TOTP key in the internal context...."
This client mentioned that he used "Google Authenticator"
Can you please provide reproducible steps?
Hi @aeneasr, i've tought on your request for STR for a while. The problem is, that is is user-dependant. We have two cases (@dirksierd and mine) but both cases need a validated e-mailadres to reproduce the error. And I can't/won't share the password and e-mailadress. If I change the e-mailadress, it just works normally.
STR:
- Register the user by the requirements of the user-schema (I won’t publicly share the schema, but can share it in private)
- Receive the e-mail verification and enter it in the UI
- User is logged in the UI and can register a 2FA TOTP
- User scans the QR-code with Microsoft Authenticator (user 1) or Google Authenticator (user 2)
- User enters the 6-digit code in the verification field
- User presses Save
- Error occurs:
Could not find they TOTP key in the internal context
Isn't it possible to reverse engeneer the issue based on the error-message? And provide us hints about what could be going wrong?
I've validated a couple of times that the returned code of app is right. When I enter a wrong 6-digit code, the normal behaviour is seen. So I guess that the code is validated succesfully, but than the error is served. My guess would be:
- code is succesfully validated
- key/token/whatever is NOT saved
- some process can't find the TOTP key (eg. webhook-call?) in context
The error message suggests that there is a problem in the settings flow. So for example:
- User opens settings
- User changes email
- Then tries to add TOTP
- See error
If you could narrow down which interaction is causing the problem we can probably find the problem quickly!
Today an other user (user 3) have seen the same error message. We've repeated the STR from scratch. I've validated that the user did not change the e-mail/other information, did not used any submit-button in the UI, other than the TOTP-submit-button.
Still the error is shown right after saving the TOTP-validation code in the UI.
I did check: The Ory Dashboard does indicate that the TOTP is set succesfully for this user.
@dirksierd can you validate that there are no changes trough any API that could interfer? I don't see any webhooks related to this in our configuration, though.
I believe this to be a dupe of: https://github.com/ory/kratos/issues/2401
I've tried many different routes, but cannot reproduce. Linking and unlinking the TOTP-method works without problem as well.
Here's the steps with a bit more detail…
- Go to our app
- Press the 'login'-button
- Get redirected to the Ory-hosted UI for our project (with ?return_to=APP_URL)
- Choose 'sign up' and complete sign up flow (which has a webhook-check on POST)
- Get redirected back to our app when succesfull
- See a notice that AAL2 is required, with a button to go do so
- Press the button (to: /ui/settings?return_to=APP_URL#totp) – creating a new flow
- Usually: user links TOTP and gets redirected back, able to use the app
- Sometimes: get the aforementioned error when trying to link TOTP
Ticket 2401 talks about logging in and out in-between. We could try that, but not sure. Step 7 tells me we're not re-using a flow to set the TOTP. It's a newly created flow.
We're still running into this issue. Could we perhaps go private to discuss with a set of given credentials, that's seeing this issue consistently?