Overview
This node handles the response logic for a login attempt within an HTTP forward authentication workflow. It verifies whether a user ID is provided and returns either a successful login redirect or a failure message embedded in a login template. This node is typically used in scenarios where an external service delegates authentication to an n8n workflow, such as implementing custom single sign-on (SSO) or integrating with legacy authentication systems.
Practical examples include:
- Returning a customized login page with error messages when login fails.
- Redirecting authenticated users to a specified URL after successful login.
- Managing session tokens and rate limiting based on user IP addresses.
Properties
| Name | Meaning |
|---|---|
| User ID | The identifier of the user attempting to log in. If empty, the login attempt is considered failed. |
| Validation Error Message | The error message displayed on the login page if the User ID is empty (login failed). |
Output
The node outputs a JSON object with the following structure:
status: A string indicating the result of the login attempt. Possible values:"success": Login succeeded."fail": Login failed.
user: Present only on success; contains the User ID.remoteIp: Optionally included if the remote IP address is available from the trigger node.
Additionally, the node sends an HTTP response directly with:
- An HTTP status code:
200with a login HTML page containing the error message if login failed.302redirecting to a configured URL if login succeeded.401unauthorized if no User ID was provided.500internal server error on unexpected failures.
- Headers including content type, location for redirects, and a forwarded user header.
- A session token cookie set on successful login.
Dependencies
- Requires a Redis connection credential to manage session tokens and rate limiting.
- Depends on a paired HTTP Forward Auth Trigger node in the same workflow to provide context such as remote IP and configuration parameters.
- Uses utility functions for session token generation, session creation, cookie setting, and rate limit resetting.
Troubleshooting
- No HttpForwardAuthTrigger node found: The node throws an error if it cannot find the required trigger node in the workflow. Ensure that the HTTP Forward Auth Trigger node is present and correctly configured.
- Empty User ID: If the User ID input is empty, the node treats the login as failed and returns the validation error message. Make sure the User ID is correctly passed to avoid unintended login failures.
- Redis connection issues: Failures connecting to Redis will cause errors. Verify Redis credentials and connectivity.
- Unexpected errors: The node returns a 500 Internal Server Error response on unexpected exceptions. Check logs for detailed error messages.