I had this exact same issue, ID takes me back to correct CM domain, but got a 404 on the POST to /identity/signin.
In my case I had scaled the CM environment to multiple instances but did not turn on Sticky Session as per this document from Sitecore: "Out-proc session state management is not officially supported. We recommend that you use in-process ...
If User/password is huge counts and users are not related to sitecore sites
You have to handle with custom implementation. I have a similar requirement to
manage users with sitecore system.
My github project have the end to end user management functionality. User sign-
up/login/Reset-password/Authenticate user/JWT token issuer functionality.
Reference git ...