bug: misleading messaging when logto do not understand which app is requesting sigin
Describe the bug
I had some strange issue, that sometimes my login worked and sometimes it shows something strange:
dev:app logs LogtoClientError: Sign-in session not found.
dev:app logs code: "sign_in_session.not_found"
dev:app logs
dev:app logs at new LogtoClientError (/app/node_modules/@logto/client/lib/errors.js:13:9)
dev:app logs at /app/node_modules/@logto/client/lib/client.js:373:19
dev:app logs process.on unhandledRejection
dev:app logs
dev:app logs 8 | user_cancelled: 'The user cancelled the action.',
dev:app logs 9 | missing_scope_organizations: `The \`${UserScope.Organizations}\` scope is required`,
dev:app logs 10 | });
Scopes were not an issue. And strangely it worked in Chrome, but didn't in Safari. Magic. I've tried to debug logto code, but there was no correlations, it worked 99% of the time, until it doesn't. I thought maybe problem was with my session solution, or because I have multiple instances of an app, maybe some conflicts with sessions? Phases of a moon? Who knows?
But finally after reading this: https://blog.logto.io/troubleshoot-logto-sign-in-404-not-found-error. I found out that it didn't work with localhost, while working completely fine with 127.0.0.1. I used localhost in Safari, and 127 in Chrome, so that is a root of magic behavior.
Expected behavior
Show descriptive error in SDK messaging: "I don't understand which app do you want to login, dummy." and a link to some docs would be enough. Saying that endpoint from which you came from wasn't registered in any of your apps and given list of registered endpoints would be ideal.
How to reproduce?
I wish I would know. I've tried to add localhost to all places in my configuration and logto app configuration trying to fix it, but localhost still do not work for me.
Context
- [x] Logto Cloud
- [x] "@logto/express": "^2.3.11",
Hi @slavaGanzin can you provide us a detailed user flow to reproduce this error? It seems like you have a miss-match callback URL configured.
@simeng-li Yes, I do have a mismatched callback URL. This issue is not about my problem; it's about misleading Logto errors. It should say "You have a mismatched URL" and not give me some ill advice about unrelated features. How I got there is not important; what's important is that the Logto team should rework error messaging. This effort goes beyond this specific case
Sounds reasonable to me. @wangsijie can you take a look?
{"code":"oidc.invalid_redirect_uri","message":"redirect_uri did not match any of the client's registered redirect_uris.","error":"invalid_redirect_uri","error_description":"redirect_uri did not match any of the client's registered redirect_uris","state":"XXXX","iss":"https://XXXX.logto.app/oidc"}
So you are doing this, but client barks on a wrong tree.
I would prefer if it will show url I wanted redirect to and what are available options. Because as I found out today my problem that somehow I got redirect to http and not https, so that was why there were no "match"
The SDK can only detect that βno sign-in flow was initiated,β resulting in the error message: βSign-in session not found.β It cannot determine the underlying cause of this issue, so I donβt believe we should change the error message. However, we can certainly add a debug link to the documentation website for further guidance.
@wangsijie I showed the error from original request, that has a proper error. But it is wrapped up in try catch in your code, so it hides descriptive error and outputs misleading one.
p.s. And one little ask more, please stop showing errors in languages, detected based on IP. If I'm using servers hosted in Finland, it doesn't make me finish.
So there are two things to do:
- In SDK, show original error message from the server.
- In Server, detect lanuages only based on request IP address.
- My question is why I get error messages in different languages?
the same. logto works in docker,can not vist another docker container?
Hi @slavaGanzin, regarding the "misleading messaging": The SDK does handle the redirect URI mismatch error and will throw an error with the code callback_uri_verification.redirect_uri_mismatched. In your case, you only see "session not found." A possible reason is that you are redirected to a new URL that has no active session data. The Express SDK, by default, uses cookie-based sessions, and cookies are saved to a specific origin. So, if the initial URL is not the same as the redirected URL, the latter cannot access the sign-in session. And a session is needed to compare the redirect URI.
And regarding the language detection, we have fixed it in https://github.com/logto-io/logto/pull/7028
I am closing this now, feel free to reopen if you have any further questions.