Membrane API Gateway returns 500 Internal Server Error with the detail Could not handle login request.! when the login plugin fails while it handles a request to its login dialog. The client's input, the second-factor token provider or the login dialog configuration is usually to blame.
The response contains the status 500 Internal Server Error, the title Internal server error., the detail Could not handle login request.!, the problem type https://membrane-api.io/problems/internal and a link to this page. In development mode, the exception message is included as well. The type internal means that the gateway could not complete the processing of the exchange. In production mode, the title is replaced by Internal Server Error and the details are left out.
The login plugin protects an API with a login form. Requests under its path are handled by the login dialog: the login form, the form for a second-factor token, the consent page, the logout and the static resources of the dialog, which are loaded from location. If handling one of these requests throws an exception, Membrane answers with this error.
Membrane parses the query string and the form parameters of the dialog strictly. A parameter name that occurs more than once, or an invalid percent-escape such as %zz, is rejected with Could not parse query: ….
A POST to the consent page must contain the consent form parameter. A hand-built request without it fails.
After a correct password, the configured token provider issues the second-factor token. This fails if the user has no attribute the provider needs, for example no sms attribute for an SMS token provider, or if sending the e-mail or SMS fails.
The request URI cannot be parsed, the form body could not be read, or the login page template from location could not be rendered.
Any other exception that the login plugin does not turn into an error response itself is reported under the same URL by Membrane's generic error handler. The detail then reads Aborting! Exception caused in … flow. and names the plugin, the request URI and the flow. Unless the exception points to your configuration or to the message, this usually indicates a bug in Membrane.
location are complete and valid.By default, Membrane runs in development mode and adds details to error responses that help you find the problem. These details may reveal information about your setup. In production, turn them off:
configuration:
production: trueconfiguration: production: true
Add the configuration document to your apis.yaml and separate it from the APIs with ---. The title then reads Internal Server Error, and instead of the details the response only contains a log key. Search the gateway log for this key to find the exception.
If the plugin is nested inside a request, response or abort element and throws an unexpected exception, the exception message, the stack trace and the link to this page are currently sent even in production mode. Fix the failing plugin rather than relying on production mode to hide them.
Configuration reference:
Still stuck? See the troubleshooting guide or ask on GitHub Issues. For commercial support, contact info@predic8.de.